Skip to content

Commit 5eeab30

Browse files
author
hawkfalcon
committed
Fix crash in experimental branch
1 parent 2a7a8d1 commit 5eeab30

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

UnifiedFactions/UnifiedFactions.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
using UnityEngine.UIElements;
1313
using Timberborn.CoreUI;
1414
using Timberborn.PrefabOptimization;
15+
using Timberborn.PlantingUI;
16+
using Timberborn.Planting;
17+
using Timberborn.EntitySystem;
18+
using Timberborn.Localization;
1519

1620
namespace UnifiedFactionsPlugin {
1721

@@ -153,6 +157,18 @@ static bool HideWarning(ref bool __result) {
153157
return false;
154158
}
155159

160+
/**
161+
* Fix a weird farm bug - Single->First (hopefully I can remove this in the future)
162+
*/
163+
[HarmonyPrefix]
164+
[HarmonyPatch(typeof(PlantingToolButtonFactory), "GetPlanterBuildingName")]
165+
static bool FarmFix(ref string __result, Plantable plantable, ObjectCollectionService ____objectCollectionService, ILoc ____loc) {
166+
string displayNameLocKey = ____objectCollectionService.GetAllMonoBehaviours<PlanterBuilding>().First((PlanterBuilding building) =>
167+
building.PlantablePrefabNames.Contains(plantable.PrefabName)).GetComponent<LabeledPrefab>().DisplayNameLocKey;
168+
__result = ____loc.T(displayNameLocKey);
169+
return false;
170+
}
171+
156172
/**
157173
* Remove the 'Unique to this faction' text
158174
*/

0 commit comments

Comments
 (0)