1
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace BITKit.Entities
|
||||
{
|
||||
[System.Serializable]
|
||||
public struct ExpectState<T>
|
||||
{
|
||||
public T shouldBe;
|
||||
public T being;
|
||||
public T force;
|
||||
public static implicit operator T(ExpectState<T> value)
|
||||
{
|
||||
return value.being;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
shouldBe = being = force = default;
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
being = shouldBe;
|
||||
}
|
||||
public void Release(T value)
|
||||
{
|
||||
force = default;
|
||||
being = shouldBe = value;
|
||||
}
|
||||
}
|
||||
public interface IEntityMovement
|
||||
{
|
||||
void SyncMovement(Vector3 velocity, Vector3 position,Quaternion rotation,bool isGrounded);
|
||||
}
|
||||
public class EntityMovement : EntityInputComponent, IEntityMovement
|
||||
{
|
||||
Vector2 inputVector;
|
||||
public override void OnMovement(InputAction.CallbackContext context)
|
||||
{
|
||||
inputVector = context.ReadValue<Vector2>();
|
||||
inputVector = Vector2.ClampMagnitude(inputVector, 1);
|
||||
}
|
||||
public override void OnFixedUpdate(float deltaTime)
|
||||
{
|
||||
transform.position += (Vector3)inputVector * deltaTime;
|
||||
}
|
||||
|
||||
public void SyncMovement(Vector3 velocity, Vector3 position, Quaternion rotation, bool isGrounded)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public interface IMovementCallback { }
|
||||
public record MovementCallback : IMovementCallback
|
||||
{
|
||||
public bool started;
|
||||
public bool updated;
|
||||
public bool canceled;
|
||||
}
|
||||
public record OnRunCallback : MovementCallback { }
|
||||
public record OnClimbCallback : MovementCallback { }
|
||||
|
||||
public interface IMovementCancelAction { }
|
||||
public record MovementCancelAction : IMovementCancelAction { }
|
||||
public record CancelMovement : MovementCancelAction { }
|
||||
public record CancelMovementAction : MovementCancelAction { }
|
||||
public record CancelRunOrSprint : MovementCancelAction { }
|
||||
}
|
Reference in New Issue
Block a user