Skip to content

Commit

Permalink
Sync non-exclusive prisoner interaction mode, change syncing exclusiv…
Browse files Browse the repository at this point in the history
…e mode (#450)

Changes:

- Added a sync worker for `Pawn_GuestTracker`, as it's needed for the sync methods
- Synced non-exclusive prisoner interaction modes
  - This affects hemogen farm and bloodfeed (as well as extra modes added by mods)
  - The synced method is `Pawn_GuestTracker:ToggleNonExclusiveInteraction`
  - As opposed to normal prisoner/slave interaction modes, it would not be possible to sync it as a field since the field is a list of allowed modes
- Changed syncing of exclusive prisoner interaction modes by using a sync methods rather than sync fields
  - The synced method is `Pawn_GuestTracker:SetExclusiveInteraction`
  - The changes didn't need to be handled as a sync field anymore, so I've changed it to a sync method
  • Loading branch information
SokyranTheDragon authored May 24, 2024
1 parent 55dae5f commit 2f7ab7e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Source/Client/Syncing/Dict/SyncDictRimWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ public static class SyncDictRimWorld
(ByteWriter data, Pawn_NeedsTracker joinerTracker) => WriteSync(data, joinerTracker?.pawn),
(ByteReader data) => ReadSync<Pawn>(data)?.needs
},
{
(ByteWriter data, Pawn_GuestTracker guestTracker) => WriteSync(data, guestTracker?.pawn),
(ByteReader data) => ReadSync<Pawn>(data)?.guest
},
#endregion

#region Policies
Expand Down
3 changes: 0 additions & 3 deletions Source/Client/Syncing/Game/SyncFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public static class SyncFields
public static ISyncField SyncHostilityResponse;
public static ISyncField SyncFollowDrafted;
public static ISyncField SyncFollowFieldwork;
public static ISyncField SyncInteractionMode;
public static ISyncField SyncSlaveInteractionMode;
public static ISyncField SyncIdeoForConversion;
public static ISyncField SyncBeCarried;
Expand Down Expand Up @@ -90,7 +89,6 @@ public static void Init()
SyncHostilityResponse = Sync.Field(typeof(Pawn), nameof(Pawn.playerSettings), nameof(Pawn_PlayerSettings.hostilityResponse));
SyncFollowDrafted = Sync.Field(typeof(Pawn), nameof(Pawn.playerSettings), nameof(Pawn_PlayerSettings.followDrafted));
SyncFollowFieldwork = Sync.Field(typeof(Pawn), nameof(Pawn.playerSettings), nameof(Pawn_PlayerSettings.followFieldwork));
SyncInteractionMode = Sync.Field(typeof(Pawn), nameof(Pawn.guest), nameof(Pawn_GuestTracker.interactionMode));
SyncSlaveInteractionMode = Sync.Field(typeof(Pawn), nameof(Pawn.guest), nameof(Pawn_GuestTracker.slaveInteractionMode));
SyncIdeoForConversion = Sync.Field(typeof(Pawn), nameof(Pawn.guest), nameof(Pawn_GuestTracker.ideoForConversion));
SyncBeCarried = Sync.Field(typeof(Pawn), nameof(Pawn.health), nameof(Pawn_HealthTracker.beCarriedByCaravanIfSick));
Expand Down Expand Up @@ -258,7 +256,6 @@ static void ITab_Pawn_Visitor_Patch(ITab __instance)
{
Pawn pawn = __instance.SelPawn;
SyncMedCare.Watch(pawn);
SyncInteractionMode.Watch(pawn);
SyncSlaveInteractionMode.Watch(pawn);
SyncIdeoForConversion.Watch(pawn);
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Client/Syncing/Game/SyncMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public static void Init()
SyncMethod.Register(typeof(Pawn_JobTracker), nameof(Pawn_JobTracker.TryTakeOrderedJob)).SetContext(SyncContext.QueueOrder_Down).ExposeParameter(0);
SyncMethod.Register(typeof(Pawn_JobTracker), nameof(Pawn_JobTracker.TryTakeOrderedJobPrioritizedWork)).SetContext(SyncContext.QueueOrder_Down).ExposeParameter(0);
SyncMethod.Register(typeof(Pawn_TrainingTracker), nameof(Pawn_TrainingTracker.SetWantedRecursive));
SyncMethod.Register(typeof(Pawn_GuestTracker), nameof(Pawn_GuestTracker.SetExclusiveInteraction)).CancelIfAnyArgNull();
SyncMethod.Register(typeof(Pawn_GuestTracker), nameof(Pawn_GuestTracker.ToggleNonExclusiveInteraction)).CancelIfAnyArgNull();
SyncMethod.Register(typeof(Zone), nameof(Zone.Delete));
SyncMethod.Register(typeof(BillStack), nameof(BillStack.AddBill)).ExposeParameter(0); // Only used for pasting
SyncMethod.Register(typeof(BillStack), nameof(BillStack.Delete)).CancelIfAnyArgNull();
Expand Down

0 comments on commit 2f7ab7e

Please sign in to comment.