Skip to content
Open
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
23 changes: 23 additions & 0 deletions Source/Client/Syncing/Dict/SyncDictDlc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,29 @@ public static class SyncDictDlc
return new PawnPsychicRitualRoleSelectionWidget(ritual, assignments.session.candidatePool, assignments);
}
},
{
(ByteWriter data, PsychicRitualToil toil) =>
{
data.WriteString(toil.uniqueId);
},
(ByteReader data) =>
{
var psychicRitualId = data.ReadString();

// Check all maps
return Find.Maps.SelectMany(map => map.lordManager.lords)
// Grab all lord toils
.Select(lord => lord.CurLordToil)
// Grab all psychic ritual toils
.OfType<LordToil_PsychicRitual>()
// Select all current psychic ritual toils
.Select(lordToil => lordToil.RitualData?.CurPsychicRitualToil)
// But only if not null, just as a precaution
.AllNotNull()
// Grab the first one with matching ID
.FirstOrDefault(toil => toil.uniqueId == psychicRitualId);
}, true // Implicit
},

#endregion
};
Expand Down
12 changes: 12 additions & 0 deletions Source/Client/Syncing/Dict/SyncDictMisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ public static class SyncDictMisc
return context;
}
},
{
(ByteWriter data, AcceptanceReport report) =>
{
data.WriteBool(report.acceptedInt);
data.WriteString(report.reasonTextInt);
},
(ByteReader data) => new AcceptanceReport
{
acceptedInt = data.ReadBool(),
reasonTextInt = data.ReadStringNullable()
}
},
#endregion

#region Unity
Expand Down
44 changes: 44 additions & 0 deletions Source/Client/Syncing/Dict/SyncDictRimWorld.cs
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,24 @@ public static class SyncDictRimWorld
return (parent.gun as ThingWithComps).TryGetComp<CompChangeableProjectile>();
}
},
{
(ByteWriter writer, ReadingOutcomeDoer doer) =>
{
WriteSync(writer, doer.Readable);
writer.WriteInt32(doer.Readable.doers.IndexOf(doer));
},
(ByteReader reader) =>
{
var parent = ReadSync<CompReadable>(reader);
var index = reader.ReadInt32();

// Make sure we have a valid doer
if (parent == null || index < 0 || index >= parent.doers.Count)
return null;

return parent.doers[index];
}, true // implicit
},
#endregion

#region Things
Expand Down Expand Up @@ -1047,6 +1065,32 @@ public static class SyncDictRimWorld
return Find.WorldGrid.PlanetLayers[layerId];
}, true
},
{
(ByteWriter data, Tile tile) =>
{
var map = Find.Maps.Find(m => m.pocketTileInfo == tile);

// Handle pocket map
if (map != null)
{
data.WriteInt32(map.uniqueID);
}
// Handle normal tile
else
{
data.WriteInt32(-1);
WriteSync(data, tile.tile);
}
},
(ByteReader data) =>
{
var pocketMapId = data.ReadInt32();

if (pocketMapId >= 0)
return Find.Maps.Find(m => m.uniqueID == pocketMapId)?.pocketTileInfo;
return ReadSync<PlanetTile>(data).Tile;
}
},
#endregion

#region Game
Expand Down
18 changes: 13 additions & 5 deletions Source/Client/Syncing/Game/SyncDelegates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public static void Init()
SyncDelegate.Lambda(typeof(Building_PassengerShuttle), nameof(Building_PassengerShuttle.GetGizmos), 2); // Fill shuttle from cargo on map
SyncMethod.Lambda(typeof(CompFlickable), nameof(CompFlickable.CompGetGizmosExtra), 1); // Toggle flick designation
SyncMethod.Lambda(typeof(Pawn_PlayerSettings), nameof(Pawn_PlayerSettings.GetGizmos), 1); // Toggle release animals
SyncMethod.Lambda(typeof(Pawn_PlayerSettings), nameof(Pawn_PlayerSettings.GetGizmos), 2); // Force animals to attack specific target
SyncMethod.Lambda(typeof(Building_TurretGun), nameof(Building_TurretGun.GetGizmos), 2); // Toggle turret hold fire
SyncMethod.Lambda(typeof(Building_Trap), nameof(Building_Trap.GetGizmos), 1); // Toggle trap auto-rearm
SyncMethod.Lambda(typeof(Building_Door), nameof(Building_Door.GetGizmos), 1); // Toggle door hold open
Expand Down Expand Up @@ -97,7 +98,7 @@ public static void Init()
SyncMethod.Lambda(typeof(CompTreeConnection), nameof(CompTreeConnection.CompGetGizmosExtra), 2).SetDebugOnly(); // Increase connection strength by 10%
SyncMethod.Lambda(typeof(CompTreeConnection), nameof(CompTreeConnection.CompGetGizmosExtra), 3).SetDebugOnly(); // Decrease connection strength by 10%

SyncMethod.Lambda(typeof(CompNeuralSupercharger), nameof(CompNeuralSupercharger.CompGetGizmosExtra), 1); // Neural supercharger: allow temporary pawns to use
SyncMethod.Lambda(typeof(CompNeuralSupercharger), nameof(CompNeuralSupercharger.CompGetGizmosExtra), 1); // Neural supercharger: allow temporary pawns (guests) to use

SyncMethod.Lambda(typeof(CompPilotConsole), nameof(CompPilotConsole.CompGetGizmosExtra), 1).SetDebugOnly(); // Dev launch instantly
SyncMethod.Lambda(typeof(CompPilotConsole), nameof(CompPilotConsole.CompGetGizmosExtra), 2).SetDebugOnly(); // Dev reset cooldown
Expand Down Expand Up @@ -129,10 +130,10 @@ public static void Init()
SyncDelegate.Lambda(typeof(Pawn_CarryTracker), nameof(Pawn_CarryTracker.GetGizmos), 1).SetDebugOnly(); // Trigger dissolution event (CompDissolution)

