1
This commit is contained in:
@@ -11,6 +11,7 @@ using BITKit.Entities;
|
||||
using BITKit.Selection;
|
||||
using UnityEngine.InputSystem;
|
||||
using BITKit.StateMachine;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
// ReSharper disable UnassignedField.Local
|
||||
|
||||
@@ -36,7 +37,6 @@ namespace BITFALL.Guns.States
|
||||
switch (old)
|
||||
{
|
||||
case Movement:
|
||||
case Equip:
|
||||
break;
|
||||
default:
|
||||
if (_entityMovement.CurrentState is IPlayerWalkState)
|
||||
@@ -54,20 +54,7 @@ namespace BITFALL.Guns.States
|
||||
|
||||
private void OnInspect(InputAction.CallbackContext obj)
|
||||
{
|
||||
PlayAnimation("Inspect");
|
||||
// if (root.MotionMatchingService.TryMatch(out var value, SearchKey.Append(BITConstant.Player.Inspect).ToArray()) is false)
|
||||
// {
|
||||
// Debug.LogWarning("No inspect animation found");
|
||||
// return;
|
||||
// }
|
||||
// Debug.Log(value);
|
||||
// switch (value)
|
||||
// {
|
||||
// case IMotionMatchingClip clip:
|
||||
// inspectState = animancerComponent.Layers[1].Play(clip.Clip);
|
||||
// inspectState.Events.OnEnd = () => { animancerComponent.Layers[1].Stop(); };
|
||||
// break;
|
||||
// }
|
||||
PlayAnimation(0,PlayAnimationVoid,nameof(BITConstant.Player.Inspect));
|
||||
}
|
||||
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
@@ -116,11 +103,14 @@ namespace BITFALL.Guns.States
|
||||
}
|
||||
}
|
||||
|
||||
public void OnActive(ISelectable selectable)
|
||||
public async void OnActive(ISelectable selectable)
|
||||
{
|
||||
//root.animator.Play(BITConstant.Player.Interactive);
|
||||
PlayAnimation(root.SearchKey.Append(nameof(BITConstant.Player.Interactive)).ToArray());
|
||||
await UniTask.DelayFrame(8);
|
||||
if (root.destroyCancellationToken.IsCancellationRequested) return;
|
||||
if (root.IsEntered && Enabled)
|
||||
PlayAnimation(0, PlayAnimationVoid,BITConstant.Player.Interactive);
|
||||
}
|
||||
|
||||
public override void OnMovementStateChanged(IEntityMovementState old, IEntityMovementState newState)
|
||||
{
|
||||
_expectRun = newState is IPlayerRunState or IPlayerSprintState;
|
||||
@@ -277,6 +267,8 @@ namespace BITFALL.Guns.States
|
||||
Limit =false,
|
||||
Speed = root._gun.InitialAimMovementSpeed,
|
||||
});
|
||||
|
||||
equipService.Aim = 0;
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
@@ -311,7 +303,7 @@ namespace BITFALL.Guns.States
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
public sealed class Equip : GunState
|
||||
public sealed class Draw : GunState
|
||||
{
|
||||
[Inject]
|
||||
private IPlayerEquipSelector _equipSelector;
|
||||
@@ -319,8 +311,6 @@ namespace BITFALL.Guns.States
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
//root.animator[0].onStateExit += OnAnimationStateExit;
|
||||
|
||||
_equipSelector.OnUpdateEquip += OnUpdateEquip;
|
||||
}
|
||||
private readonly List<int> _drawed = new();
|
||||
@@ -345,13 +335,13 @@ namespace BITFALL.Guns.States
|
||||
base.OnStateEntry(old);
|
||||
if (_drawed.TryAdd(root.Item.Id))
|
||||
{
|
||||
PlayAnimation(nameof(BITConstant.Player.Draw));
|
||||
root.UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.Draw);
|
||||
//root.animator.Play(BITConstant.Player.Draw, -1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayAnimation(nameof(BITConstant.Player.QuickDraw));
|
||||
root.UnityEntity.Invoke(Constant.Animation.Play, BITConstant.Player.QuickDraw);
|
||||
//root.animator.Play(BITConstant.Player.QuickDraw,-1,0);
|
||||
}
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
}
|
||||
@@ -419,23 +409,32 @@ namespace BITFALL.Guns.States
|
||||
Focus = true,
|
||||
Sender = this
|
||||
});
|
||||
|
||||
root.inputActionGroup.RegisterCallback(root.meleeAction, OnMelee);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
base.OnStateExit(old,newState);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,false));
|
||||
|
||||
root.inputActionGroup.UnRegisterCallback(root.meleeAction, OnMelee);
|
||||
|
||||
_entityMovement.ExecuteCommand(new PlayerFocusCommand()
|
||||
{
|
||||
Focus = false,
|
||||
Sender = this
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnStateUpdate(float deltaTime)
|
||||
private void OnMelee(InputAction.CallbackContext obj)
|
||||
{
|
||||
_entityMovement.ExecuteCommand<PlayerCancelRunCommand>();
|
||||
if (obj.performed is false) return;
|
||||
if (!(currentState.NormalizedTime > 0.5f)) return;
|
||||
currentState.Events.OnEnd = null;
|
||||
currentState.Stop();
|
||||
PlayAnimation();
|
||||
}
|
||||
public override void OnMovementStateChanged(IEntityMovementState old, IEntityMovementState newState)
|
||||
{
|
||||
@@ -469,7 +468,15 @@ namespace BITFALL.Guns.States
|
||||
case IPlayerClimbState:
|
||||
case IPlayerLinkState { LinkArea: 44 }:
|
||||
case IPlayerVaultState:
|
||||
root.TransitionState<Climb>();
|
||||
if (Enabled)
|
||||
{
|
||||
currentState.Stop();
|
||||
PlayAnimation();
|
||||
}
|
||||
else
|
||||
{
|
||||
root.TransitionState<Climb>();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (Enabled)
|
||||
@@ -491,4 +498,23 @@ namespace BITFALL.Guns.States
|
||||
animancerComponent.Stop();
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public sealed class Tactics : GunState
|
||||
{
|
||||
public override void OnStateEntry(IState old)
|
||||
{
|
||||
base.OnStateEntry(old);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,true));
|
||||
}
|
||||
public override void OnStateExit(IState old, IState newState)
|
||||
{
|
||||
base.OnStateExit(old, newState);
|
||||
_entityMovement.ExecuteCommand<PlayerPauseRunCommand>(new(this,false));
|
||||
}
|
||||
protected override void OnEnd()
|
||||
{
|
||||
base.OnEnd();
|
||||
root.TransitionState<Movement>();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user