using Animancer; using NodeCanvas.Framework; using NodeCanvas.StateMachines; using UnityEngine; namespace Ether { [RequireComponent(typeof(Rigidbody2D))] public class PlayerController : MonoBehaviour { Rigidbody2D playerRigid; FSMOwner fsmOwer; Blackboard blackboard; bool isInputEnabled = true; private void Start() { playerRigid = GetComponent(); fsmOwer = GetComponent(); blackboard = GetComponent(); DontDestroyOnLoad(gameObject); } private void OnEnable() { EventCenter.AddListener(ReInputEvent.Move, OnMove); } private void OnMove(Vector2 move) { if (!isInputEnabled) { return; } if (move == Vector2.zero) { blackboard.SetVariableValue("moveDirection", move); } else { blackboard.SetVariableValue("moveDirection", move); } } public void SetInputOperation(bool isEnable) { Vector2 moveDirection = blackboard.GetVariableValue("moveDirection"); if (moveDirection != Vector2.zero) { blackboard.SetVariableValue("direction", moveDirection); blackboard.SetVariableValue("moveDirection", Vector2.zero); } isInputEnabled = isEnable; } private void OnDisable() { EventCenter.RemoveListener(ReInputEvent.Move, OnMove); } } }