1
This commit is contained in:
@@ -62,6 +62,14 @@ namespace BITKit.Entities
|
||||
/// </summary>
|
||||
public interface IEntityMovement:IStateMachine<IEntityMovementState>
|
||||
{
|
||||
/// <summary>
|
||||
/// 视角中心,通常是摄像机的位置
|
||||
/// </summary>
|
||||
Vector3 ViewCenter { get; }
|
||||
/// <summary>
|
||||
/// 视角旋转,通常是摄像机的旋转
|
||||
/// </summary>
|
||||
Quaternion ViewRotation { get; }
|
||||
/// <summary>
|
||||
/// 基于运动的速度,是相对于标准化移动速度的相对速度
|
||||
/// </summary>
|
||||
@@ -75,6 +83,10 @@ namespace BITKit.Entities
|
||||
/// </summary>
|
||||
Vector3 GroundVelocity { get; }
|
||||
/// <summary>
|
||||
/// 旋转速度
|
||||
/// </summary>
|
||||
Vector3 AngularVelocity { get; }
|
||||
/// <summary>
|
||||
/// 是否在地面上
|
||||
/// </summary>
|
||||
bool IsGrounded { get; }
|
||||
@@ -96,8 +108,16 @@ namespace BITKit.Entities
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
void Movement(InputAction.CallbackContext context);
|
||||
|
||||
/// <summary>
|
||||
/// 执行命令
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
void ExecuteCommand<T>(T command=default);
|
||||
/// <summary>
|
||||
/// 执行命令的回调
|
||||
/// </summary>
|
||||
event Action<object> OnCommand;
|
||||
}
|
||||
public interface IEntityMovementState:IState
|
||||
{
|
||||
@@ -107,80 +127,4 @@ namespace BITKit.Entities
|
||||
void AfterUpdateMovement(float deltaTime);
|
||||
void ExecuteCommand<T>(T command);
|
||||
}
|
||||
public interface IPlayerMovementCommand{}
|
||||
[Serializable]
|
||||
public class MonoMovementProxy:IEntityMovement
|
||||
{
|
||||
[SerializeField] private MonoBehaviour monoBehaviour;
|
||||
private IEntityMovement _entityMovementImplementation=>monoBehaviour as IEntityMovement;
|
||||
|
||||
public Vector3 LocomotionBasedVelocity=>_entityMovementImplementation.LocomotionBasedVelocity;
|
||||
public Vector3 Velocity => _entityMovementImplementation.Velocity;
|
||||
|
||||
public Vector3 GroundVelocity => _entityMovementImplementation.GroundVelocity;
|
||||
|
||||
public bool IsGrounded => _entityMovementImplementation.IsGrounded;
|
||||
|
||||
public void SyncMovement(Vector3 velocity, Vector3 position, Quaternion rotation, bool isGrounded)
|
||||
{
|
||||
_entityMovementImplementation.SyncMovement(velocity, position, rotation, isGrounded);
|
||||
}
|
||||
|
||||
public void Movement(Vector3 relativeVector)
|
||||
{
|
||||
_entityMovementImplementation.Movement(relativeVector);
|
||||
}
|
||||
|
||||
public void Movement(InputAction.CallbackContext context)
|
||||
{
|
||||
_entityMovementImplementation.Movement(context);
|
||||
}
|
||||
|
||||
public void ExecuteCommand<T>(T command)=>_entityMovementImplementation.ExecuteCommand(command);
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => _entityMovementImplementation.Enabled;
|
||||
set => _entityMovementImplementation.Enabled = value;
|
||||
}
|
||||
|
||||
public IEntityMovementState CurrentState
|
||||
{
|
||||
get => _entityMovementImplementation.CurrentState;
|
||||
set => _entityMovementImplementation.CurrentState = value;
|
||||
}
|
||||
|
||||
public event Action<IEntityMovementState, IEntityMovementState> OnStateChanged
|
||||
{
|
||||
add => _entityMovementImplementation.OnStateChanged += value;
|
||||
remove => _entityMovementImplementation.OnStateChanged -= value;
|
||||
}
|
||||
|
||||
public IDictionary<Type, IEntityMovementState> StateDictionary => _entityMovementImplementation.StateDictionary;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
_entityMovementImplementation.Initialize();
|
||||
}
|
||||
|
||||
public void UpdateState(float deltaTime)
|
||||
{
|
||||
_entityMovementImplementation.UpdateState(deltaTime);
|
||||
}
|
||||
|
||||
public void DisposeState()
|
||||
{
|
||||
_entityMovementImplementation.DisposeState();
|
||||
}
|
||||
|
||||
public void TransitionState<State>() where State : IEntityMovementState
|
||||
{
|
||||
_entityMovementImplementation.TransitionState<State>();
|
||||
}
|
||||
|
||||
public void TransitionState(IEntityMovementState state)
|
||||
{
|
||||
_entityMovementImplementation.TransitionState(state);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user