Skip to content

Commit

Permalink
Fixes for v46
Browse files Browse the repository at this point in the history
  • Loading branch information
mend-dev committed Dec 30, 2024
1 parent fc0697a commit 881e8ed
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ bld/

# Visual Studio 2015/2017 cache/options directory
.vs/
.vscode/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

Expand Down
2 changes: 2 additions & 0 deletions Game/RogueGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,7 @@ public void GameStarted(InGame game) {
rerolls = 3;
roundManager.GenerateRound(0, true);
roundManager.GenerateBossBag();

gamemode.OnMatchStart();
}
}
10 changes: 7 additions & 3 deletions Gamemode/RogueGamemode.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using BTD_Mod_Helper.Api;
using BTD_Mod_Helper.Api.Enums;
using BTD_Mod_Helper.Api.Enums;
using BTD_Mod_Helper.Api.Scenarios;
using BTD_Mod_Helper.Extensions;
using Il2CppAssets.Scripts.Models;
using Il2CppAssets.Scripts.Models.Difficulty;

Expand All @@ -25,4 +23,10 @@ public override void ModifyGameModel(GameModel gameModel) {
base.ModifyGameModel(gameModel);
this.gameModel = gameModel;
}

public virtual void OnMatchStart() { }

public virtual void OnRoundStart() { }

public virtual void OnRoundEnd() { }
}
2 changes: 0 additions & 2 deletions Interface/Menu/StartGameMenus/RogueGameMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using BTD_Mod_Helper.Api.Components;
using BTD_Mod_Helper.Api.Enums;
using BTD_Mod_Helper.Extensions;
using Il2CppAssets.Scripts.Data;
using Il2CppAssets.Scripts.Unity.Map;
using Il2CppAssets.Scripts.Unity.UI_New.ChallengeEditor;
using System;
using System.Collections.Generic;
Expand Down
8 changes: 3 additions & 5 deletions Interface/Menu/StartGameMenus/SelectGamemodeMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
using UnityEngine;
using System;
using Object = Il2CppSystem.Object;
using Il2CppAssets.Scripts.Data.Skins;
using Il2CppAssets.Scripts.Unity.UI_New.Popups;
using Il2CppAssets.Scripts.Data.Boss;

namespace BTD6Rogue;


