public void Awake() { Debug.Log("MVP: Proceeding to check for mod compatibility..."); //Check if Mods are loaded. hasClayMan = AssetLoaderAndChecker.CheckForMod("com.Moffein.ClayMen"); hasAncientWisp = AssetLoaderAndChecker.CheckForMod("com.Moffein.AncientWisp"); hasArchWisp = AssetLoaderAndChecker.CheckForMod("com.Nebby1999.ArchaicWisps"); hasMysticItems = AssetLoaderAndChecker.CheckForMod("com.themysticsword.mysticsitems"); Debug.Log("MVP: Mod Compat Checker finished."); //Register Hooks Debug.Log("MVP: Proceeding to create custom hooks..."); RegisterHooks(); Debug.Log("MVP: Hook creation finished."); //Load Monster Variant Assets Debug.Log("MVP: Proceeding to load Assets..."); AssetLoaderAndChecker.LoadAssets(); //Initializes Config Debug.Log("MVP: Proceeding to initialize the Config File."); ConfigLoader.SetupConfigLoader(Config); //Initializes variant spawn chances ConfigLoader.ReadConfig(Config); Debug.Log("MVP: Config creation finished."); //Make sure config values aren't invalid. if (ConfigLoader.EnableConfigcheck) { Debug.Log("MVP: " + ConfigLoader.EnableConfigCheckConfig.Definition.Key + "Is set to True, proceeding to check for bad values in the config..."); AssetLoaderAndChecker.PreventBadValues(Config); } else { Debug.Log("MVP: " + ConfigLoader.EnableConfigCheckConfig.Definition.Key + "Is set to False, skipping to skill registration..."); } //Registers skills Debug.Log("MVP: Proceeding to register Monster Variants Skills..."); SubClasses.Skills.CustomSkills.RegisterSkills(); Debug.Log("MVP: Monster Variants Skills registered..."); //Register Artifact of Variance if (ConfigLoader.EnableArtifactOfVariance) { Debug.Log("MVP: Proceeding to Register the Artifact of Variance"); Artifact.InitializeArtifact(); Debug.Log("MVP: Artifact Registered..."); } Debug.Log("MVP: Proceeding to register prefabs"); //Registers Prefabs... hopefully? var Prefabs = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(PrefabBase))); foreach (var prefabType in Prefabs) { PrefabBase prefab = (PrefabBase)System.Activator.CreateInstance(prefabType); prefab.Init(); } //Initializes custom items for monster variants, thanks Komrade for the boilerplate! <3 var ItemTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(MVPItemBase))); foreach (var itemType in ItemTypes) { MVPItemBase item = (MVPItemBase)System.Activator.CreateInstance(itemType); if (ValidateItem(item, Items)) { item.Init(); } } //main hook On.RoR2.DeathRewards.OnKilledServer += (orig, self, DamageReport) => { foreach (VariantHandler enemy in DamageReport.victimBody.GetComponents <VariantHandler>()) { if (enemy.isVariant && (DamageReport.victimTeamIndex == (TeamIndex)2)) { if (ConfigLoader.CertainVariantsSpawnMoreEnemies) { TrySpawnEnemy(DamageReport.victimBody); } if (ConfigLoader.EnableItemRewards) { if (Run.instance.isRunStopwatchPaused && ConfigLoader.HiddenRealmItemdropBehavior != "Unchanged") { if (ConfigLoader.HiddenRealmItemdropBehavior == "Halved") { int rng = UnityEngine.Random.Range(1, 20); if (rng > 10) { ExtraRewards.TryExtraReward(enemy, DamageReport.victimBody, DamageReport.attackerBody); } } else //(Hidden Realm item drop behavior is "Never") { } } else { ExtraRewards.TryExtraReward(enemy, DamageReport.victimBody, DamageReport.attackerBody); } } if (ConfigLoader.EnableGoldRewards) { uint multipliedGold = MultiplyGold.MultiplyMoney(self.goldReward, enemy); self.goldReward = multipliedGold; } if (ConfigLoader.EnableXPRewards) { uint multipliedXP = MultiplyXP.MultiplyExperience(self.expReward, enemy); self.expReward = multipliedXP; } } } orig(self, DamageReport); }; }
public bool ValidateItem(MVPItemBase item, List <MVPItemBase> itemList) { itemList.Add(item); return(true); }