private static IEnumerable <string> GetFactionNames() { var factions = BotHelper.GetAvailableBotFactions(); foreach (var faction in factions) { yield return(((int)faction).ToString() + ": " + SharpHelper.EnumToString(faction)); } }
private static void ListBotType() { ScriptHelper.PrintMessage("--BotExtended list bot type--", ScriptHelper.ERROR_COLOR); foreach (var botType in SharpHelper.EnumToList <BotType>()) { ScriptHelper.PrintMessage((int)botType + ": " + SharpHelper.EnumToString(botType), ScriptHelper.WARNING_COLOR); } }
public static void CreateNewBot(IEnumerable <string> arguments) { if (arguments.Count() < 1) { return; } var botTypeStr = arguments.First(); var botType = BotType.None; if (SharpHelper.TryParseEnum(botTypeStr, out botType)) { arguments = arguments.Skip(1); } else { ScriptHelper.PrintMessage("--BotExtended spawn bot--", ScriptHelper.ERROR_COLOR); ScriptHelper.PrintMessage("Invalid query: " + botTypeStr, ScriptHelper.WARNING_COLOR); return; } var team = PlayerTeam.Independent; if (arguments.Any()) { if (TryParseTeam(arguments.First(), out team)) { arguments = arguments.Skip(1); } } var count = 1; if (arguments.Any()) { if (int.TryParse(arguments.First(), out count)) { count = (int)MathHelper.Clamp(count, Constants.BOT_SPAWN_COUNT_MIN, Constants.BOT_SPAWN_COUNT_MAX); } else { count = 1; } } for (var i = 0; i < count; i++) { BotManager.SpawnBot(botType, player: null, team: team, ignoreFullSpawner: true); } // Dont use the string name in case it just an index var bot = count > 1 ? " bots" : " bot"; ScriptHelper.PrintMessage("Spawned " + count + " " + SharpHelper.EnumToString(botType) + bot + " to " + team); }
private static void SetFactions(IEnumerable <string> arguments) { var allBotFactions = SharpHelper.EnumToList <BotFaction>() .Select((f) => SharpHelper.EnumToString(f)) .ToList(); var botFactions = new List <string>(); var excludeFlag = false; BotFaction botFaction; if (arguments.Count() == 0) { ScriptHelper.PrintMessage("--BotExtended setfaction--", ScriptHelper.ERROR_COLOR); ScriptHelper.PrintMessage("Invalid command: Argument is empty", ScriptHelper.WARNING_COLOR); return; } var team = PlayerTeam.Team4; if (TryParseTeam(arguments.First(), out team, PlayerTeam.Team4)) { arguments = arguments.Skip(1); } if (arguments.Count() == 1 && (arguments.Single() == "all" || arguments.Single() == "none")) { if (arguments.Single() == "all") { botFactions = new List <string> { "All" } } ; if (arguments.Single() == "none") { botFactions = new List <string> { "None" } } ; } else { if (arguments.First() == "-e") { excludeFlag = true; arguments = arguments.Skip(1); } foreach (var arg in arguments) { if (arg == "none") { ScriptHelper.PrintMessage("--BotExtended setfaction--", ScriptHelper.ERROR_COLOR); ScriptHelper.PrintMessage("Invalid argument: Cannot mix None with other options", ScriptHelper.WARNING_COLOR); return; } if (SharpHelper.TryParseEnum(arg, out botFaction)) { botFactions.Add(SharpHelper.EnumToString(botFaction)); } else { ScriptHelper.PrintMessage("--BotExtended setfaction--", ScriptHelper.ERROR_COLOR); ScriptHelper.PrintMessage("Invalid argument: " + arg, ScriptHelper.WARNING_COLOR); return; } } } if (excludeFlag) { botFactions = allBotFactions.Where((f) => !botFactions.Contains(f)).ToList(); } BotHelper.Storage.SetItem(BotHelper.StorageKey("BOT_FACTIONS_" + team), botFactions.Distinct().ToArray()); ScriptHelper.PrintMessage("[Botextended] Update successfully"); }
public static string StorageKey(BotFaction botFaction, int factionIndex) { return(Constants.STORAGE_KEY_PREFIX + SharpHelper.EnumToString(botFaction).ToUpperInvariant() + "_" + factionIndex); }