From 5eeab30d99de63bb847e5a276d3c44ff50e0de5d Mon Sep 17 00:00:00 2001 From: hawkfalcon Date: Sun, 5 Dec 2021 23:23:55 -0500 Subject: [PATCH] Fix crash in experimental branch --- UnifiedFactions/UnifiedFactions.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/UnifiedFactions/UnifiedFactions.cs b/UnifiedFactions/UnifiedFactions.cs index 5c3b7ac..bfc29aa 100644 --- a/UnifiedFactions/UnifiedFactions.cs +++ b/UnifiedFactions/UnifiedFactions.cs @@ -12,6 +12,10 @@ using UnityEngine.UIElements; using Timberborn.CoreUI; using Timberborn.PrefabOptimization; +using Timberborn.PlantingUI; +using Timberborn.Planting; +using Timberborn.EntitySystem; +using Timberborn.Localization; namespace UnifiedFactionsPlugin { @@ -153,6 +157,18 @@ static bool HideWarning(ref bool __result) { return false; } + /** + * Fix a weird farm bug - Single->First (hopefully I can remove this in the future) + */ + [HarmonyPrefix] + [HarmonyPatch(typeof(PlantingToolButtonFactory), "GetPlanterBuildingName")] + static bool FarmFix(ref string __result, Plantable plantable, ObjectCollectionService ____objectCollectionService, ILoc ____loc) { + string displayNameLocKey = ____objectCollectionService.GetAllMonoBehaviours().First((PlanterBuilding building) => + building.PlantablePrefabNames.Contains(plantable.PrefabName)).GetComponent().DisplayNameLocKey; + __result = ____loc.T(displayNameLocKey); + return false; + } + /** * Remove the 'Unique to this faction' text */