Skip to content

Commit 80f59a8

Browse files
committed
Fix feedback for drafted pawn move order
1 parent c950171 commit 80f59a8

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

Source/Client/Patches/Feedback.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
using System.Linq;
66
using System.Reflection;
77
using System.Reflection.Emit;
8+
using Multiplayer.API;
89
using RimWorld.Planet;
910
using UnityEngine;
1011
using Verse;
12+
using Verse.AI;
1113
using Verse.Sound;
1214

1315
namespace Multiplayer.Client.Patches
@@ -228,4 +230,30 @@ static void Finalizer(bool __state)
228230
}
229231
}
230232

233+
[HarmonyPatch(typeof(FloatMenuOptionProvider_DraftedMove),
234+
nameof(FloatMenuOptionProvider_DraftedMove.PawnGotoAction))]
235+
static class DraftedMove_GotoFeedbackPatch
236+
{
237+
private static MethodInfo tryTakeOrderedJob =
238+
AccessTools.Method(typeof(Pawn_JobTracker), nameof(Pawn_JobTracker.TryTakeOrderedJob));
239+
240+
static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
241+
{
242+
foreach (var inst in instructions)
243+
{
244+
if (inst.Calls(tryTakeOrderedJob)) inst.operand = ((Delegate)CustomTryTakeOrderedJob).Method;
245+
yield return inst;
246+
}
247+
}
248+
249+
[SyncMethod(exposeParameters = [1])]
250+
static bool CustomTryTakeOrderedJob(Pawn_JobTracker self, Job job, JobTag? tag = JobTag.Misc,
251+
bool requestQueueing = false)
252+
{
253+
if (self.TryTakeOrderedJob(job, tag, requestQueueing) && TickPatch.currentExecutingCmdIssuedBySelf)
254+
FleckMaker.Static(job.targetA.Cell, self.pawn.Map, FleckDefOf.FeedbackGoto);
255+
return false;
256+
}
257+
}
258+
231259
}

Source/Client/Syncing/Game/SyncDelegates.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public static void Init()
3636
// SyncDelegate.Lambda(typeof(FloatMenuOptionProvider_CarryToShuttle), "GetSingleOptionFor", 0).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Carry to shuttle
3737
// SyncDelegate.Lambda(typeof(FloatMenuOptionProvider_Childcare), "GetOptionsFor", 0).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Breastfeed/give milk
3838
// SyncDelegate.Lambda(typeof(FloatMenuOptionProvider_DraftedAttack), "GetSingleOptionFor", 0).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted attack
39-
// SyncDelegate.Lambda(typeof(FloatMenuOptionProvider_DraftedMove), "GetSingleOptionFor", 0).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted move (Goto)
4039
// SyncDelegate.Lambda(typeof(FloatMenuOptionProvider_DraftedRepair), "GetSingleOptionFor", 0).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted repair
4140
// SyncDelegate.Lambda(typeof(FloatMenuOptionProvider_DraftedTend), "GetOptionsFor", 0).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted tend
4241
// SyncDelegate.Lambda(typeof(FloatMenuOptionProvider_DressOtherPawn), "GetSingleOptionFor", 0).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Dress other pawn

0 commit comments

Comments
 (0)