From 2ba78838f77da2668bc1b1ecf84cf864dab48b29 Mon Sep 17 00:00:00 2001 From: TuanAnh2901 Date: Sun, 5 Oct 2025 00:59:53 +0700 Subject: [PATCH] BepInEx --- BepInEx/Core.cs | 4 --- .../GameObjects/SpriteRenderer_patch.cs | 25 ++++++++++++++ .../PvZ Fusion Translator [BepInEx].csproj | 1 + MelonLoader/Utils.cs | 34 ++++++++++++++++++- 4 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs diff --git a/BepInEx/Core.cs b/BepInEx/Core.cs index 1d17f41..e69ff89 100644 --- a/BepInEx/Core.cs +++ b/BepInEx/Core.cs @@ -94,10 +94,6 @@ public class Core : BasePlugin Log.LogInfo("del del"); Utils.OpenTrello(); } - if (Input.GetKeyDown(KeyCode.P)) - { - Time.timeScale = 0; - } if (TowerManager.Instance != null) { TowerManager_Patch.UpdateText(); diff --git a/BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs b/BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs new file mode 100644 index 0000000..07279bd --- /dev/null +++ b/BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using TMPro; +using BepInEx.Unity.IL2CPP; +using PvZ_Fusion_Translator__BepInEx_.AssetStore; +using UnityEngine; + +namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects +{ + [HarmonyPatch(typeof(SpriteRenderer))] + public static class SpriteRenderer_Patch + { + [HarmonyPatch(nameof(SpriteRenderer.InvokeSpriteChanged))] + [HarmonyPostfix] + private static void InvokeSpriteChanged(SpriteRenderer __instance) + { + if (__instance.sprite != null) + { + if (TextureStore.spriteDict.ContainsKey(__instance.sprite.name) && __instance.drawMode != SpriteDrawMode.Sliced) + { + __instance.drawMode = SpriteDrawMode.Sliced; + } + } + } + } +} \ No newline at end of file diff --git a/BepInEx/PvZ Fusion Translator [BepInEx].csproj b/BepInEx/PvZ Fusion Translator [BepInEx].csproj index 956be10..512b4c7 100644 --- a/BepInEx/PvZ Fusion Translator [BepInEx].csproj +++ b/BepInEx/PvZ Fusion Translator [BepInEx].csproj @@ -179,6 +179,7 @@ + diff --git a/MelonLoader/Utils.cs b/MelonLoader/Utils.cs index 356c40b..3647392 100644 --- a/MelonLoader/Utils.cs +++ b/MelonLoader/Utils.cs @@ -235,7 +235,39 @@ namespace PvZ_Fusion_Translator return theZombieName; } - public static Dictionary> plantIndices = new Dictionary>(); + public static string GetZombieNameFromAlmanac(ZombieType theZombieType) + { + string json; + string theZombieName = ""; + + string currentLanguage = Utils.Language.ToString(); + string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language); + string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json"); + + if (!File.Exists(path)) + { + Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}"); + Log.LogError("Zombie name could not be found!"); + theZombieName = ""; + } + else + { + json = File.ReadAllText(path); + AlmanacMgrZombie.ZombieAlmanacData zombieData = JsonUtility.FromJson(json); + + foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in zombieData.zombies) + { + if ((int)zombieInfo.theZombieType == (int)theZombieType) + { + theZombieName = zombieInfo.name; + } + } + } + + return theZombieName; + } + + public static Dictionary> plantIndices = new Dictionary>(); Dictionary>(); public static void RegisterPlantIndices() {