1
This commit is contained in:
@@ -20,12 +20,15 @@ namespace BITFALL.Guns.States
|
||||
{
|
||||
[SerializeField] private ExpectState<bool> _expectRun;
|
||||
[Inject] protected ISelector _selector;
|
||||
private float elapsedTime;
|
||||
private float requestBoltActionElapsedTime;
|
||||
private bool boltActionImmediately;
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
switch (old)
|
||||
{
|
||||
case Movement:
|
||||
case Equip:
|
||||
break;
|
||||
case Aim:
|
||||
root.animator.CrossFade(BITConstant.Player.Movement, 0.32f);
|
||||
break;
|
||||
@@ -38,13 +41,15 @@ namespace BITFALL.Guns.States
|
||||
}
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
elapsedTime = 0;
|
||||
requestBoltActionElapsedTime = 0;
|
||||
base.OnStateExit(old, newState);
|
||||
_selector.OnActive -= OnActive;
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
elapsedTime += deltaTime;
|
||||
if (root.RequireBolt)
|
||||
requestBoltActionElapsedTime += deltaTime;
|
||||
if (root.animator[0].stateName is not BITConstant.Player.Movement) return;
|
||||
if (root.expectFiring.shouldBe && root.fireInterval.AllowUpdate)
|
||||
{
|
||||
@@ -53,14 +58,24 @@ namespace BITFALL.Guns.States
|
||||
if (root.expectAiming.shouldBe && BITAppForUnity.AllowCursor == false)
|
||||
{
|
||||
root.TransitionState<Aim>();
|
||||
}else if (_expectRun)
|
||||
return;
|
||||
}
|
||||
if (_expectRun)
|
||||
{
|
||||
root.TransitionState<Run>();
|
||||
}else if (root.RequireBolt && elapsedTime > 0.5f || boltActionImmediately)
|
||||
return;
|
||||
}
|
||||
|
||||
switch (root.RequireBolt)
|
||||
{
|
||||
root.TransitionState<Reload>();
|
||||
case var _ when boltActionImmediately:
|
||||
case var _ when requestBoltActionElapsedTime > 1f:
|
||||
case var _ when root.animator[4].stateName == BITConstant.Player.Empty && requestBoltActionElapsedTime>0.32f:
|
||||
root.TransitionState<Reload>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnActive(ISelectable selectable)
|
||||
{
|
||||
root.animator.Play(BITConstant.Player.Interactive);
|
||||
@@ -167,13 +182,12 @@ namespace BITFALL.Guns.States
|
||||
root.animator.CrossFade(BITConstant.Player.Aim, 0.16f);
|
||||
break;
|
||||
}
|
||||
_entityMovement.ExecuteCommand<PlayerDisableRunCommand>(new(this));
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
}
|
||||
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
base.OnStateExit(old, newState);
|
||||
_entityMovement.ExecuteCommand<PlayerEnableRunCommand>(new(this));
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,false));
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
@@ -214,8 +228,6 @@ namespace BITFALL.Guns.States
|
||||
base.Initialize();
|
||||
root.animator[0].onStateExit += OnAnimationStateExit;
|
||||
}
|
||||
|
||||
|
||||
private void OnAnimationStateExit(string obj)
|
||||
{
|
||||
if (obj is BITConstant.Player.Equip) completed = true;
|
||||
@@ -225,22 +237,26 @@ namespace BITFALL.Guns.States
|
||||
{
|
||||
completed = false;
|
||||
root.animator.Play(BITConstant.Player.Equip,-1,0);
|
||||
root.animator.animator.Update(0);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
}
|
||||
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
base.OnStateExit(old, newState);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,false));
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
{
|
||||
var state = root.animator[0];
|
||||
if (state.stateName == BITConstant.Player.Equip)
|
||||
//var state = root.animator[0];
|
||||
if (completed)
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
root.TransitionState<Movement>();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
root.animator.Play(BITConstant.Player.Equip);
|
||||
root.TransitionState<Movement>();
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// root.animator.Play(BITConstant.Player.Equip);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +280,7 @@ namespace BITFALL.Guns.States
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
|
||||
_entityMovement.ExecuteCommand<PlayerCancelRunCommand>();
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
|
||||
if (root.RequireBolt)
|
||||
{
|
||||
@@ -289,6 +305,7 @@ namespace BITFALL.Guns.States
|
||||
{
|
||||
root.RequireBolt = false;
|
||||
base.OnStateExit(old, newState);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,false));
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
@@ -310,13 +327,15 @@ namespace BITFALL.Guns.States
|
||||
}
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
root.UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Melee);
|
||||
_entityMovement.ExecuteCommand(new PlayerDisableRunCommand(this));
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
}
|
||||
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
_entityMovement.ExecuteCommand(new PlayerEnableRunCommand(this));
|
||||
base.OnStateExit(old,newState);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,false));
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
@@ -338,7 +357,15 @@ namespace BITFALL.Guns.States
|
||||
{
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
root.animator.Play(BITConstant.Player.Climb);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
}
|
||||
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
base.OnStateExit(old, newState);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,false));
|
||||
}
|
||||
|
||||
public override void OnMovementStateChanged(IEntityMovementState old, IEntityMovementState newState)
|
||||
|
Reference in New Issue
Block a user