public static void AssemblySetup() { var PodTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(PodBase))); int podAmount = 0; foreach (var podType in PodTypes) { PodBase podBase = (PodBase)Activator.CreateInstance(podType); if (ValidatePod(instance.Config, podBase)) { podBase.Init(instance.Config); _logger.LogMessage("Added pod for " + podBase.BodyName); podAmount++; } } _logger.LogMessage($"Amount of pod types added: " + podAmount); var survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(BodyCatalog.FindBodyPrefab("EnforcerBody")); if (survivorDef) { _logger.LogMessage("Enforcer is loaded, setting him up."); //Enfucker.Init(survivorDef); return; } }
/// <summary> /// A helper to easily set up and initialize an pod from your pod classes if the user has it enabled in their configuration files. /// </summary> /// <param name="configFile">The configuration file from the main plugin."</param> /// <param name="podBase">A new instance of an PodBase class."</param> public static bool ValidatePod(BepInEx.Configuration.ConfigFile configFile, PodBase podBase) { var survivorDef = SurvivorCatalog.FindSurvivorDefFromBody(BodyCatalog.FindBodyPrefab(podBase.BodyName)); if (survivorDef != null) { var enabled = configFile.Bind <bool>(podBase.ConfigCategory, "Enable Pod Modification?", true, "[Server] Should this body's pod get modified?").Value; if (enabled) { return(true); } } return(false); }