//using System; //using System.Collections.Generic; //using System.Linq; //using System.Text; //namespace ET //{ // public class StackFsmComponent:Entity // { // private LinkedList m_FsmStateBases = new LinkedList(); // public Action FsmLinkedListHasChanaged; // public FsmStateBase GetCurrentFsmState() // { // return this.m_FsmStateBases.First.Value; // } // /// // /// 从状态机移除一个状态 // /// // /// // public void RemoveState(string stateName) // { // FsmStateBase temp = GetState(stateName); // if (temp == null) // return; // this.m_FsmStateBases.Remove(temp); // FsmLinkedListHasChanaged?.Invoke(); // } // /// // /// 是否存在某个状态 // /// // /// // /// // private bool HasState(string stateName) // { // foreach (var VARIABLE in this.m_FsmStateBases) // { // if (VARIABLE.StateName == stateName) // { // return true; // } // } // return false; // } // /// // /// 获取某个状态 // /// // /// // /// // private FsmStateBase GetState(string stateName) // { // foreach (var VARIABLE in this.m_FsmStateBases) // { // if (VARIABLE.StateName == stateName) // { // return VARIABLE; // } // } // //Log.Error($"所请求的状态:{stateName}不存在,将会自动创建一个"); // return null; // } // /// // /// 向状态机添加一个状态,如果当前已存在,说明需要把它提到同优先级状态的前面去,让他先执行 // /// // /// 状态类型 // /// 状态名称 // /// 状态优先级 // public void AddState(StateTypes stateTypes, string stateName, int priority) // { // //Log.Info($"意图加入一个{stateTypes}类型的状态"); // FsmStateBase fsmStateBase = this.GetState(stateName); // if (fsmStateBase != null) // { // InsertState(fsmStateBase,true); // return; // } // fsmStateBase = EntityFactory.Create(stateTypes, stateName, priority); // InsertState(fsmStateBase); // } // /// // /// 插入State到链表中,如果当前已存在,说明需要把它提到同优先级状态的前面去,让他先执行 // /// // /// // private void InsertState(FsmStateBase fsmStateBase,bool containsSelf =false) // { // LinkedListNode current = this.m_FsmStateBases.First; // while (current != null) // { // if (fsmStateBase.Priority >= current.Value.Priority) // { // break; // } // current = current.Next; // } // //如果包含自身 // if (containsSelf) // { // if(fsmStateBase.StateName != current.Value.StateName) // { // m_FsmStateBases.Remove(fsmStateBase); // m_FsmStateBases.AddBefore(current,fsmStateBase); // } // } // else // { // if (current != null) // { // this.m_FsmStateBases.AddBefore(current, fsmStateBase); // } // else // { // this.m_FsmStateBases.AddLast(fsmStateBase); // } // } // FsmLinkedListHasChanaged?.Invoke(); // } // /// // /// 刷新状态,其实就是抛出一下链表改变事件,让动画回到该有的状态 // /// // public void RefreshState() // { // FsmLinkedListHasChanaged?.Invoke(); // } // } //}