This commit is contained in:
CortexCore
2023-12-16 23:30:08 +08:00
parent 78216a3d47
commit 961ae8feb4
33 changed files with 369 additions and 148 deletions

View File

@@ -3,10 +3,10 @@
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:66d2ae14764cc7d49aad4b16930747c0",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
"GUID:6ef4ed8ff60a7aa4bb60a8030e6f4008",
"GUID:d8b63aba1907145bea998dd612889d6b"
"GUID:d8b63aba1907145bea998dd612889d6b",
"GUID:2665a8d13d1b3f18800f46e256720795"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -6,7 +6,8 @@
"GUID:87bea3a21c744b1478660b70494160ba",
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
"GUID:7efac18f239530141802fb139776f333",
"GUID:75469ad4d38634e559750d17036d5f7c"
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:a3de65b07192e7d49bad7b4032d681de"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -1,6 +1,7 @@
using System;
using BITFALL;
using BITKit.Entities;
using BITKit.Entities.Physics;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
@@ -17,6 +18,9 @@ namespace BITKit
[Inject] private IHealth _health;
[Inject(true)] private IEntityOverride _override;
[Inject(true)]
private IEntityPhysics _physics;
#endregion
public override void OnStart()
@@ -114,6 +118,11 @@ namespace BITKit
{
case false:
isDead = true;
if (_physics is not null)
{
_physics.Velocity = agent.velocity;
}
agent.ResetPath();
break;
case true when isDead:
{

View File

@@ -7,9 +7,10 @@ namespace BITFALL.HotFix
{
public class FPVScaleFix : MonoBehaviour
{
[SerializeField] private Transform fpvScale;
private void LateUpdate()
{
transform.localScale = Vector3.zero;
fpvScale.localScale = Vector3.zero;
}
}
}

View File

@@ -237,8 +237,8 @@ namespace BITFALL.Items
private void Tick(float obj)
{
if(gameService.CurrentState is not IGamePlayingState) return;
if(gameService.CurrentState is not IGamePlayingState || !this) return;
while (_registerQueue.TryDequeue(out var item))
{
if (!item || _worldItems.TryAdd(item.Id,item) is false) continue;

View File

@@ -57,7 +57,7 @@ namespace BITFALL.Player.Survival
if (_health.IsAlive is false) return;
foreach (var x in Elements)
{
x.Value -= deltaTime;
x.Value -= x.Decay * deltaTime;
if (x.Value <= 0)
{
_damageService.Execute(new DamageMessage()

View File

@@ -15,7 +15,9 @@ namespace BITKit
private void Start()
{
if(rigidbody.isKinematic)Destroy(this);
if (!rigidbody.isKinematic) return;
Destroy(this);
if(rigidbody)Destroy(rigidbody);
}
private void Update()
@@ -24,6 +26,7 @@ namespace BITKit
if (_collider.gameObject.isStatic)
{
Destroy(this);
if(rigidbody)Destroy(rigidbody);
return;
}
enabled = false;

View File

@@ -3,28 +3,30 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using BITKit;
using Unity.Burst;
using Unity.Collections;
using Unity.Jobs;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Jobs;
using UnityEngine.Pool;
namespace BITFALL.Rig{
public class TickOverrideTranformService : MonoBehaviour
{
public struct SetTransformJob : IJobParallelForTransform
//[BurstCompile]
public struct CopyTransformJob : IJobParallelForTransform
{
// Jobs declare all data that will be accessed in the job
// By declaring it as read only, multiple jobs are allowed to access the data in parallel
[Unity.Collections.ReadOnly]
public NativeArray<Vector3> positions;
public NativeArray<float3> positions;
[Unity.Collections.ReadOnly]
public NativeArray<Quaternion> rotations;
public NativeArray<quaternion> rotations;
// The code actually running on the job
public void Execute(int index, TransformAccess transform)
{
transform.position = positions[index];
transform.rotation = rotations[index];
transform.SetPositionAndRotation(positions[index],rotations[index]);
}
}
public static void Register(int id,TickOverrideTransform tickOverrideTransform)
@@ -40,12 +42,16 @@ namespace BITFALL.Rig{
private static readonly Dictionary<int, TickOverrideTransform> Dictionary = new();
private static bool IsDirty;
private static TickOverrideTransform[] Array;
private static Transform[] Sources;
private static Transform[] Targets;
[SerializeReference, SubclassSelector] private ITicker ticker;
private TransformAccessArray m_AccessArray;
private bool _isCompleted;
private NativeArray<quaternion> _rotations;
private NativeArray<float3> _positions;
private JobHandle _jobHandle;
private InitializationState _initializationState;
private void OnEnable()
{
ticker.Add(Tick);
@@ -56,33 +62,59 @@ namespace BITFALL.Rig{
}
private void Tick(float obj)
{
if (!_isCompleted) return;
switch (_initializationState)
{
case InitializationState.Initializing when _jobHandle.IsCompleted:
_jobHandle.Complete();
_rotations.Dispose();
_positions.Dispose();
_initializationState = InitializationState.Initialized;
break;
case InitializationState.None:
break;
default:
return;
}
if (IsDirty)
{
Array = Dictionary.Values.ToArray();
var newLength = Dictionary.Count;
Sources = new Transform[newLength];
Targets = new Transform[newLength];
var index = 0;
foreach (var x in Dictionary.Values)
{
Sources[index] = x.Source;
Targets[index] = x.Target;
index++;
}
}
m_AccessArray = new TransformAccessArray(Array.Length);
var length = Sources.Length;
var rotations = new NativeArray<Quaternion>(Array.Length, Allocator.TempJob);
var positions = new NativeArray<Vector3>(Array.Length, Allocator.TempJob);
if(length is 0) return;
m_AccessArray = new TransformAccessArray(length);
m_AccessArray.SetTransforms(Sources);
var index = 0;
foreach (var x in Array)
_positions = new NativeArray<float3>(length, Allocator.Persistent);
_rotations = new NativeArray<quaternion>(length, Allocator.Persistent);
var i = 0;
foreach (var x in Targets)
{
positions[index] = x.Source.position;
rotations[index] = x.Source.rotation;
index++;
_positions[i] = x.position;
_rotations[i] = x.rotation;
i++;
}
var job = new SetTransformJob()
var _job = new CopyTransformJob()
{
positions = positions,
rotations = rotations
positions = _positions,
rotations = _rotations
};
job.Schedule(m_AccessArray);
_isCompleted = true;
_jobHandle = _job.Schedule(m_AccessArray);
_initializationState = InitializationState.Initializing;
}
}

View File

@@ -9,6 +9,12 @@ using UnityEngine;
namespace BITFALL.Player.Movement
{
[Serializable]
public class MonoPlayerFixedPlace:AbstractPlayerFixedPlace
{
[SerializeField] private PlayerFixedPlace playerFixedPlace;
protected override IPlayerFixedPlace _playerFixedPlaceImplementation => playerFixedPlace;
}
public class PlayerFixedPlace :MonoBehaviour, IPlayerFixedPlace,IDescription
{
[SerializeField] private new Rigidbody rigidbody;

View File

@@ -116,6 +116,11 @@ namespace BITFALL.UX
if (arg1.Position.IsDefault()) return;
var indicator =indicatorContainer.Create<VisualElement>(()=>indicatorAsset.CloneTree()[0]);
if (arg1.Damage is 0)
{
indicator[0].style.unityBackgroundImageTintColor = Color.black;
}
_indicators.Add((indicator, (Vector3)arg1.Position, Time.time + 1));
}

View File

@@ -35,7 +35,6 @@ namespace BITFALL.UX
});
hitmarkerImage.GetVisualElement().SetOpacity(0);
}
@@ -47,7 +46,7 @@ namespace BITFALL.UX
private void OnKilled(DamageMessage obj)
{
hitmarkerImage.GetVisualElement().style.unityBackgroundImageTintColor = Color.red;
Execute(obj,1);
Execute(obj);
}
private void OnDamage(DamageMessage obj)
@@ -56,7 +55,7 @@ namespace BITFALL.UX
Execute(obj);
}
private async void Execute(DamageMessage obj,float duration=0.1f)
private void Execute(DamageMessage obj)
{
if ((Entity)obj.Target == playerService.LocalPlayer) return;
@@ -68,11 +67,7 @@ namespace BITFALL.UX
destroyCancellationToken.Register(nextHitmarkerCancellationTokenSource.Cancel);
var sequence = BITween.CreateSequence();
// sequence.Append(
// BITween.MoveToForward(
// hitmarkerImage.GetVisualElement().SetOpacity,
// 0, 1,0.1f
// ));
sequence.Append(UniTask.Delay(200));
sequence.Append(
BITween.MoveToForward(
@@ -88,18 +83,7 @@ namespace BITFALL.UX
0.16f, 1.32f,0.05f
));
scaleSequence.Play(nextHitmarkerCancellationTokenSource.Token).Forget();
// hitmarkerImage.GetVisualElement().SetOpacity(1);
//
// try
// {
// await Task.Delay(TimeSpan.FromSeconds(duration), nextHitmarkerCancellationTokenSource.Token);
// }
// catch (OperationCanceledException)
// {
// return;
// }
//
// hitmarkerImage.GetVisualElement().SetOpacity(0);
}
}

View File

@@ -7,7 +7,9 @@
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
"GUID:1235ca61e7f433b408ed5a68767e7123",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:2e7f0f7a8ee6e144db6fb95614c6d8fe"
"GUID:2e7f0f7a8ee6e144db6fb95614c6d8fe",
"GUID:d525ad6bd40672747bde77962f1c401e",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -22,6 +22,8 @@ namespace BITKit.Vehicles
[SerializeField] private new Rigidbody rigidbody;
[SerializeField] private new Collider collider;
[SerializeField] private Transform model;
[SerializeReference,SubclassSelector] private IPlayerFixedPlace fixedPlace;
private Vector2 _movement;
@@ -32,9 +34,10 @@ namespace BITKit.Vehicles
private bool _hover;
private bool _reset;
private IPlayerFixedPlace _fixedPlace;
private Transform Transform;
private Vector3 _initialPosition;
private Vector3 _initialPosition;
private readonly ValidHandle _resetHandle=new();
private void Start()
{
@@ -50,6 +53,9 @@ private Vector3 _initialPosition;
var newRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(Transform.forward, Vector3.up));
rigidbody.MoveRotation(newRotation);
fixedPlace.OnPlayerEntered += x => _resetHandle.RemoveElement(111);
fixedPlace.OnPlayerExited += x => _resetHandle.AddElement(111);
}
private void FixedUpdate()
@@ -59,7 +65,7 @@ private Vector3 _initialPosition;
var offsetX = Mathf.PerlinNoise(Time.time, 0) - 0.5f;
var offsetY = Mathf.PerlinNoise(0, Time.time) - 0.5f;
_resetHandle.SetElements(123,_reset);
rigidbody.useGravity = !_hover;
@@ -70,7 +76,8 @@ private Vector3 _initialPosition;
var moveForce = up * (_AscendAndDescend * upForce * Time.fixedDeltaTime);
var newRotation = Quaternion.LookRotation(Vector3.ProjectOnPlane(Transform.forward, Vector3.up));
if (_reset)
if (_resetHandle)
{
rigidbody.AddTorque(MathV.CalculateTorque(Transform,newRotation) * (torqueResetDelta * Time.fixedDeltaTime),
ForceMode.VelocityChange);
@@ -161,7 +168,5 @@ private Vector3 _initialPosition;
_reset = false;
}
}
}
}