using System.Collections; using System.Collections.Generic; using UnityEngine; using BITKit; using BITKit.Entities; using UnityEngine.InputSystem; namespace BITFALL.Entites { public class EntityRootMotionController : EntityComponent { [SerializeReference, SubclassSelector] References _vertical; [SerializeReference, SubclassSelector] References _horizontal; [SerializeReference, SubclassSelector] References _sqrMagnitude; public override void OnStart() { base.OnStart(); entity.AddListener(nameof(OnMovement), OnMovement); } public override void OnDestroyComponent() { base.OnDestroyComponent(); entity.RemoveListener(nameof(OnMovement), OnMovement); } public void OnMovement(InputAction.CallbackContext context) { var moveDelta = context.ReadValue(); entity.Set(_vertical, moveDelta.y); entity.Set(_horizontal, moveDelta.x); entity.Set(_sqrMagnitude,moveDelta.sqrMagnitude); } } }