コード例 #1
0
 internal void BuildController(UController controller)
 {
     if (controller._machine == null)
     {
         UStateNode <UMachine, string> node = new UStateNode <UMachine, string>();
         node.Data           = controller.MachineID;
         controller._machine = BuildMachine(node);
         if (controller._machine != null)
         {
             _controllers.Add(controller._machine, controller);
         }
     }
 }
コード例 #2
0
        public UMachine InvokeMachine(string machineID)
        {
            UStateNode <UMachine, string> node = new UStateNode <UMachine, string>();

            node.Data = machineID;
            UMachine mac = BuildMachine(node);

            if (mac != null)
            {
                mac.OnEnterState();
            }
            return(mac);
        }
コード例 #3
0
        protected void Bind <S, D>(string stateID, D data) where S : UState, IInitializable <D>, new()
        {
            int index = _nodes.FindIndex(n => n.ID == stateID);

            if (index >= 0)
            {
                _nodes[index] = new UStateNode <S, D>()
                {
                    ID = stateID, Data = data
                }
            }
            ;
        }
コード例 #4
0
        protected void Bind <S>(string stateID) where S : UState, new()
        {
            int index = _nodes.FindIndex(n => n.ID == stateID);

            if (index >= 0)
            {
                _nodes[index] = new UStateNode <S>()
                {
                    ID = stateID
                }
            }
            ;
        }
コード例 #5
0
        public void RegisterState <S, T>(string machineID, string stateID, T arg) where S : UState <T>, new()
        {
            UStateNode <S, T> n = AddNodeToGraph(new UStateNode <S, T>(), stateID, machineID);

            n.Data = arg;
            if (!_instantiators.ContainsKey(typeof(UStateNode <S, T>)))
            {
                Func <UStateNode <S, T>, S> Create = node =>
                {
                    S s = new S();
                    s._node = node;
                    s.SetData(node.Data);
                    return(s);
                };
                _instantiators.Add(typeof(UStateNode <S, T>), Create);
            }
        }
コード例 #6
0
        internal UMachine BuildMachine(UStateNode <UMachine, string> node)
        {
            UMachineGraph graph;

            if (!_machines.TryGetValue(node.Data, out graph))
            {
                return(null);
            }
            UMachine mac = new UMachine();

            mac.SetData(node.Data);
            mac._graph = graph;
            mac._uflow = this;
            mac._node  = node;
            _active.Add(mac);
            return(mac);
        }