public void ResumeFSM(FSMElement element) { if (this.Root != null) { this.Root.ResumeFSM(Root.MapElement2Canvas(element)); } }
public void FinishFSM(FSMElement e) { if (this.Root != null) { this.Root.FinishFSM(Root.MapElement2Canvas(e)); } }
public void ReStart(FSMElement element) { if (Root != null) { this.Root.Restart(Root.MapElement2Canvas(element)); } }
public FSMElement LastFSMElement(FSMElement e) { if (this.Root == null) { return(null); } return(this.Root.LastFSMElement(Root.MapElement2Canvas(e))); }
public bool TryGetCanvas(FSMElement e, out NodeCanvas outcanvas) { if (Root != null) { outcanvas = Root.MapElement2Canvas(e); return(true); } outcanvas = null; return(false); }
private static void CallEnter(AbstractParams p) { if (p.ArgCount > 0) { FSMElement e = p.ReadObject() as FSMElement; if (e != null) { e.OnEnter(); } } else { LogMgr.LogError("参数异常"); } }
internal NodeCanvas MapElement2Canvas(FSMElement e) { List <NodeCanvas> values = GetAllFSM(); for (int i = 0; i < values.Count; ++i) { NodeCanvas canvas = values[i]; for (int j = 0; j < canvas.nodes.Count; ++j) { Node node = canvas.nodes[j]; if (node == e) { ListPool.TryDespawn(values); return(canvas); } } } ListPool.TryDespawn(values); return(null); }
internal void Reset(NodeCanvas nodecanvas) { this.current = null; this.laststate = null; this.isRunning = true; if (nodecanvas != null && nodecanvas.nodes.Count > 0) { if (cachecanvas == null || cachecanvas != nodecanvas) { cachecanvas = nodecanvas; for (int i = 0; i < nodecanvas.nodes.Count; ++i) { Node nd = nodecanvas.nodes[i]; this.nodequeue.Add(nd); } current = nodequeue[0] as FSMElement; } else { nodecanvas.nodes.Clear(); for (int i = 0; i < nodequeue.Count; ++i) { Node nd = nodequeue[i]; if (nd is FSMElement) { ((FSMElement)nd).ResetValues(); } nodecanvas.nodes.Add(nd); } current = nodequeue[0] as FSMElement; } } else { LogMgr.LogErrorFormat("结点异常 :{0}", nodecanvas); } }
internal void UpdateInFrame(long cnt) { if (runners.Count == 0) { return; } List <NodeCanvas> values = GetAllFSM(); for (int i = 0; i < values.Count; ++i) { NodeCanvas nodecanvas = values[i]; if (nodestates.ContainsKey(nodecanvas)) { FSMRunerState runningstate = nodestates[nodecanvas]; if (runningstate.isRunning && runningstate.current != null) { FSMElement current = runningstate.current; FSMElement laststate = runningstate.laststate; if (laststate != null) { if (laststate != current) { // LogMgr.LogError("this is " + nodecanvas); ScriptCommand exitcmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallExit); exitcmd.CallParams.WriteObject(laststate); exitcmd.ExcuteAndRelease(); ScriptCommand entercmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallEnter); entercmd.CallParams.WriteObject(current); entercmd.ExcuteAndRelease(); } } else { // LogMgr.LogError("this is " + nodecanvas); ScriptCommand cmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallEnter); cmd.CallParams.WriteObject(current); cmd.ExcuteAndRelease(); } runningstate.laststate = current; bool ret = current.UpdateFrameInFSM(cnt); if (!ret && runningstate.isRunning) { FSMElement next = current.SelectForNext(); if (next != null) { runningstate.current = next; } else { ScriptCommand exitcmd = ScriptCommand.Create((int)FrameWorkCmdDefine.FSMCallExit); exitcmd.CallParams.WriteObject(current); exitcmd.ExcuteAndRelease(); runningstate.isRunning = false; this.CallFinishCanvas(nodecanvas); } } } } } ListPool.TryDespawn(values); }
protected override bool Select(FSMElement element) { return(true); }
protected override void From(FSMElement element) { }
protected abstract void From(FSMElement element);
protected abstract bool Select(FSMElement element);