80 lines
1.6 KiB
C#
80 lines
1.6 KiB
C#
using BITFALL.Player.Movement;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using BITKit.StateMachine;
|
|
using Lightbug.CharacterControllerPro.Core;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Entities.Player.Movement.States
|
|
{
|
|
public abstract class PlayerCharacterState : IEntityMovementState
|
|
{
|
|
[Inject] public PlayerCharacterController self;
|
|
[SerializeField] protected CharacterActor actor;
|
|
private IEntityMovementState entryState;
|
|
public bool Enabled { get; set; }
|
|
public virtual void Initialize()
|
|
{
|
|
|
|
}
|
|
|
|
public virtual void OnStateEntry(IState old)
|
|
{
|
|
|
|
entryState=old is IPlayerRunState or IPlayerSprintState ? old as IEntityMovementState: null;
|
|
}
|
|
|
|
public virtual void OnStateUpdate(float deltaTime)
|
|
{
|
|
}
|
|
|
|
public virtual void OnStateExit(IState old, IState newState)
|
|
{
|
|
}
|
|
|
|
public virtual void UpdateVelocity(ref Vector3 currentVelocity,float deltaTime)
|
|
{
|
|
}
|
|
|
|
public virtual void UpdateRotation(ref Quaternion currentRotation,float deltaTime)
|
|
{
|
|
}
|
|
|
|
public virtual void BeforeUpdateMovement(float deltaTime)
|
|
{
|
|
}
|
|
|
|
public virtual void AfterUpdateMovement(float deltaTime)
|
|
{
|
|
}
|
|
public virtual void ExecuteCommand<T>(T command)
|
|
{
|
|
}
|
|
protected virtual void Exit()
|
|
{
|
|
if ( entryState is not null)
|
|
{
|
|
if ( entryState is IPlayerWalkState or IPlayerRunState or IPlayerSprintState && self.topBlocked )
|
|
{
|
|
self.TransitionState<Crouch>();
|
|
}
|
|
else
|
|
{
|
|
self.TransitionState(entryState);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (self.topBlocked)
|
|
{
|
|
self.TransitionState<Crouch>();
|
|
}
|
|
else
|
|
{
|
|
self.TransitionState<Walk>();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|