public static void TestGenerationDatabase() { GameEngine.SayToServer(" - Testing item prefab generation database..."); foreach (ItemType it in Enum.GetValues(typeof(ItemType))) { GameEngine.SayToServer($"{it}..."); if (it != ItemType.Unarmed && it != ItemType.Unarmored) { NewItem(it); } } GameEngine.SayToServer("done.\n"); GameEngine.SayToServer(" - Testing unit prefab generation database..."); foreach (UnitType ut in Enum.GetValues(typeof(UnitType))) { GameEngine.SayToServer($"{ut}..."); if (ut != UnitType.PlayerCharacter) { foreach (Gender g in Enum.GetValues(typeof(Gender))) { if (g != Gender.Unset && g != Gender.Genderless) { SpawnUnit(ut, null, g); } } } } GameEngine.SayToServer("done.\n"); }
public static void RunStartupPlugins() { if (AllPlugins.Count > 0) { if (Mappers.Count > 0) { GameEngine.SayToServer(" - Map-building plugins:\n"); foreach (IMappable mapper in Mappers) { mapper.ExpandMap(); } } if (Spawners.Count > 0) { GameEngine.SayToServer(" - Spawner plugins:\n"); foreach (ISpawnable spawner in Spawners) { spawner.SpawnAtStart(); } } } else { GameEngine.SayToServer(" - No plugins detected.\n"); } }
public void TryAssignAction(string input, GameClient assigningClient) { lock (actionLocker) // CALLED BY (2 - CLIENT LISTENER) { if (input == null || input.Length == 0) { ChosenAction = DefaultAction; actionArg2 = ""; } else { string cmd = "", arg2 = ""; input = TextUtils.SanitizeInput(input); cmd = TextUtils.GetArg1(input).ToLower(); arg2 = TextUtils.GetArg2(input); ChosenAction = actions.Find(ao => ao.Matches(cmd)); if (ChosenAction == null) { ChosenAction = DefaultAction; actionArg2 = ""; } else if (arg2 != null) { actionArg2 = arg2; } } if (ChosenAction != null) { string arg2out = (actionArg2.Length > 0) ? $" '{actionArg2}'" : ""; GameEngine.SayToServer($"{Name} assigned action: {ChosenAction.Name}{arg2out}\n"); } } }
public static void LoadPlugins() { GameEngine.SayToServer(" - Scanning for plugins..."); foreach (string dll in Directory.GetFiles(".", "*.dll")) { // Prevent snagging on self when running as deployed executable if (dll.Contains(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name)) { continue; } Assembly asm = Assembly.LoadFrom(dll); foreach (Type type in asm.GetTypes()) { if (type.GetInterface("IPluggable") == typeof(IPluggable)) { IPluggable thisPlugin = Activator.CreateInstance(type) as IPluggable; GameEngine.SayToServer($"{thisPlugin.Name}..."); AllPlugins.Add(thisPlugin); if (type.GetInterface("IMappable") == typeof(IMappable)) { IMappable mapPlugin = Activator.CreateInstance(type) as IMappable; Mappers.Add(mapPlugin); } if (type.GetInterface("ISpawnable") == typeof(ISpawnable)) { ISpawnable spawnPlugin = Activator.CreateInstance(type) as ISpawnable; Spawners.Add(spawnPlugin); } if (type.GetInterface("IPlayerModifiable") == typeof(IPlayerModifiable)) { IPlayerModifiable playerPlugin = Activator.CreateInstance(type) as IPlayerModifiable; PlayerMods.Add(playerPlugin); } if (type.GetInterface("ICanOverrideAttackMethod") == typeof(ICanOverrideAttackMethod)) { ICanOverrideAttackMethod combatPlugin = Activator.CreateInstance(type) as ICanOverrideAttackMethod; AttackMod = combatPlugin; } if (type.GetInterface("ISpeakable") == typeof(ISpeakable)) { ISpeakable speechMod = Activator.CreateInstance(type) as ISpeakable; SpeechMods.Add(speechMod); } if (type.GetInterface("IFabricable") == typeof(IFabricable)) { IFabricable templateMod = Activator.CreateInstance(type) as IFabricable; TemplateMods.Add(templateMod); } } } } GameEngine.SayToServer("done.\n"); }