示例#1
0
        private void AddCommand(string name, Command.Method handler, Command.MethodExtended extendedHandler,
                                string description, object userData)
        {
            if (GetCommandByName(name) != null)
            {
                return;
            }

            Command command = new Command();

            command.name            = name;
            command.handler         = handler;
            command.extendedHandler = extendedHandler;
            command.description     = description;
            command.userData        = userData;

            for (int n = 0; n < commands.Count; n++)
            {
                if (string.Equals(name, commands[n].Name, StringComparison.OrdinalIgnoreCase))
                {
                    commands.Insert(n, command);
                    return;
                }
            }
            commands.Add(command);
        }
示例#2
0
    public override Dictionary <string, Command.Method> GetMethodsDict()
    {
        Command.Method MoveBlock = (methods, memory, name, paramStrings, subscript) => {
            object[] parameters = Command.EvaluateParameters(methods, paramStrings, memory);

            // Only allowed to move physically once per tick
            if (actionTaken)
            {
                return(memory, null);
            }

            float x = (float)parameters[0];
            float z = (float)parameters[1];

            transform.Translate(new Vector3(x, 0, z));
            actionTaken = true;

            return(memory, null);
        };

        Dictionary <string, Command.Method> methodsDict = new Dictionary <string, Command.Method>()
        {
            { "move", MoveBlock }
        };

        return(methodsDict);
    }
示例#3
0
 public void AddCommand(string name, Command.Method handler)
 {
     AddCommand(name, handler, null);
 }
示例#4
0
 public void AddCommand(string name, Command.Method handler, string description)
 {
     AddCommand(name, handler, null, description, null);
 }