using System;
using System.Collections.Generic;
using BITKit.StateMachine;
using UnityEngine;
using UnityEngine.InputSystem;
namespace BITKit.Entities
{
///
/// 期望状态与当前状态
///
///
[Serializable]
public struct ExpectState
{
///
/// 期望状态
///
public T shouldBe;
///
/// 当前状态
///
public T being;
///
/// 强制状态
///
public T force;
public bool UnExpect => !shouldBe.Equals(being);
public void Reset()
{
shouldBe = being = force = default;
}
public void Release()
{
being = shouldBe;
}
public void Release(T value)
{
force = default;
being = shouldBe = value;
}
public static implicit operator ExpectState(T value)
{
return new ExpectState { shouldBe = value, being = value };
}
public static implicit operator T(ExpectState value)
{
return value.being;
}
}
///
/// Entity移动组件接口定义
///
public interface IEntityMovement:IStateMachine
{
Vector3 Position { get; set; }
Quaternion Rotation { get; set; }
Vector3 Forward { get; }
///
/// 视角前方,通常是摄像机的前方
///
Vector3 ViewForward { get; }
///
/// 视角中心,通常是摄像机的位置
///
Vector3 ViewCenter { get; }
///
/// 注视点
///
Vector3 FocusPoint { get; }
///
/// 视角旋转,通常是摄像机的旋转
///
Quaternion ViewRotation { get; }
///
/// 基于运动的速度,是相对于标准化移动速度的相对速度
///
Vector3 LocomotionBasedVelocity { get; }
///
/// 世界空间的速度
///
Vector3 Velocity { get; }
///
/// 在地面的速度 = with {y=0}
///
Vector3 GroundVelocity { get; }
///
/// 旋转速度
///
Vector3 AngularVelocity { get; }
///
/// 是否在地面上
///
bool IsGrounded { get; }
///
/// 同步移动,用于网络或强制同步移动信息
///
///
///
///
///
void SyncMovement(Vector3 velocity, Vector3 position,Quaternion rotation,bool isGrounded);
///
/// 基于相对坐标的移动
///
///
void Movement(Vector3 relativeVector);
///
/// 基于InputAction的移动
///
///
void Movement(InputAction.CallbackContext context);
///
/// 执行命令
///
///
///
void ExecuteCommand(T command=default);
///
/// 执行命令的回调
///
event Action