Esempio n. 1
0
        /// <summary>
        /// Processes the incoming command.
        /// </summary>
        /// <param name="raw"></param>
        /// <returns></returns>
        public static bool ProcessCommand(string raw)
        {
            // Validate the incoming command..
            if (string.IsNullOrEmpty(raw) || !raw.StartsWith("/"))
            {
                return(false);
            }

            // Parse the command for arguments..
            var args = ConsoleCommands.ParseCommand(raw);

            if (args == null || args.Count == 0)
            {
                return(false);
            }

            try
            {
                // Attemt to locate and invoke the owning command..
                var cmd = ConsoleCommands.Commands.SingleOrDefault(c => c.HasAlias(args[0]));
                return(cmd != null && cmd.Invoke(raw, args));
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 2
0
 public override bool Initialize()
 {
     godmode = false;
     Events.XnaEvents.PostLoadContent.Register(this, OnPostLoadContent, 1);
     Events.XnaEvents.PostUpdate.Register(this, OnPostUpdate, 1);
     Events.TerrariaMainEvents.PreDrawInterface.Register(this, OnPreDrawInterface, 1);
     CC.AddCommnd(new List <string>()
     {
         "tgm", "godmode"
     }, "Toggles godmode for the player.", OnGodmodeCommand);
     CC.AddCommnd(new List <string> {
         "grid"
     }, "Toggles building grid.", OnGridCommand);
     CC.AddCommnd(new List <string> {
         "give"
     }, "Gives the player an item.", OnGiveCommand);
     CC.AddCommnd(new List <string> {
         "time"
     }, "Sets the current time.", OnTimeCommand);
     return(true);
 }
Esempio n. 3
0
 /// <summary>
 /// Default Constructor
 /// </summary>
 /// <param name="alias"></param>
 /// <param name="cmdCallback"></param>
 public ConsoleCommand(List<string> alias, ConsoleCommands.ConsoleCommandDelegate cmdCallback)
 {
     this._alias = alias;
     this._cmdCallback = cmdCallback;
 }