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); } } }
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); }
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 } } ; }
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 } } ; }
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); } }
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); }