Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More Anomaly syncing #448

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Source/Client/Syncing/Dict/SyncDictDlc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,23 @@ public static class SyncDictDlc
}
},
#endregion

#region Anomaly

{
(ByteWriter data, ActivityGizmo gizmo) => WriteSync(data, gizmo.Comp),
(ByteReader data) =>
{
var comp = ReadSync<CompActivity>(data);

// The gizmo may not yet be initialized for the comp.
comp.gizmo ??= new ActivityGizmo(comp.parent);

return (ActivityGizmo)comp.gizmo;
}
}

#endregion
};
}
}
6 changes: 4 additions & 2 deletions Source/Client/Syncing/Game/SyncDelegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public static void Init()
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddHumanlikeOrders), 7).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Capture slave
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddHumanlikeOrders), 8).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Capture prisoner
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddHumanlikeOrders), 9).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Carry to cryptosleep casket
SyncDelegate.LocalFunc(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddHumanlikeOrders), "CarryToShuttleAct").CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Carry to shuttle
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddHumanlikeOrders), 12).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Capture entity
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddHumanlikeOrders), 50).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Reload
SyncDelegate.LocalFunc(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddHumanlikeOrders), "CarryToShuttleAct").CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Carry to shuttle
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddDraftedOrders), 3).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted carry to bed
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddDraftedOrders), 4).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted carry to bed (arrest)
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddDraftedOrders), 5).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted carry entity to holding building
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddDraftedOrders), 6).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted carry to transport shuttle
SyncDelegate.Lambda(typeof(FloatMenuMakerMap), nameof(FloatMenuMakerMap.AddDraftedOrders), 7).CancelIfAnyFieldNull().SetContext(mouseKeyContext); // Drafted carry to cryptosleep casket

Expand Down Expand Up @@ -195,7 +197,7 @@ public static void Init()
SyncDelegate.Lambda(typeof(Pawn), nameof(Pawn.GetGizmos), 5).SetDebugOnly(); // Set growth tier

// Building_HoldingPlatform and related comps
SyncDelegate.Lambda(typeof(Building_HoldingPlatform), nameof(Building_HoldingPlatform.GetGizmos), 1); // Set escape tick
SyncDelegate.Lambda(typeof(Building_HoldingPlatform), nameof(Building_HoldingPlatform.GetGizmos), 1).SetDebugOnly(); // Set escape tick
SyncMethod.Lambda(typeof(CompActivity), nameof(CompActivity.CompGetGizmosExtra), 0).SetDebugOnly(); // Dev activity -5%
SyncMethod.Lambda(typeof(CompActivity), nameof(CompActivity.CompGetGizmosExtra), 1).SetDebugOnly(); // Dev activity +5%
SyncMethod.Lambda(typeof(CompActivity), nameof(CompActivity.CompGetGizmosExtra), 2).SetDebugOnly(); // Dev go active/go passive
Expand Down
43 changes: 43 additions & 0 deletions Source/Client/Syncing/Game/SyncFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@
public static ISyncField SyncMechCarrierGizmoTargetValue;
public static ISyncField SyncMechCarrierMaxToFill;

public static ISyncField SyncStudiableCompEnabled;
public static ISyncField SyncEntityContainmentMode;
public static ISyncField SyncExtractBioferrite;

public static ISyncField SyncActivityGizmoTarget;
public static ISyncField SyncActivityCompTarget;
public static ISyncField SyncActivityCompSuppression;

