65 lines
1.4 KiB
C#
65 lines
1.4 KiB
C#
using BITFALL.Player.Movement;
|
|
using BITKit.Entities;
|
|
using BITKit.StateMachine;
|
|
using Lightbug.CharacterControllerPro.Core;
|
|
using UnityEngine;
|
|
|
|
namespace BITFALL.Entities.Player.Movement.States
|
|
{
|
|
public abstract class PlayerCharacterState : IEntityMovementState
|
|
{
|
|
[SerializeField] protected PlayerCharacterController characterController;
|
|
[SerializeField] protected CharacterActor actor;
|
|
private IEntityMovementState entryState;
|
|
public bool Enabled { get; set; }
|
|
public virtual void Initialize()
|
|
{
|
|
characterController.UnityEntity.Inject(this);
|
|
}
|
|
|
|
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 && entryState is IEntityMovementState state)
|
|
{
|
|
characterController.TransitionState(state);
|
|
}
|
|
else
|
|
{
|
|
characterController.TransitionState<Walk>();
|
|
}
|
|
}
|
|
}
|
|
}
|