public bool Restore(string machineName, IEnumerable <MyObjectBuilder_ScriptSMCursor> cursors)
        {
            MyObjectBuilder_ScriptSM machineDefinition;

            if (!m_machineDefinitions.TryGetValue(machineName, out machineDefinition))
            {
                return(false);
            }

            var definitionWithoutCursors = new MyObjectBuilder_ScriptSM
            {
                Name        = machineDefinition.Name,
                Nodes       = machineDefinition.Nodes,
                Transitions = machineDefinition.Transitions
            };

            var newMachine = new MyVSStateMachine();

            newMachine.Init(definitionWithoutCursors);

            foreach (var newCursorData in cursors)
            {
                if (newMachine.RestoreCursor(newCursorData.NodeName) == null)
                {
                    return(false);
                }
            }

            m_runningMachines.Add(newMachine);
            return(true);
        }
        public bool Run(string machineName, long ownerId = 0)
        {
            MyObjectBuilder_ScriptSM ob;
            if (m_machineDefinitions.TryGetValue(machineName, out ob))
            {
                var machine = new MyVSStateMachine();
                machine.Init(ob, ownerId);
                m_runningMachines.Add(machine);
                if(MyVisualScriptLogicProvider.MissionStarted != null)
                    MyVisualScriptLogicProvider.MissionStarted(machine.Name);

                return true;
            }

            return false;
        }
        public bool Run(string machineName, long ownerId = 0)
        {
            MyObjectBuilder_ScriptSM ob;

            if (m_machineDefinitions.TryGetValue(machineName, out ob))
            {
                var machine = new MyVSStateMachine();
                machine.Init(ob, ownerId);
                m_runningMachines.Add(machine);
                if (MyVisualScriptLogicProvider.MissionStarted != null)
                {
                    MyVisualScriptLogicProvider.MissionStarted(machine.Name);
                }

                return(true);
            }

            return(false);
        }
        public bool Restore(string machineName, IEnumerable<MyObjectBuilder_ScriptSMCursor> cursors)
        {
            MyObjectBuilder_ScriptSM machineDefinition;
            if(!m_machineDefinitions.TryGetValue(machineName, out machineDefinition))
                return false;

            var definitionWithoutCursors = new MyObjectBuilder_ScriptSM
            {
                Name = machineDefinition.Name,
                Nodes = machineDefinition.Nodes,
                Transitions = machineDefinition.Transitions
            };

            var newMachine = new MyVSStateMachine();
            newMachine.Init(definitionWithoutCursors);

            foreach (var newCursorData in cursors)
                if(newMachine.RestoreCursor(newCursorData.NodeName) == null)
                    return false;

            m_runningMachines.Add(newMachine);
            return true;
        }
Exemplo n.º 5
0
 private void SMManager_StateMachineStarted(MyVSStateMachine obj)
 {
     obj.CursorStateChanged += new Action <MyVSStateMachineNode, MyVSStateMachineNode>(this.obj_CursorStateChanged);
 }