99 lines
2.4 KiB
C#
99 lines
2.4 KiB
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using Animancer;
|
||
|
using BITKit;
|
||
|
using BITKit.Entities;
|
||
|
using BITKit.StateMachine;
|
||
|
using Cysharp.Threading.Tasks;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace BITFALL.Entities.Equipment
|
||
|
{
|
||
|
public abstract class StateWeaponController<TState> : StateBasedMonoBehaviour<TState> , IEquipBase where TState : IState
|
||
|
{
|
||
|
[SerializeField] internal AssetableItem assetableItem;
|
||
|
[SerializeField] internal AnimancerComponent animancerComponent;
|
||
|
[SerializeField] internal Renderer[] renderers;
|
||
|
|
||
|
[Inject]
|
||
|
internal InputActionGroup inputActionGroup;
|
||
|
|
||
|
[Inject] internal IEntityOverride _override;
|
||
|
public virtual bool IsEntered { get; set; }
|
||
|
|
||
|
public event Action<string> OnAnimationEvent;
|
||
|
|
||
|
protected readonly ValidHandle allowRenderer = new ValidHandle();
|
||
|
public virtual void Entry()
|
||
|
{
|
||
|
allowRenderer.AddElement(this);
|
||
|
}
|
||
|
|
||
|
public virtual UniTask EntryAsync()
|
||
|
{
|
||
|
return UniTask.CompletedTask;
|
||
|
}
|
||
|
|
||
|
public virtual void Entered()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public virtual void Exit()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public virtual UniTask ExitAsync()
|
||
|
{
|
||
|
return UniTask.CompletedTask;
|
||
|
}
|
||
|
|
||
|
public virtual void Exited()
|
||
|
{
|
||
|
allowRenderer.RemoveElement(this);
|
||
|
animancerComponent.Stop();
|
||
|
}
|
||
|
|
||
|
public virtual void OnAwake()
|
||
|
{
|
||
|
allowRenderer.AddListener(allow =>
|
||
|
{
|
||
|
foreach (var x in renderers)
|
||
|
{
|
||
|
x.enabled = allow;
|
||
|
}
|
||
|
});
|
||
|
if (_override is not null)
|
||
|
{
|
||
|
_override.OnOverride += (x) =>
|
||
|
{
|
||
|
allowRenderer.SetDisableElements(_override,x);
|
||
|
};
|
||
|
}
|
||
|
allowRenderer.Invoke();
|
||
|
Initialize();
|
||
|
}
|
||
|
|
||
|
public virtual void OnStart()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public virtual void OnUpdate(float deltaTime)
|
||
|
{
|
||
|
CurrentState?.OnStateUpdate(deltaTime);
|
||
|
}
|
||
|
public virtual string AddressablePath => assetableItem.AddressablePath;
|
||
|
public virtual IEntity Entity { get; set; }
|
||
|
public virtual IBasicItem Item { get; set; }
|
||
|
public virtual bool IsSupportItem(IBasicItem item)=>item is not null && item.AddressablePath == AddressablePath;
|
||
|
|
||
|
public virtual void PlayAudio(string audioName)
|
||
|
{
|
||
|
}
|
||
|
public virtual void AnimationEvent(string eventName)
|
||
|
{
|
||
|
OnAnimationEvent?.Invoke(eventName);
|
||
|
}
|
||
|
}
|
||
|
}
|