1
This commit is contained in:
@@ -25,36 +25,49 @@ namespace BITFALL.Entities.Equipment.Universal
|
||||
[SerializeField] protected AnimancerComponent animancerComponent;
|
||||
[SerializeField] protected AnimationClip[] clips;
|
||||
public virtual bool Enabled { get; set; }
|
||||
protected AnimancerState currentState;
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
|
||||
}
|
||||
public virtual void OnStateEntry(IState old)
|
||||
{
|
||||
PlayAnimation();
|
||||
}
|
||||
public virtual void PlayAnimation()
|
||||
{
|
||||
if (clips?.Length is 0) return;
|
||||
var clip = clips.Random();
|
||||
animancerComponent.Play(clip).Events.OnEnd=OnPlayEnd;
|
||||
currentState = animancerComponent.Play(clip);
|
||||
currentState.Events.OnEnd = OnPlayEnd;
|
||||
}
|
||||
|
||||
public virtual void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
}
|
||||
|
||||
protected virtual void OnPlayEnd()
|
||||
{
|
||||
if (currentState is { IsValid: true })
|
||||
currentState.Events.OnEnd = null;
|
||||
}
|
||||
}
|
||||
|
||||
public class UniversalUseController : BITEquipBase<IUseState>
|
||||
{
|
||||
public struct Used:IProperty{}
|
||||
/// <summary>
|
||||
/// 是使用完就释放,还是连续使用
|
||||
/// </summary>
|
||||
[SerializeField] private bool release;
|
||||
[Inject] internal IPlayerInventory _playerInventory;
|
||||
[Inject] internal IPlayerEquipSelector _playerEquipSelector;
|
||||
[Inject] internal IEntityEquipmentContainer _equipmentContainer;
|
||||
public bool IClosed { get; set; }
|
||||
public bool Release => release;
|
||||
public override void Entry()
|
||||
{
|
||||
base.Entry();
|
||||
@@ -72,6 +85,7 @@ namespace BITFALL.Entities.Equipment.Universal
|
||||
switch (eventName)
|
||||
{
|
||||
case BITConstant.Player.Use when CurrentState is Use:
|
||||
var current = Item;
|
||||
if (item.TryGetProperty<EquipmentAsSlot>(out var asSlot))
|
||||
{
|
||||
_equipmentContainer.TryUseEquip(asSlot.slot);
|
||||
@@ -80,6 +94,8 @@ namespace BITFALL.Entities.Equipment.Universal
|
||||
{
|
||||
_inventory.UseItem(Item);
|
||||
}
|
||||
if (current?.Id == Item?.Id)
|
||||
Item = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user