Ejemplo n.º 1
0
        public void ProcessInstruction(string insText)
        {
            // Clean the instruction text.
            string cleanText = insText.Trim().ToLower();

            // If there is no instruction text, no need to continue.
            if (cleanText.Length == 0)
            {
                ConsoleTrack.tabLookup = string.Empty;
                return;
            }

            // If there was a pipe, split into multiple instructions UNLESS the instruction starts with "macro"
            if (insText.Contains('|') && !cleanText.StartsWith("macro"))
            {
                string[] multiInstructions = insText.Split('|');

                // If we're activating the instructions, run all of them.
                if (ConsoleTrack.activate)
                {
                    foreach (string ins in multiInstructions)
                    {
                        this.ProcessInstruction(ins);
                    }
                }

                // If we're not activating the instructions, only run the last pipe (since we only need to identify that one).
                else
                {
                    this.ProcessInstruction(multiInstructions.Last());
                }

                return;
            }

            // Load Console Track Information
            ConsoleTrack.LoadInstructionText(cleanText);

            // Must have at least one part for a valid instruction.
            if (ConsoleTrack.instructionList.Count < 1)
            {
                return;
            }

            string currentIns = ConsoleTrack.GetArg();

            // Assign Default Character and Player
            ConsoleTrack.player    = Systems.localServer.MyPlayer;
            ConsoleTrack.character = Systems.localServer.MyCharacter;

            // Update the tab lookup.
            ConsoleTrack.PrepareTabLookup(this.consoleDict, currentIns, this.baseHelperText);

            // Invoke the Relevant Next Function
            if (this.consoleDict.ContainsKey(currentIns))
            {
                this.consoleDict[currentIns].Invoke();
            }
        }