Skip to content

Commit

Permalink
#606 added drafted repair option
Browse files Browse the repository at this point in the history
  • Loading branch information
Sn1p3rr3c0n committed Sep 18, 2022
1 parent 1c7a030 commit 38c09ee
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Source/ProjectRimFactory/Common/HarmonyPatches/PatchStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using UnityEngine;
using HarmonyLib;
using ProjectRimFactory.Storage;
using Verse.AI;

namespace ProjectRimFactory.Common.HarmonyPatches
{
Expand Down Expand Up @@ -55,6 +56,26 @@ static bool Prefix(Vector3 clickPos, Pawn pawn, out List<FloatMenuOption> __resu
if (pawn.Map.GetComponent<PRFMapComponent>().iHideRightMenus.Contains(clickPos.ToIntVec3()))
{
__result = new List<FloatMenuOption>();
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;
Expand Down

0 comments on commit 38c09ee

Please sign in to comment.