From 38c09eecfbd959f61a220b9a22ef1fdece72586f Mon Sep 17 00:00:00 2001 From: Sn1p3rr3c0n Date: Sun, 18 Sep 2022 13:55:25 +0200 Subject: [PATCH] #606 added drafted repair option --- .../Common/HarmonyPatches/PatchStorage.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Source/ProjectRimFactory/Common/HarmonyPatches/PatchStorage.cs b/Source/ProjectRimFactory/Common/HarmonyPatches/PatchStorage.cs index cb4d7071..4f2cce03 100644 --- a/Source/ProjectRimFactory/Common/HarmonyPatches/PatchStorage.cs +++ b/Source/ProjectRimFactory/Common/HarmonyPatches/PatchStorage.cs @@ -9,6 +9,7 @@ using UnityEngine; using HarmonyLib; using ProjectRimFactory.Storage; +using Verse.AI; namespace ProjectRimFactory.Common.HarmonyPatches { @@ -55,6 +56,26 @@ static bool Prefix(Vector3 clickPos, Pawn pawn, out List __resu if (pawn.Map.GetComponent().iHideRightMenus.Contains(clickPos.ToIntVec3())) { __result = new List(); + if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation) && !pawn.skills.GetSkill(SkillDefOf.Construction).TotallyDisabled) + { + foreach (LocalTargetInfo item13 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRepair(pawn), thingsOnly: true)) + { + Thing repairTarget = item13.Thing; + if (!pawn.CanReach(repairTarget, PathEndMode.Touch, Danger.Deadly)) + { + __result.Add(new FloatMenuOption("CannotRepair".Translate(repairTarget) + ": " + "NoPath".Translate().CapitalizeFirst(), null)); + } + else if (RepairUtility.PawnCanRepairNow(pawn, repairTarget)) + { + FloatMenuOption item5 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("RepairThing".Translate(repairTarget), delegate + { + Job job = JobMaker.MakeJob(JobDefOf.Repair, repairTarget); + pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); + }), pawn, repairTarget); + __result.Add(item5); + } + } + } return false; } __result = null;