1
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23",
|
||||
"GUID:42a9827d94e00374aa52e51f0a1b035c",
|
||||
"GUID:87bea3a21c744b1478660b70494160ba",
|
||||
"GUID:ef0bb553b58b90b488bdbe8672e3be0b"
|
||||
"GUID:ef0bb553b58b90b488bdbe8672e3be0b",
|
||||
"GUID:48ef04d98836e2640bf90b524bdff904"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
@@ -163,7 +163,6 @@ namespace BITFALL.Guns
|
||||
isHolstered = false;
|
||||
|
||||
var animName = animator.animator.GetCurrentAnimatorStateInfo(0).shortNameHash;
|
||||
animator.animator.enabled = true;
|
||||
animator.animator.Play(animName,-1,0);
|
||||
inputActionGroup.allowInput.AddElement(this);
|
||||
expectFiring.Reset();
|
||||
@@ -200,7 +199,6 @@ namespace BITFALL.Guns
|
||||
}
|
||||
|
||||
destroyCancellationToken.ThrowIfCancellationRequested();
|
||||
animator.animator.enabled = false;
|
||||
|
||||
await base.ExitAsync();
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BITFALL.Entities.Equipment.Melee;
|
||||
using BITFALL.Entities.Equipment.Universal.States;
|
||||
using BITFALL.Entities.Inventory;
|
||||
using BITFALL.Player.Inventory;
|
||||
using BITKit;
|
||||
using BITKit.Entities;
|
||||
@@ -13,14 +14,18 @@ using Draw = BITFALL.Entities.Equipment.Universal.States.Draw;
|
||||
|
||||
namespace BITFALL.Entities.Equipment.Universal
|
||||
{
|
||||
public interface IUseState:IState{}
|
||||
public interface IUseState : IState
|
||||
{
|
||||
}
|
||||
|
||||
public abstract class UseState : IUseState
|
||||
{
|
||||
[SerializeField] protected UniversalUseController useController;
|
||||
public virtual bool Enabled { get; set; }
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public virtual void OnStateEntry(IState old)
|
||||
@@ -38,14 +43,48 @@ namespace BITFALL.Entities.Equipment.Universal
|
||||
|
||||
public class UniversalUseController : BITEquipBase<IUseState>
|
||||
{
|
||||
[SerializeField] private IAssetableItem[] supportedItems;
|
||||
|
||||
public override bool IsSupportItem(IBasicItem _item)
|
||||
[Inject] private IPlayerInventory _playerInventory;
|
||||
[Inject] private IEntityInventory _inventory;
|
||||
[Inject] private IPlayerEquipSelector _playerEquipSelector;
|
||||
public bool IClosed { get; set; }
|
||||
public override void OnAwake()
|
||||
{
|
||||
return _item is not null && supportedItems.Any(x=>x.AddressablePath == _item.AddressablePath);
|
||||
base.OnAwake();
|
||||
animator[0].onStateEnter += (x) =>
|
||||
{
|
||||
if (IsEntered is false) return;
|
||||
switch (x)
|
||||
{
|
||||
case BITConstant.Player.Draw:
|
||||
TransitionState<Draw>();
|
||||
break;
|
||||
case BITConstant.Player.Use:
|
||||
TransitionState<Use>();
|
||||
break;
|
||||
case BITConstant.Player.Exit:
|
||||
TransitionState<Exit>();
|
||||
break;
|
||||
}
|
||||
};
|
||||
animator[0].onStateExit += x =>
|
||||
{
|
||||
if (IsEntered is false) return;
|
||||
switch (x)
|
||||
{
|
||||
case BITConstant.Player.Exit:
|
||||
IClosed = true;
|
||||
if (IsEntered)
|
||||
{
|
||||
_playerEquipSelector.Cancel();
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void Entry()
|
||||
{
|
||||
IClosed = false;
|
||||
base.Entry();
|
||||
TransitionState<Draw>();
|
||||
}
|
||||
@@ -58,20 +97,37 @@ namespace BITFALL.Entities.Equipment.Universal
|
||||
|
||||
public override async UniTask ExitAsync()
|
||||
{
|
||||
await base.ExitAsync();
|
||||
|
||||
while (destroyCancellationToken.IsCancellationRequested is false)
|
||||
{
|
||||
if (animator[0].stateName == BITConstant.Player.Exit && animator[0].currentState.normalizedTime > 1)
|
||||
if (IClosed)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (destroyCancellationToken.IsCancellationRequested)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
await UniTask.NextFrame();
|
||||
}
|
||||
|
||||
await base.ExitAsync();
|
||||
}
|
||||
|
||||
public override void AnimationEvent(string eventName)
|
||||
{
|
||||
base.AnimationEvent(eventName);
|
||||
|
||||
switch (eventName)
|
||||
{
|
||||
case BITConstant.Player.Use when CurrentState is Use:
|
||||
if (_inventory.UseItem(Item))
|
||||
{
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,29 +1,23 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using BITKit.StateMachine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITFALL.Entities.Equipment.Universal.States
|
||||
{
|
||||
[Serializable]
|
||||
public sealed class Draw:UseState
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
useController.animator[0].onStateExit += (x) =>
|
||||
{
|
||||
if (Enabled && x is BITConstant.Player.Draw)
|
||||
{
|
||||
useController.TransitionState<Use>();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Use:UseState
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Exit:UseState
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user