示例#1
0
        public void Visit(FsmNode node)
        {
            AppendLine("// This code was generated by the StateMachineCompiler (https://github.com/DanStevens/StateMachineCompiler)");
            AppendLine();
            AppendLine("// Uncomment #define below to swap out the multiple event methods with a single");
            AppendLine("// `TiggerEvent` method that accepts an `Event` enum as an argument (or define it as a");
            AppendLine("// compilation symbol in the project settings if you cannot rely on changing manual changes to");
            AppendLine("// this generated file). You will want to do this if you have events and actions with the same name");
            AppendLine($"//#define {SingleEventFuncDefine}");
            AppendLine();

            IndentedAppendLine("using System;");
            AppendLine();
            IndentedAppendLine("namespace Smc");
            IndentedAppendLine("{");
            indentLevel++;
            IndentedAppendLine($"public class {node.ClassName} : {node.ActionsName}");
            IndentedAppendLine("{");

            indentLevel++;

            node.States.Accept(this);
            node.Events.Accept(this);
            node.Delegators.Accept(this);
            node.Initial.Accept(this);
            node.HandleEvent.Accept(this);

            indentLevel--;
            IndentedAppendLine("}");
            indentLevel--;
            IndentedAppendLine("}");
        }
示例#2
0
 public virtual void Visit(FsmNode node)
 {
     node.Initial.Accept(this);
     node.States.Accept(this);
     node.Events.Accept(this);
     node.Delegators.Accept(this);
     node.HandleEvent.Accept(this);
 }
示例#3
0
 public void Goto(string key)
 {
     curNode = null;
     if (nodes.ContainsKey(key))
     {
         curNode = nodes[key];
     }
 }
示例#4
0
 public FSM <TEdge> addNode_0_(string key)
 {
     _lastAddedNode = new FsmNode()
     {
         Key = key,
     };
     nodes.Add(key, _lastAddedNode);
     return(this);
 }
示例#5
0
 public override void Visit(FsmNode node)
 {
     StringBuilder.Append($"class {node.ClassName}:{node.ActionsName} {{");
     node.Delegators.Accept(this);
     node.States.Accept(this);
     node.Events.Accept(this);
     node.Initial.Accept(this);
     node.HandleEvent.Accept(this);
     StringBuilder.Append("}");
 }
        public void Visit(FsmNode node)
        {
            IndentedAppendLine("using System;");
            AppendLine();
            IndentedAppendLine("namespace Smc");
            IndentedAppendLine("{");
            indentLevel++;
            IndentedAppendLine($"public class {node.ClassName} : {node.ActionsName}");
            IndentedAppendLine("{");

            indentLevel++;

            node.States.Accept(this);
            node.Events.Accept(this);
            node.Delegators.Accept(this);
            node.Initial.Accept(this);
            node.HandleEvent.Accept(this);

            indentLevel--;
            IndentedAppendLine("}");
            indentLevel--;
            IndentedAppendLine("}");
        }
示例#7
0
        public override void OnEnter()
        {
            var go = InputPath.Value as FsmPath;

            if (go == null || go.Value == null)
            {
                Debug.Log("Input incomplete");
                Finish();
                return;
            }             // it would continue for a frame without return

            var a   = 1 / 0f;
            var doo = InputPath.Value as FsmPath;
            var coo = new FsmNode();

            if (doo.Value == null)
            {
                return;
            }
            else
            {
                var pathNodes = doo.Value.vectorPath;
                for (var i = 0; i < Enumerable.Count(pathNodes); i++)
                {
                    var o = (pathNodes[i] - Fsm.GetOwnerDefaultTarget(DistanceFrom).transform.position).sqrMagnitude;
                    if (o < a)
                    {
                        position.Value = pathNodes[i];
                        coo.Value      = doo.Value.path[i];
                        a = o;
                    }
                }
            }
            node.Value = coo;
            Finish();
        }
示例#8
0
 public void Reset()
 {
     curNode = null;
 }