public class SelectGamemodeMenu : ModGameMenu<ExtraSettingsScreen> {

public override bool OnMenuOpened(Object data) {

// Remove base ExtraSettingsScreen UI
CommonForegroundHeader.SetText("Select Gamemode");
RectTransform panelTransform = GameMenu.gameObject.GetComponentInChildrenByName<RectTransform>("Panel");
GameObject panel = panelTransform.gameObject;
Expand All @@ -29,6 +27,8 @@ public override bool OnMenuOpened(Object data) {

List<RogueGamemode> gamemodes = GetContent<RogueGamemode>();

// Make a large image button for each of the RogueGamemodes
// TODO: Turn this into a horizontal scroll panel
foreach (RogueGamemode gamemode in gamemodes) {
ModHelperButton borderPanel = gamemodesPanel.AddButton(new Info("", InfoPreset.Flex),
VanillaSprites.BrownInsertPanelDark, new Action(() => {
Expand All @@ -50,11 +50,9 @@ public override bool OnMenuOpened(Object data) {
ModHelperText gamemodeName = gamemodeImage.AddText(new Info("Name", InfoPreset.Flex) { FlexHeight = 1 },
gamemode.DisplayName, 128, Il2CppTMPro.TextAlignmentOptions.Top);


ModHelperText gamemodeDescription = gamemodeImage.AddText(new Info("Description", InfoPreset.Flex) { FlexHeight = 1 }, gamemode.Description, 72,
Il2CppTMPro.TextAlignmentOptions.Bottom);
}

return false;
}
}
4 changes: 2 additions & 2 deletions ModHelperData.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
namespace BTD6Rogue;

public static class ModHelperData {
public const string WorksOnVersion = "45";
public const string Version = "3.0.0";
public const string WorksOnVersion = "46";
public const string Version = "3.1.0";
public const string Name = "BTD6Rogue";
public const string Description =
"Turn BTD6 into a Roguelike!" +
Expand Down
10 changes: 0 additions & 10 deletions Patch/BossBloonManager/BossBloonManager_OnRoundStart.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,3 @@ private static bool Prefix(BossBloonManager __instance, int spawnedRound) {
return false;
}
}

[HarmonyPatch(typeof(BossBloonManager), nameof(BossBloonManager.SpawnBoss))]
internal static class BossBloonManager_SpawnBoss {

[HarmonyPostfix]
private static bool Prefix(BossBloonManager __instance) {
return false;
}
}

14 changes: 14 additions & 0 deletions Patch/BossBloonManager/BossBloonManager_SpawnBoss.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using HarmonyLib;
using Il2CppAssets.Scripts.Simulation.Track;

namespace BTD6Rogue;

[HarmonyPatch(typeof(BossBloonManager), nameof(BossBloonManager.SpawnBoss))]
internal static class BossBloonManager_SpawnBoss {

[HarmonyPostfix]
private static bool Prefix(BossBloonManager __instance) {
return false;
}
}

17 changes: 17 additions & 0 deletions Patch/InGame/InGame_Initialise.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using HarmonyLib;
using Il2CppAssets.Scripts.Unity.UI_New.InGame;
using Il2CppSystem;
using Il2CppSystem.Collections;

namespace BTD6Rogue;

[HarmonyPatch(typeof(InGame), nameof(InGame.Initialise))]
internal static class InGame_Initialise {

[HarmonyPostfix]
private static void Postfix(InGame __instance) {
IEnumerator enumer = __instance.InstantiateUiObject(__instance.inGameMenuDefs[15]);
enumer.MoveNext();
enumer.MoveNext();
}
}
19 changes: 1 addition & 18 deletions Patch/InGame/InGame_StartMatch.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using BTD_Mod_Helper.Api.Helpers;
using BTD_Mod_Helper.Extensions;
using BTD_Mod_Helper.Extensions;
using HarmonyLib;
using Il2CppAssets.Scripts.Models.Profile;
using Il2CppAssets.Scripts.Simulation.Track;
using Il2CppAssets.Scripts.Unity.UI_New;
using Il2CppAssets.Scripts.Unity.UI_New.InGame;
using Il2CppAssets.Scripts.Unity.UI_New.InGame.Races;
using Il2CppNinjaKiwi.Common;
using Il2CppSystem;
using Il2CppSystem.Collections;
using MelonLoader;
using UnityEngine;

namespace BTD6Rogue;
Expand Down Expand Up @@ -39,15 +34,3 @@ private static void Postfix(InGame __instance, MapSaveDataModel mapSaveData, boo
}
}
}


[HarmonyPatch(typeof(InGame), nameof(InGame.Initialise))]
internal static class InGame_StartMatcah {

[HarmonyPostfix]
private static void Postfix(InGame __instance) {
IEnumerator enumer = __instance.InstantiateUiObject(__instance.inGameMenuDefs[15]);
enumer.MoveNext();
enumer.MoveNext();
}
}
22 changes: 0 additions & 22 deletions Patch/InGame/InGame_Testing.cs

This file was deleted.

26 changes: 26 additions & 0 deletions Patch/MainMenu/MainMenu_Open.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
using BTD_Mod_Helper.Api;
using UnityEngine.UI;
using Il2CppNinjaKiwi.Common.ResourceUtils;
using Il2CppAssets.Scripts.Unity.UI_New;
using Il2CppAssets.Scripts.Data.Quests;
using Il2CppAssets.Scripts.Unity;
using Il2CppAssets.Scripts.Data.Quests.UI;
using System.Linq;
using System.Collections.Generic;
using Il2CppNinjaKiwi.Common;

namespace BTD6Rogue;

Expand All @@ -26,5 +33,24 @@ private static void Postfix(MainMenu __instance) {
rogueButton.GetComponentInChildrenByName<Image>("Button").SetSprite(sprite.ToString());
rogueButton.GetComponentInChildren<NK_TextMeshProUGUI>().localizeKey = $"Rogue";
rogueButton.GetComponentInChildren<Button>().SetOnClick(() => ModGameMenu.Open<RogueGameMenu>());

// Code for custom dialogue pop ups using the base QuestUI and related systems (will use in future)
/*
LocalizationManager lm = LocalizationManager.Instance;
lm.textTable["DialogueScoopsTaleIQuest1UI1"] = "Mend is super cool and awesome";
CommonForegroundScreen instance = CommonForegroundScreen.instance;
BTD6Rogue.LogMessage("COUNT: " + Game.instance.questTrackerManager.QuestData.quests.Count);
QuestDetails test = Game.instance.questTrackerManager.QuestData.quests[31];
DialogueTaskIntroduction taskIntro = null!;
TaskData td = test.GetTaskDataForImport(0, 0);
td.TryGetTaskDialogue(out taskIntro);
instance.TryRunAnimatedDialogueSequence(taskIntro);
List<string> localkeys = Il2CppNinjaKiwi.Common.LocalizationManager.Instance.GetTextTable().Keys().ToList();
for (int i = 0; i < localkeys.Count; i++) {
BTD6Rogue.LogMessage(localkeys[i]);
}*/
}
}
2 changes: 1 addition & 1 deletion Patch/MenuManager/MenuManager_CloseMenuInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace BTD6Rogue;

[HarmonyPatch(typeof(BTDMenuManager._CloseCurrentMenuInternal_d__57), nameof(BTDMenuManager._CloseCurrentMenuInternal_d__57.MoveNext))]
static class CloseCur {
static class MenuManager_CloseCurrentMenuInternal {
[HarmonyPrefix]
static void Prefix(BTDMenuManager._CloseCurrentMenuInternal_d__57 __instance, out string __state) {
__state = __instance._menuName_5__2;
Expand Down
2 changes: 1 addition & 1 deletion Patch/MenuManager/MenuManager_LoadSceneAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace BTD6Rogue;

[HarmonyPatch(typeof(BTDMenuManager._LoadSceneAsync_d__34), nameof(BTDMenuManager._LoadSceneAsync_d__34.MoveNext))]
static class LoadSceneAsync_MoveNext {
static class MenuManager_LoadSceneAsync {
[HarmonyPrefix]
static void Prefix(BTDMenuManager._LoadSceneAsync_d__34 __instance, out string __state) {
__state = __instance.sceneName;
Expand Down
2 changes: 1 addition & 1 deletion Patch/MenuManager/MenuManager_OpenMenuInternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace BTD6Rogue;
// TODO: Menus of the same type overwrite eachother in the stack making it so if you press the back button, in this case, it sends the user back to the main menu rather than the previous menu
// TODO: Delete Il2Cpp and obfuscation from existence
[HarmonyPatch(typeof(BTDMenuManager._OpenMenuInternal_d__52), nameof(BTDMenuManager._OpenMenuInternal_d__52.MoveNext))]
static class MenuManagerOpenMenuInternal54_MoveNext {
static class MenuManager_OpenMenuInternal {
[HarmonyPrefix]
static void Prefix(BTDMenuManager._OpenMenuInternal_d__52 __instance) {
bool isModdedMenu = false;
Expand Down
7 changes: 1 addition & 6 deletions Patch/MenuManager/MenuManager_UnloadSceneAsync.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using HarmonyLib;
using BTD_Mod_Helper.Api;
using Il2CppAssets.Scripts.Unity.Menu;
using UnityEngine.SceneManagement;
using BTDMenuManager = Il2CppAssets.Scripts.Unity.Menu.MenuManager;
using Object = Il2CppSystem.Object;
using System;
using BTD_Mod_Helper.Extensions;

namespace BTD6Rogue;

[HarmonyPatch(typeof(BTDMenuManager._UnloadSceneAsync_d__35), nameof(BTDMenuManager._UnloadSceneAsync_d__35.MoveNext))]
static class LoadSceneAsync_MoveNexttttttttttttttttttttttttttttttttttttttt {
static class MenuManager_UnloadSceneAsync {
[HarmonyPrefix]
static void Prefix(BTDMenuManager._UnloadSceneAsync_d__35 __instance) {
if (__instance.sceneName.Contains("ModdedMenu") && __instance.__1__state == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private static void Prefix(ReanimateMoabsAction __instance, ref BloonModel bloon
}

[HarmonyPostfix]
private static void Postfix(Spawner __instance, BloonModel bloonModel, ref Bloon __result) {
private static void Postfix(ReanimateMoabsAction __instance, BloonModel bloonModel, ref Bloon __result) {
if (bloonModel.baseId.ToLower().Contains("minilych")) {
BossUtil.GetBossFromBloonId(bloonModel.baseId).AdjustBloon(__result, InGame.instance.bridge.GetCurrentRound() / 20, false);
}
Expand Down
22 changes: 22 additions & 0 deletions Patch/SpawnChildren/SpawnChildren_CreatedChildren.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using HarmonyLib;
using Il2CppAssets.Scripts.Simulation.Bloons;
using Il2CppAssets.Scripts.Models.Towers.Projectiles.Behaviors;
using Il2CppAssets.Scripts.Simulation.Bloons.Behaviors;
using Il2CppSystem.Collections.Generic;

namespace BTD6Rogue;

[HarmonyPatch(typeof(SpawnChildren), nameof(SpawnChildren.CreatedChildren))]
internal static class SpawnChildren_CreatedChildren {
[HarmonyPostfix]
private static void Postfix(SpawnChildren __instance, List<Bloon> childernCreatedIn) {
if (__instance.bloon.emissionIndex >= 5000) {
foreach (Bloon bloon in childernCreatedIn) {
IncreaseBloonWorthModel.BloonWorthMutator bme = new IncreaseBloonWorthModel.BloonWorthMutator(
"CashlessBloon", 0, 0, "");
bloon.AddMutator(bme, -1, false);
}
}

}
}
18 changes: 0 additions & 18 deletions Patch/Spawner/Spawner_Emit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
using Il2CppAssets.Scripts.Models.Bloons;
using Il2CppAssets.Scripts.Simulation.Bloons;
using Il2CppAssets.Scripts.Models.Towers.Projectiles.Behaviors;
using Il2CppAssets.Scripts.Simulation.Bloons.Behaviors;
using Il2CppSystem.Collections.Generic;
using System;

namespace BTD6Rogue;
Expand Down Expand Up @@ -49,19 +47,3 @@ private static void Postfix(Spawner __instance, BloonModel bloonModel, int round

}
}

[HarmonyPatch(typeof(SpawnChildren), nameof(SpawnChildren.CreatedChildren))]
internal static class Spawner_Emasddsit {
[HarmonyPostfix]
private static void Postfix(SpawnChildren __instance, List<Bloon> childernCreatedIn) {
if (BTD6Rogue.rogueGame is null) { return; }
if (__instance.bloon.emissionIndex >= 5000) {
foreach (Bloon bloon in childernCreatedIn) {
IncreaseBloonWorthModel.BloonWorthMutator bme = new IncreaseBloonWorthModel.BloonWorthMutator(
"CashlessBloon", 0, 0, "");
bloon.AddMutator(bme, -1, false);
}
}

}
}

0 comments on commit 881e8ed

Please sign in to comment.