diff --git a/MelonLoader/Core.cs b/MelonLoader/Core.cs index 587d633..54cddc8 100644 --- a/MelonLoader/Core.cs +++ b/MelonLoader/Core.cs @@ -81,11 +81,6 @@ namespace PvZ_Fusion_Translator { TowerManager_Patch.UpdateText(); } - - if (Input.GetKeyDown(KeyCode.P)) - { - Time.timeScale = 0; - } } public override void OnGUI() diff --git a/MelonLoader/Patches/GameObjects/SpriteRenderer_Patch.cs b/MelonLoader/Patches/GameObjects/SpriteRenderer_Patch.cs new file mode 100644 index 0000000..744fa5b --- /dev/null +++ b/MelonLoader/Patches/GameObjects/SpriteRenderer_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; + +namespace PvZ_Fusion_Translator.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/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index 7e4a19a..219dd61 100644 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj @@ -400,6 +400,8 @@ + + diff --git a/MelonLoader/Utils.cs b/MelonLoader/Utils.cs index b45f497..356c40b 100644 --- a/MelonLoader/Utils.cs +++ b/MelonLoader/Utils.cs @@ -28,7 +28,7 @@ namespace PvZ_Fusion_Translator { ImageConversion.LoadImage(ogTexture, File.ReadAllBytes(texturePath)); - Log.LogDebug("OK! Replaced Texture " + ogTexture.name); + Log.LogDebug("OK! Replaced Texture " + ogTexture.name); ogTexture.name = "replaced_" + ogTexture.name; return true; @@ -203,7 +203,39 @@ namespace PvZ_Fusion_Translator return thePlantName; } - 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>(); public static void RegisterPlantIndices() {