public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { CommandLoader.Instance.New <ShutdownCommand>().Run(moPlayer, usedName, inputLine, args); CommandLoader.Instance.New <StartCommand>().Run(moPlayer, usedName, inputLine, args); return(true); }
public override void Action(CommandCaller caller, string input, string[] args) { if (args.Length == 0) { // TODO Open console return; } List <string> parsedArgs = input.ParseLine(); parsedArgs.RemoveAt(0); string commandName = parsedArgs[0]; parsedArgs.RemoveAt(0); if (!CommandLoader.Instance.Exists(commandName)) { Main.NewText($"Command '{commandName}' not found. Use /help for a list of available commands."); return; } Command command = CommandLoader.Instance.New(commandName); MOPlayer moPlayer = caller.Player.GetModPlayer <MOPlayer>(); if (!command.CanUse(moPlayer)) { return; } command.Run(moPlayer, commandName, input, parsedArgs); }
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { if (args.Count == 0) { return(false); } Main.NewText($"{moPlayer.player.name} says {string.Join(" ", args)}"); return(true); }
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { if (args.Count == 0) { moPlayer.TryStart(); return(true); } return(true); }
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { if (!Enum.TryParse(args[0], true, out Keys key)) { Main.NewText($"Key {args[0]} not found.", 255, 0, 0); return(true); } moPlayer.Unbind(key); return(true); }
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { if (args.Count == 0 && Main.netMode != NetmodeID.MultiplayerClient) { Main.NewText("This function is disabled in SinglePlayer."); return(true); } moPlayer.Shutdown(0); return(true); }
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { List <Command> commands = CommandLoader.Instance.GetAvailableCommands(moPlayer).OrderBy(c => c.Name).ToList(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < commands.Count; i++) { sb.AppendLine(commands[i].Name); } Main.NewTextMultiline(sb.ToString()); return(true); }
public List <Command> GetAvailableCommands(MOPlayer moPlayer) { List <Command> commands = new List <Command>(); foreach (Type type in idByType.Keys) { Command command = New(type); if (command.CanUse(moPlayer)) { commands.Add(command); } } return(commands); }
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { if (args.Count == 1) { string arg = args[0].ToLower(); if (arg == "-l" || arg == "-list") { ListBinds(moPlayer.Binds); } return(true); } if (args.Count < 2) { return(false); } if (!Enum.TryParse(args[0], true, out Keys key)) { Main.NewText($"Key {args[0]} not found.", 255, 0, 0); return(true); } string[] splitLine = inputLine.Split(' '); string toBind = null; for (int i = 3; i < splitLine.Length; i++) { toBind += splitLine[i]; if (i + 1 < splitLine.Length) { toBind += " "; } } moPlayer.Bind(key, toBind); return(true); }
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { WorldGen.SaveAndQuit(); return(true); }
public virtual bool CanUse(MOPlayer moPlayer) { //if (moPlayer.HasModule()) return(true); }
public abstract bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args);
public override bool Run(MOPlayer moPlayer, string usedName, string inputLine, List <string> args) { moPlayer.UnbindAll(); return(true); }