Persist entity contact state in typed snapshots
This commit is contained in:
parent
cb9c5ca21f
commit
1f8a1576f8
10 changed files with 160 additions and 4 deletions
|
|
@ -460,10 +460,28 @@ public static class AetheriaRuntimeCommitLogApplier
|
|||
DockingBayContents = ToCargoBays(entity.DockingBayContents),
|
||||
DockingBayAssignments = ToIntArray(entity.DockingBayAssignments),
|
||||
Visibility = entity.Visibility,
|
||||
VisibilitySourceCount = entity.VisibilitySourceCount
|
||||
VisibilitySourceCount = entity.VisibilitySourceCount,
|
||||
Contacts = ToEntityContacts(entity.Contacts, runId, zoneIndex)
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaEntityContactSnapshot[] ToEntityContacts(
|
||||
IReadOnlyList<AetheriaRuntimeEntityContactCommit>? contacts,
|
||||
string runId,
|
||||
int zoneIndex)
|
||||
{
|
||||
return (contacts ?? Array.Empty<AetheriaRuntimeEntityContactCommit>())
|
||||
.Where(contact => contact.TargetEntityIndex >= 0)
|
||||
.Select(contact => new AetheriaEntityContactSnapshot
|
||||
{
|
||||
TargetEntityKey = EntityKey(runId, zoneIndex, contact.TargetEntityIndex).ToString(),
|
||||
InfoGathered = contact.InfoGathered,
|
||||
Hostile = contact.Hostile,
|
||||
Visible = contact.Visible
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static AetheriaBehaviorStateSnapshot[] ToBehaviorStates(
|
||||
IReadOnlyList<AetheriaRuntimeBehaviorStateCommit>? states)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -509,6 +509,26 @@ public sealed class AetheriaEntitySnapshot
|
|||
|
||||
[Key(28)]
|
||||
public int VisibilitySourceCount { get; set; }
|
||||
|
||||
[Key(29)]
|
||||
public AetheriaEntityContactSnapshot[] Contacts { get; set; } = [];
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
public sealed class AetheriaEntityContactSnapshot
|
||||
{
|
||||
[Key(0)]
|
||||
[CultReference(typeof(AetheriaEntitySnapshot))]
|
||||
public string TargetEntityKey { get; set; } = "";
|
||||
|
||||
[Key(1)]
|
||||
public double InfoGathered { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
public bool Hostile { get; set; }
|
||||
|
||||
[Key(3)]
|
||||
public bool Visible { get; set; }
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
|
|||
Loading…
Reference in a new issue