using Syntriax.Modules.Movement.State; using UnityEngine; using UnityEngine.Events; namespace Syntriax.Modules.Movement { [RequireComponent(typeof(Rigidbody2D))] public abstract class TwoDimensionalMovementBase : MonoBehaviour, IMovement { protected Rigidbody2D rigid = null; protected IToggleState toggleState = null; private bool _canTakeOver = false; public float BaseSpeed { get; set; } = 1f; public float MovementMultiplier { get; set; } = 1f; public UnityEvent OnTakeOverStateChanged { get; protected set; } = null; public bool CanTakeOver { get => _canTakeOver; protected set { bool isNewValue = _canTakeOver != value; _canTakeOver = value; if (isNewValue) OnTakeOverStateChanged.Invoke(value); } } public IToggleState ToggleState { get; protected set; } = null; protected virtual void Awake() { OnTakeOverStateChanged = new UnityEvent(); } protected virtual void Start() { rigid = GetComponent(); toggleState = GetComponent(); } public abstract void Move(float x = 0, float y = 0, float z = 0); public abstract void ApplyMovement(); } }