// CompSpawner
SyncMethod.Lambda(typeof(CompSpawner), nameof(CompSpawner.CompGetGizmosExtra), 0).SetDebugOnly();
SyncMethod.Lambda(typeof(CompSpawnerHives), nameof(CompSpawnerHives.CompGetGizmosExtra), 0).SetDebugOnly();
SyncMethod.Lambda(typeof(CompSpawnerItems), nameof(CompSpawnerItems.CompGetGizmosExtra), 0).SetDebugOnly();
SyncMethod.Lambda(typeof(CompSpawnerPawn), nameof(CompSpawnerPawn.CompGetGizmosExtra), 0).SetDebugOnly();
SyncMethod.Lambda(typeof(CompSpawner), nameof(CompSpawner.CompGetGizmosExtra), 0).SetDebugOnly(); // Spawn thing
SyncMethod.Lambda(typeof(CompSpawnerHives), nameof(CompSpawnerHives.CompGetGizmosExtra), 0).SetDebugOnly(); // Reproduce
SyncMethod.Lambda(typeof(CompSpawnerItems), nameof(CompSpawnerItems.CompGetGizmosExtra), 0).SetDebugOnly(); // Spawn items
SyncMethod.Lambda(typeof(CompSpawnerPawn), nameof(CompSpawnerPawn.CompGetGizmosExtra), 0).SetDebugOnly(); // Spawn pawn

SyncMethod.Lambda(typeof(CompSendSignalOnCountdown), nameof(CompSendSignalOnCountdown.CompGetGizmosExtra), 0).SetDebugOnly();

Expand Down Expand Up @@ -242,6 +243,9 @@ public static void Init()
SyncDelegate.Lambda(typeof(GeneResourceDrainUtility), nameof(GeneResourceDrainUtility.GetResourceDrainGizmos), 0).SetDebugOnly(); // -10% resource
SyncDelegate.Lambda(typeof(GeneResourceDrainUtility), nameof(GeneResourceDrainUtility.GetResourceDrainGizmos), 1).SetDebugOnly(); // +10% resource
SyncMethod.Register(typeof(CompBreakdownable), nameof(CompBreakdownable.Notify_Repaired)).SetDebugOnly(); // Dev repair breakdownable
SyncDelegate.Lambda(typeof(CompCanBeDormant), nameof(CompCanBeDormant.CompGetGizmosExtra), 1).SetDebugOnly(); // Wake up after delay
SyncDelegate.Lambda(typeof(Tile), nameof(Tile.GetGizmos), 0).SetDebugOnly(); // Generate settlement
SyncDelegate.Lambda(typeof(Tile), nameof(Tile.GetGizmos), 4).SetDebugOnly(); // Generate map

// Hediffs
SyncMethod.Register(typeof(Hediff_CubeInterest), nameof(Hediff_CubeInterest.StartWithdrawal)).SetDebugOnly();
Expand Down Expand Up @@ -272,6 +276,10 @@ public static void Init()

SyncDelegate.Lambda(typeof(CompNociosphere), nameof(CompNociosphere.TargetLocation), 1);

// Animal training tracker
SyncDelegate.Lambda(typeof(Pawn_TrainingTracker), nameof(Pawn_TrainingTracker.GetGizmos), 0, fields: [SyncDelegate.DelegateThis, "master"]).SetContext(SyncContext.MapSelected).CancelIfNoSelectedMapObjects(); // Force attack target
SyncDelegate.Lambda(typeof(Pawn_TrainingTracker), nameof(Pawn_TrainingTracker.GetGizmos), 3).SetContext(SyncContext.MapSelected).CancelIfNoSelectedMapObjects(); // Cancel attacking target

InitRituals();
InitChoiceLetters();
InitDevTools();
Expand Down
18 changes: 11 additions & 7 deletions Source/Client/Syncing/Game/SyncFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ static void WatchAwaitingExecution(Pawn pawn)
}

[MpPrefix(typeof(Gizmo_Slider), nameof(Gizmo_Slider.GizmoOnGUI))]
static void SyncGizmoSlider(Gizmo_Slider __instance)
static void SyncGizmoSliderChanges(Gizmo_Slider __instance)
{
if (__instance is GeneGizmo_Resource geneGizmo)
{
Expand All @@ -638,12 +638,16 @@ static void SyncGizmoSlider(Gizmo_Slider __instance)
SyncActivityCompTarget.Watch(comp);
SyncActivityCompSuppression.Watch(comp);
}
else if (__instance is Gizmo_SetFuelLevel fuelGizmo)
{
var refuelable = fuelGizmo.refuelable;
SyncCompRefuelableValue.Watch(refuelable);
SyncCompRefuelableTargetFuelLevel.Watch(refuelable);
}
}

[MpPrefix(typeof(Gizmo_SetFuelLevel), nameof(Gizmo_SetFuelLevel.GizmoOnGUI))]
static void SyncRefuelableChanges(Gizmo_SetFuelLevel __instance)
{
// Must be separate from SyncGizmoSliderChanges, as this type overrides the base
// method and modifies the field in there (toggle the value using a hotkey).
var refuelable = __instance.refuelable;
SyncCompRefuelableValue.Watch(refuelable);
SyncCompRefuelableTargetFuelLevel.Watch(refuelable);
}

[MpPrefix(typeof(ITab_ContentsGenepackHolder), nameof(ITab_ContentsGenepackHolder.DoItemsLists))]
Expand Down
Loading
Loading