This commit is contained in:
CortexCore
2023-11-15 23:55:06 +08:00
parent 5446067f91
commit 70247f0242
82 changed files with 3271 additions and 579 deletions

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using System.Net.Configuration;
using BITKit.Animations;
namespace BITKit.Entities
@@ -14,9 +15,15 @@ namespace BITKit.Entities
[SerializeReference, SubclassSelector] private References[] boolParameters;
[SerializeReference, SubclassSelector] private References[] floatParameters;
private List<string> keyWords;
private ConstantHash[] _boolParameterHashes;
private ConstantHash[] _floatParameterHashes;
public override void OnAwake()
{
keyWords = animationKeyWords.Select(x => x.Get()).ToList();
_boolParameterHashes = boolParameters.Select(x =>new ConstantHash(x.Get())).ToArray();
_floatParameterHashes = floatParameters.Select(x =>new ConstantHash(x.Get())).ToArray();
}
public override void OnStart()
{
@@ -35,26 +42,30 @@ namespace BITKit.Entities
});
}
}
public override void OnFixedUpdate(float deltaTime)
{
foreach (var boolPar in boolParameters)
bool cacheBool;
float cacheFloat;
foreach (var boolPar in _boolParameterHashes)
{
animators.ForEach(x =>
{
if (x.isActiveAndEnabled)
x.animator.SetBool(boolPar, UnityEntity.Get<bool>(boolPar));
});
foreach (var x in animators)
{
if (!x.isActiveAndEnabled) return;
UnityEntity.GetDirect<bool>(boolPar, out cacheBool);
x.animator.SetBool(boolPar.HashCode, cacheBool);
}
}
foreach (var floatPar in floatParameters)
foreach (var floatPar in _floatParameterHashes)
{
animators.ForEach(x =>
{
if (x.isActiveAndEnabled)
x.animator.SetFloat(floatPar, UnityEntity.Get<float>(floatPar));
});
foreach (var x in animators)
{
if (!x.isActiveAndEnabled) return;
UnityEntity.GetDirect<float>(floatPar, out cacheFloat);
x.animator.SetFloat(floatPar.HashCode, cacheFloat);
}
}
}
private void OnAnimatorMove()
{
if (enabled is false) return;