public static void Init()
{
SyncMedCare = Sync.Field(typeof(Pawn), nameof(Pawn.playerSettings), nameof(Pawn_PlayerSettings.medCare));
Expand Down Expand Up @@ -210,6 +218,14 @@
SyncMechAutoRepair = Sync.Field(typeof(CompMechRepairable), nameof(CompMechRepairable.autoRepair));
SyncMechCarrierGizmoTargetValue = Sync.Field(typeof(MechCarrierGizmo), nameof(MechCarrierGizmo.targetValue)).SetBufferChanges();
SyncMechCarrierMaxToFill = Sync.Field(typeof(CompMechCarrier), nameof(CompMechCarrier.maxToFill)).SetBufferChanges();

SyncStudiableCompEnabled = Sync.Field(typeof(CompStudiable), nameof(CompStudiable.studyEnabled));
SyncEntityContainmentMode = Sync.Field(typeof(CompHoldingPlatformTarget), nameof(CompHoldingPlatformTarget.containmentMode));
SyncExtractBioferrite = Sync.Field(typeof(CompHoldingPlatformTarget), nameof(CompHoldingPlatformTarget.extractBioferrite));

Check failure on line 224 in Source/Client/Syncing/Game/SyncFields.cs

View workflow job for this annotation

GitHub Actions / Builds

'CompHoldingPlatformTarget' does not contain a definition for 'extractBioferrite'

Check failure on line 224 in Source/Client/Syncing/Game/SyncFields.cs

View workflow job for this annotation

GitHub Actions / Builds

'CompHoldingPlatformTarget' does not contain a definition for 'extractBioferrite'

SyncActivityGizmoTarget = Sync.Field(typeof(ActivityGizmo), nameof(ActivityGizmo.targetValuePct)).SetBufferChanges();
SyncActivityCompTarget = Sync.Field(typeof(CompActivity), nameof(CompActivity.suppressIfAbove)).SetBufferChanges();
SyncActivityCompSuppression = Sync.Field(typeof(CompActivity), nameof(CompActivity.suppressionEnabled));
}

[MpPrefix(typeof(StorytellerUI), nameof(StorytellerUI.DrawStorytellerSelectionInterface))]
Expand Down Expand Up @@ -526,6 +542,14 @@
if (geneGizmo.gene is Gene_Hemogen)
SyncGeneHemogenAllowed.Watch(geneGizmo.gene);
}
else if (__instance is ActivityGizmo activityGizmo)
{
SyncActivityGizmoTarget.Watch(activityGizmo);

var comp = activityGizmo.Comp;
SyncActivityCompTarget.Watch(comp);
SyncActivityCompSuppression.Watch(comp);
}
}

[MpPrefix(typeof(ITab_ContentsGenepackHolder), nameof(ITab_ContentsGenepackHolder.DoItemsLists))]
Expand Down Expand Up @@ -560,6 +584,25 @@
SyncMechCarrierGizmoTargetValue.Watch(__instance);
SyncMechCarrierMaxToFill.Watch(__instance.carrier);
}

[MpPrefix(typeof(ITab_StudyNotes), nameof(ITab_StudyNotes.DrawTitle))]
static void CompStudiableEnabledCheckbox(ITab_StudyNotes __instance)
{
var comp = __instance.StudiableThing.TryGetComp<CompStudiable>();
if (comp != null)
SyncStudiableCompEnabled.Watch(comp);
}

[MpPrefix(typeof(ITab_Entity), nameof(ITab_Entity.FillTab))]
static void CompHoldingPlatformTargetMode(ITab_Entity __instance)
{
var comp = __instance.SelPawn.TryGetComp<CompHoldingPlatformTarget>();
if (comp != null)
{
SyncEntityContainmentMode.Watch(comp);
SyncExtractBioferrite.Watch(comp);
}
}
}

}
3 changes: 1 addition & 2 deletions Source/Client/Syncing/Game/SyncMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,9 @@ public static void Init()
SyncMethod.Lambda(typeof(Building_VoidMonolith), nameof(Building_VoidMonolith.GetGizmos), 2).SetDebugOnly(); // Dev relink

// Harbinger Tree
SyncMethod.Register(typeof(HarbingerTree), nameof(HarbingerTree.CreateCorpseStockpile));
SyncMethod.Register(typeof(HarbingerTree), nameof(HarbingerTree.CreateCorpseStockpile)).SetContext(SyncContext.MapSelected);
SyncMethod.Register(typeof(HarbingerTree), nameof(HarbingerTree.AddNutrition)).SetDebugOnly();
SyncMethod.Register(typeof(HarbingerTree), nameof(HarbingerTree.SpawnNewTree)).SetDebugOnly();
SyncMethod.Register(typeof(HarbingerTree), nameof(HarbingerTree.UpdateRoots)).SetDebugOnly();
SyncMethod.LocalFunc(typeof(HarbingerTree), nameof(HarbingerTree.GetGizmos), "DelayedSplatter").SetDebugOnly(); // Set blood splatters delay

// Pawn creep joiner tracker
Expand Down
Loading