Beispiel #1
0
 public Sequence(Sequence baseSequence) : this()
 {
     //commands.AddRange(baseSequence.commands);
     baseSequence.commands.ForEach((BasicCommand bc) => commands.Add(new BasicCommand(bc)));
     name       = "Copy of " + baseSequence.name;
     startState = baseSequence.startState;
     endState   = baseSequence.endState;
 }
Beispiel #2
0
        public void Start(SequencerState currentState)
        {
            Logger.Log("[Sequencer] Sequence started", Logger.Level.Debug);

            if (commands == null)
            {
                return;
            }

            if (isLocked)
            {
                Logger.Log("[Sequencer] Cannot start sequence " + name + " as it is Locked", Logger.Level.Debug);
                return;
            }

            if (currentState != startState)
            {
                Logger.Log("[Sequencer] Cannot start sequence " + name + " because its start state is not current state", Logger.Level.Debug);
                return;
            }
            //if the sequence is marked as Finished - reset it and start anew.
            if (isFinished)
            {
                Reset();
            }

            isActive = true;

            //find first unfinished command
            lastCommandIndex = commands.FindIndex(s => s.isFinished == false);
            Logger.Log("[Sequencer] First unfinished Index = " + lastCommandIndex, Logger.Level.Debug);
            if (lastCommandIndex == -1)
            {
                //there are no unfinished commands, loop if needed or SetFinished and exit
                if (isLooped)
                {
                    Reset();
                }
                else
                {
                    SetFinished();
                    return;
                }
            }
            //now we can start/continue execution
            //we execute commands until first wait command

            Resume(lastCommandIndex);

            Logger.Log("[Sequencer] Sequence Start finished, lastCommandIndex = " + lastCommandIndex, Logger.Level.Debug);
            //else we are either finished, or most likely waiting for commands to finish.
        }