1
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "BITFALL.Entities.Animation",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
|
||||
"GUID:84d565da37ad40546a118cfb3c3509f3",
|
||||
"GUID:d525ad6bd40672747bde77962f1c401e",
|
||||
"GUID:49b49c76ee64f6b41bf28ef951cb0e50",
|
||||
"GUID:677cd05ca06c46b4395470200b1acdad"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -1,18 +1,48 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using AYellowpaper.SerializedCollections;
|
||||
using BITFALL.Entities.Equipment;
|
||||
using BITKit.Animations;
|
||||
using UnityEngine;
|
||||
|
||||
public class EntitiesAnimationController : MonoBehaviour
|
||||
namespace BITKit.Entities.Animation
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public sealed class EntitiesAnimationController : EntityComponent
|
||||
{
|
||||
[SerializeField] private UnityAnimator unityAnimator;
|
||||
[SerializeField] private SerializedDictionary<string, RuntimeAnimatorController> animatorControllers;
|
||||
[Inject]
|
||||
private IEntityEquipment _entityEquipment;
|
||||
|
||||
private RuntimeAnimatorController _initialRuntimeAnimatorController;
|
||||
|
||||
private readonly DoubleBuffer<RuntimeAnimatorController> _runtimeAnimatorControllerBuffer = new();
|
||||
public override void OnAwake()
|
||||
{
|
||||
base.OnAwake();
|
||||
_entityEquipment.OnEquip += OnEquip;
|
||||
_initialRuntimeAnimatorController = unityAnimator.animator.runtimeAnimatorController;
|
||||
}
|
||||
|
||||
public override void OnLateUpdate(float deltaTime)
|
||||
{
|
||||
if(_runtimeAnimatorControllerBuffer.TryGetRelease(out var controller))
|
||||
{
|
||||
unityAnimator.animator.runtimeAnimatorController = controller;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEquip(IBasicItem obj)
|
||||
{
|
||||
if(animatorControllers.TryGetValue(obj.AddressablePath, out var controller))
|
||||
{
|
||||
_runtimeAnimatorControllerBuffer.Release(controller);
|
||||
}
|
||||
else
|
||||
{
|
||||
_runtimeAnimatorControllerBuffer.Release(_initialRuntimeAnimatorController);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user