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();
            }
        }
Ejemplo n.º 2
0
        public static void SetLevel()
        {
            byte gridX = (byte)ConsoleTrack.GetArgAsInt();

            ConsoleTrack.possibleTabs = "Example: setLevel 10 10 MyLevelID";

            // If gridX is assigned:
            if (ConsoleTrack.instructionList.Count >= 2)
            {
                byte gridY = (byte)ConsoleTrack.GetArgAsInt();

                // If gridY is assigned:
                if (ConsoleTrack.instructionList.Count >= 3)
                {
                    // Check if this X, Y grid is valid (has a node at it).
                    WEScene         scene  = (WEScene)Systems.scene;
                    WorldZoneFormat zone   = scene.currentZone;
                    byte[]          wtData = scene.worldContent.GetWorldTileData(zone, gridX, gridY);

                    // If the location is a valid node, we can attempt to add a level ID.
                    if (NodeData.IsObjectANode(wtData[5], false, false, true))
                    {
                        string coordStr = Coords.MapToInt(gridX, gridY).ToString();
                        string levelId  = ConsoleTrack.GetArg();
                        ConsoleTrack.helpText = "Assign a level ID to the specified node.";

                        if (zone.nodes.ContainsKey(coordStr))
                        {
                            ConsoleTrack.helpText += " Current level ID is: " + zone.nodes[coordStr];
                        }

                        // If the console was activated:
                        if (ConsoleTrack.activate)
                        {
                            zone.nodes[coordStr] = levelId;
                            return;
                        }
                    }

                    // If the location is invalid:
                    else
                    {
                        ConsoleTrack.helpText = "WARNING! There is not a level node at " + gridX.ToString() + ", " + gridY.ToString();
                    }
                }

                // If gridY has not been assigned:
                else
                {
                    ConsoleTrack.helpText = "Assign a level ID to a node at the specified X, Y coordinate. Enter the Y position.";
                }
            }

            // If gridX has not been assigned:
            else
            {
                ConsoleTrack.helpText = "Assign a level ID to a node at the specified X, Y coordinate. Enter the X position.";
            }
        }
Ejemplo n.º 3
0
        // Returns the next instruction arg as a float.
        public static float GetArgAsFloat(bool increment = true)
        {
            string arg = ConsoleTrack.GetArg(increment);

            if (arg != string.Empty)
            {
                float floatVal;
                if (!float.TryParse(arg, out floatVal))
                {
                    floatVal = 0;
                }
                return(floatVal);
            }

            return(0);
        }
Ejemplo n.º 4
0
        // Returns the next instruction arg as an int.
        public static int GetArgAsInt(bool increment = true)
        {
            string arg = ConsoleTrack.GetArg(increment);

            if (arg != string.Empty)
            {
                int intVal;
                if (!Int32.TryParse(arg, out intVal))
                {
                    intVal = 0;
                }
                return(intVal);
            }

            return(0);
        }
Ejemplo n.º 5
0
        // Returns the next instruction arg as a bool.
        public static bool GetArgAsBool(bool increment = true)
        {
            string arg = ConsoleTrack.GetArg(increment);

            return(arg == "true" || arg == "1" || arg == "on");
        }
Ejemplo n.º 6
0
        // Returns the next instruction arg as a string.
        public static string GetArgAsString(bool increment = true)
        {
            string arg = ConsoleTrack.GetArg(increment);

            return(arg.ToString().ToLower());
        }