Share dock parent sensor picture
This commit is contained in:
parent
4351226b41
commit
cadddb4c87
7 changed files with 208 additions and 9 deletions
|
|
@ -676,8 +676,92 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public double DepthRange { get; }
|
||||
}
|
||||
|
||||
public readonly struct AetheriaRuntimeEffectiveContact
|
||||
{
|
||||
public AetheriaRuntimeEffectiveContact(
|
||||
int observerEntityIndex,
|
||||
int primarySensorSourceEntityIndex,
|
||||
AetheriaRuntimeEntityContactCommit contact)
|
||||
{
|
||||
ObserverEntityIndex = observerEntityIndex;
|
||||
PrimarySensorSourceEntityIndex = primarySensorSourceEntityIndex;
|
||||
Contact = contact ?? throw new ArgumentNullException(nameof(contact));
|
||||
}
|
||||
|
||||
public int ObserverEntityIndex { get; }
|
||||
public int PrimarySensorSourceEntityIndex { get; }
|
||||
public AetheriaRuntimeEntityContactCommit Contact { get; }
|
||||
}
|
||||
|
||||
public static class AetheriaRuntimeDaemonRenderQueries
|
||||
{
|
||||
public static AetheriaRuntimeEffectiveContact[] QueryEffectiveContacts(
|
||||
AetheriaRuntimeZoneSnapshotCommit? zone,
|
||||
int observerEntityIndex)
|
||||
{
|
||||
if (zone == null || observerEntityIndex < 0)
|
||||
return Array.Empty<AetheriaRuntimeEffectiveContact>();
|
||||
|
||||
var entities = zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>();
|
||||
var observer = entities.FirstOrDefault(entity =>
|
||||
entity != null && entity.EntityIndex == observerEntityIndex);
|
||||
if (observer == null)
|
||||
return Array.Empty<AetheriaRuntimeEffectiveContact>();
|
||||
|
||||
var sources = new List<AetheriaRuntimeEntitySnapshotCommit> { observer };
|
||||
var dockParent = entities.FirstOrDefault(entity => entity != null &&
|
||||
(entity.DockingBayAssignments ?? Array.Empty<int>()).Contains(observerEntityIndex));
|
||||
if (dockParent != null && dockParent.EntityIndex != observerEntityIndex)
|
||||
sources.Add(dockParent);
|
||||
|
||||
var contacts = new Dictionary<int, AetheriaRuntimeEffectiveContact>();
|
||||
foreach (var source in sources)
|
||||
foreach (var contact in source.Contacts ?? Array.Empty<AetheriaRuntimeEntityContactCommit>())
|
||||
{
|
||||
if (contact == null || contact.TargetEntityIndex < 0)
|
||||
continue;
|
||||
|
||||
if (!contacts.TryGetValue(contact.TargetEntityIndex, out var previous))
|
||||
{
|
||||
contacts.Add(contact.TargetEntityIndex, Effective(observerEntityIndex, source.EntityIndex, contact));
|
||||
continue;
|
||||
}
|
||||
|
||||
var previousContact = previous.Contact;
|
||||
var sourceWins = contact.InfoGathered > previousContact.InfoGathered ||
|
||||
(contact.InfoGathered == previousContact.InfoGathered && contact.Visible && !previousContact.Visible);
|
||||
contacts[contact.TargetEntityIndex] = new AetheriaRuntimeEffectiveContact(
|
||||
observerEntityIndex,
|
||||
sourceWins ? source.EntityIndex : previous.PrimarySensorSourceEntityIndex,
|
||||
new AetheriaRuntimeEntityContactCommit
|
||||
{
|
||||
TargetEntityIndex = contact.TargetEntityIndex,
|
||||
InfoGathered = Math.Max(previousContact.InfoGathered, contact.InfoGathered),
|
||||
Hostile = previousContact.Hostile || contact.Hostile,
|
||||
Visible = previousContact.Visible || contact.Visible
|
||||
});
|
||||
}
|
||||
|
||||
return contacts.Values
|
||||
.OrderBy(contact => contact.Contact.TargetEntityIndex)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeEffectiveContact Effective(
|
||||
int observerEntityIndex,
|
||||
int primarySensorSourceEntityIndex,
|
||||
AetheriaRuntimeEntityContactCommit contact) =>
|
||||
new AetheriaRuntimeEffectiveContact(
|
||||
observerEntityIndex,
|
||||
primarySensorSourceEntityIndex,
|
||||
new AetheriaRuntimeEntityContactCommit
|
||||
{
|
||||
TargetEntityIndex = contact.TargetEntityIndex,
|
||||
InfoGathered = contact.InfoGathered,
|
||||
Hostile = contact.Hostile,
|
||||
Visible = contact.Visible
|
||||
});
|
||||
|
||||
public static double ResolveZoneRenderRadius(
|
||||
AetheriaRuntimeZoneSnapshotCommit? zone,
|
||||
double fallbackRadius)
|
||||
|
|
|
|||
|
|
@ -51,11 +51,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var dockParent = (zone?.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
|
||||
.FirstOrDefault(entity => entity != null && controlled != null &&
|
||||
(entity.DockingBayAssignments ?? Array.Empty<int>()).Contains(controlled.EntityIndex));
|
||||
var visibleContacts = (controlled?.Contacts ?? Array.Empty<AetheriaRuntimeEntityContactCommit>())
|
||||
.Concat(dockParent?.Contacts ?? Array.Empty<AetheriaRuntimeEntityContactCommit>());
|
||||
var visibleEntityIndices = visibleContacts
|
||||
.Where(contact => contact != null && contact.Visible)
|
||||
.Select(contact => contact.TargetEntityIndex)
|
||||
var visibleEntityIndices = AetheriaRuntimeDaemonRenderQueries
|
||||
.QueryEffectiveContacts(zone, controlled?.EntityIndex ?? -1)
|
||||
.Where(contact => contact.Contact.Visible)
|
||||
.Select(contact => contact.Contact.TargetEntityIndex)
|
||||
.Append(controlled?.EntityIndex ?? -1)
|
||||
.ToHashSet();
|
||||
if (dockParent != null)
|
||||
|
|
|
|||
|
|
@ -481,6 +481,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var entityMap = entities
|
||||
.Where(entity => entity != null && entity.EntityIndex >= 0)
|
||||
.ToDictionary(entity => entity.EntityIndex, entity => entity);
|
||||
var currentEntityIndex = TryParseEntityIndex(context.Run.CurrentEntityKey);
|
||||
|
||||
return new AetheriaRuntimeZoneContactsDocument
|
||||
{
|
||||
|
|
@ -497,12 +498,25 @@ namespace GameCult.Aetheria.State.Verse
|
|||
.Select(entity => ToZoneTargetRow(entity, entityMap[entity.TargetEntityIndex]))
|
||||
.ToArray(),
|
||||
Contacts = entities
|
||||
.Where(entity => entity != null)
|
||||
.Where(entity => entity != null && entity.EntityIndex != currentEntityIndex)
|
||||
.SelectMany(entity => (entity.Contacts ?? Array.Empty<AetheriaRuntimeEntityContactCommit>())
|
||||
.Where(contact => contact != null &&
|
||||
contact.TargetEntityIndex >= 0 &&
|
||||
entityMap.ContainsKey(contact.TargetEntityIndex))
|
||||
.Select(contact => ProjectZoneContactRow(entity, entityMap[contact.TargetEntityIndex], contact)))
|
||||
.Select(contact => ProjectZoneContactRow(
|
||||
entity.EntityIndex,
|
||||
entity.EntityIndex,
|
||||
entity,
|
||||
entityMap[contact.TargetEntityIndex],
|
||||
contact)))
|
||||
.Concat(AetheriaRuntimeDaemonRenderQueries.QueryEffectiveContacts(context.Zone, currentEntityIndex)
|
||||
.Where(effective => entityMap.ContainsKey(effective.Contact.TargetEntityIndex))
|
||||
.Select(effective => ProjectZoneContactRow(
|
||||
effective.ObserverEntityIndex,
|
||||
effective.PrimarySensorSourceEntityIndex,
|
||||
entityMap[currentEntityIndex],
|
||||
entityMap[effective.Contact.TargetEntityIndex],
|
||||
effective.Contact)))
|
||||
.ToArray()
|
||||
};
|
||||
}
|
||||
|
|
@ -588,6 +602,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
}
|
||||
|
||||
private static AetheriaRuntimeZoneContactRow ProjectZoneContactRow(
|
||||
int observerEntityIndex,
|
||||
int primarySensorSourceEntityIndex,
|
||||
AetheriaRuntimeEntitySnapshotCommit observer,
|
||||
AetheriaRuntimeEntitySnapshotCommit target,
|
||||
AetheriaRuntimeEntityContactCommit contact)
|
||||
|
|
@ -597,7 +613,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
var deltaZ = target.PositionZ - observer.PositionZ;
|
||||
return new AetheriaRuntimeZoneContactRow
|
||||
{
|
||||
ObserverEntityIndex = observer.EntityIndex,
|
||||
ObserverEntityIndex = observerEntityIndex,
|
||||
PrimarySensorSourceEntityIndex = primarySensorSourceEntityIndex,
|
||||
TargetEntityIndex = target.EntityIndex,
|
||||
InfoGathered = contact.InfoGathered,
|
||||
Hostile = contact.Hostile,
|
||||
|
|
|
|||
|
|
@ -461,6 +461,9 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
[Key(11)]
|
||||
public double Distance { get; set; }
|
||||
|
||||
[Key(12)]
|
||||
public int PrimarySensorSourceEntityIndex { get; set; } = -1;
|
||||
}
|
||||
|
||||
[CultDocument("gamecult.aetheria.station_refit", "gamecult.aetheria.station_refit.v1")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue