Skip to content

Commit

Permalink
Fix crash in experimental branch
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkfalcon committed Dec 6, 2021
1 parent 2a7a8d1 commit 5eeab30
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions UnifiedFactions/UnifiedFactions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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<PlanterBuilding>().First((PlanterBuilding building) =>
building.PlantablePrefabNames.Contains(plantable.PrefabName)).GetComponent<LabeledPrefab>().DisplayNameLocKey;
__result = ____loc.T(displayNameLocKey);
return false;
}

/**
* Remove the 'Unique to this faction' text
*/
Expand Down

0 comments on commit 5eeab30

Please sign in to comment.