Esempio n. 1
0
 internal static void Postfix(string name, ref Sprite __result)
 {
     if (ModContent.GetContent <ModTowerSet>().FirstOrDefault(set => set.Id == name) is ModTowerSet modTowerSet)
     {
         __result = ModContent.GetSprite(modTowerSet.mod, modTowerSet.Container);
     }
 }
            internal static void Prefix(MonkeySelectMenu __instance, Il2CppSystem.Object data)
            {
                if (!reOpening)
                {
                    var towerSets = new List <string>(__instance.TowerSets);
                    foreach (var modTowerSet in ModContent.GetContent <ModTowerSet>())
                    {
                        var towerSetIndex = modTowerSet.GetTowerSetIndex(towerSets);
                        towerSets.Insert(towerSetIndex, modTowerSet.Id);
                    }
                    __instance.TowerSets = towerSets.ToArray();
                }

                if (data == null)
                {
                    menu = null;

                    var model = Game.instance.model;
                    foreach (var set in __instance.TowerSets)
                    {
                        Offsets[set]      = 0;
                        TowersInSets[set] = model.towerSet.Where(details =>
                                                                 model.GetTowerFromId(details.towerId).towerSet == set).ToList();
                        TotalSpotses[set] = ((TowersInSets[set].Count - 1) / 8 + 1) * 8;
                    }
                }

                if (!reOpening)
                {
                    CreatePips(__instance);
                    CreateCustomButtons(__instance);
                }
            }
        internal static void Postfix(GameModel result, List <ModModel> mods)
        {
            MelonMain.PerformHook(mod => mod.OnNewGameModel(result, mods));
            MelonMain.PerformHook(mod => mod.OnNewGameModel(result));

            foreach (var modVanillaContent in ModContent.GetContent <ModVanillaContent>()
                     .Where(content => !content.AffectBaseGameModel))
            {
                foreach (var affectedTower in modVanillaContent.GetAffectedTowers(result))
                {
                    modVanillaContent.Apply(affectedTower);
                }
            }
        }
        internal static void Postfix()
        {
            foreach (var mod in MelonHandler.Mods.OfType <BloonsMod>().OrderByDescending(mod => mod.Priority))
            {
                try
                {
                    ResourceHandler.LoadEmbeddedTextures(mod);
                    ResourceHandler.LoadEmbeddedBundles(mod);
                    ModContent.LoadModContent(mod);
                }
                catch (Exception e)
                {
                    MelonLogger.Error("Critical failure when loading resources for mod " + mod.Info.Name);
                    MelonLogger.Error(e);
                }
            }

            MelonMain.PerformHook(mod => mod.OnTitleScreen());

            foreach (var modParagonTower in ModContent.GetContent <ModVanillaParagon>())
            {
                modParagonTower.AddUpgradesToRealTowers();
            }


            foreach (var modelMod in Game.instance.model.mods)
            {
                if (modelMod.name.EndsWith("Only"))
                {
                    var mutatorModModels = modelMod.mutatorMods.ToList();
                    mutatorModModels.AddRange(ModContent.GetContent <ModTowerSet>()
                                              .Where(set => !set.AllowInRestrictedModes)
                                              .Select(set => new LockTowerSetModModel(modelMod.name, set.Id)));
                    modelMod.mutatorMods = mutatorModModels.ToIl2CppReferenceArray();
                }
            }
        }
        internal static void Postfix(ProfileModel __instance)
        {
            foreach (var modTower in ModContent.GetContent <ModTower>()
                     .Where(modTower => !(modTower is ModHero) && !__instance.unlockedTowers.Contains(modTower.Id)))
            {
                __instance.unlockedTowers.Add(modTower.Id);
                __instance.acquiredUpgrades.Add(modTower.Id);
            }

            foreach (var modUpgrade in ModContent.GetContent <ModUpgrade>()
                     .Where(modUpgrade => !__instance.acquiredUpgrades.Contains(modUpgrade.Id)))
            {
                __instance.acquiredUpgrades.Add(modUpgrade.Id);
            }

            foreach (var modHero in ModContent.GetContent <ModHero>())
            {
                __instance.unlockedHeroes.Add(modHero.Id);
                __instance.seenUnlockedHeroes.Add(modHero.Id);
                __instance.seenNewHeroNotification.Add(modHero.Id);
            }

            MelonMain.PerformHook(mod => mod.OnProfileLoaded(__instance));
        }