Query docked inventory relationships from daemon

This commit is contained in:
Meta Vens 2026-06-21 18:14:12 +01:00
commit 0952ca12da
2 changed files with 72 additions and 10 deletions

View file

@ -7777,7 +7777,12 @@ static void RequireMainMenuContinueRunState(string root)
"entity.RestoreStatGrids(entitySnapshot.StatGrids)",
"RestoreThermalExposure((float)entitySnapshot.Heatstroke, (float)entitySnapshot.Hypothermia)",
"entity.HeatsinksEnabled = entitySnapshot.HeatsinksEnabled",
"RestoreDroppedPickupsFromDaemonZoneState"
"RestoreDroppedPickupsFromDaemonZoneState",
"TryGetDaemonEntitySnapshot(",
"TryGetDaemonParentSnapshot(",
"parentSnapshot.DockingBayAssignments",
"dockedEntitySnapshot.ChildEntityIndices",
"TryGetObservedEntityFacade(childEntityIndex, out var entity)"
};
if (actionGameManager.Contains("_authoritativeDaemonEntities", StringComparison.Ordinal))
@ -7814,7 +7819,9 @@ static void RequireMainMenuContinueRunState(string root)
"UpdateTargetPanel(CurrentEntity.Target.Value)",
"var target = CurrentEntity.Target.Value;",
"TargetIndicator.Target = CurrentEntity.Target.Value.Position",
"indicator.Target = CurrentEntity.Target.Value.Position"
"indicator.Target = CurrentEntity.Target.Value.Position",
"foreach (var bay in CurrentEntity.Parent.DockingBays)",
"foreach (var entity in DockedEntity.Children)"
};
var forbiddenGameplayHits = forbiddenGameplaySymbols

View file

@ -3152,6 +3152,46 @@ public class ActionGameManager : MonoBehaviour
return FindDaemonZoneSnapshot(CurrentDaemonGalaxyZone);
}
private bool TryGetDaemonEntitySnapshot(Entity entity, out AetheriaRuntimeEntitySnapshotCommit snapshot)
{
snapshot = null;
if (entity == null || entity.DaemonEntityIndex < 0)
return false;
snapshot = (FindCurrentDaemonZoneSnapshot()?.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
.FirstOrDefault(candidate => candidate != null && candidate.EntityIndex == entity.DaemonEntityIndex);
return snapshot != null;
}
private bool TryGetDaemonParentSnapshot(
Entity child,
out AetheriaRuntimeEntitySnapshotCommit parentSnapshot,
out Entity parent)
{
parentSnapshot = null;
parent = null;
if (child == null || child.DaemonEntityIndex < 0)
return false;
foreach (var candidate in FindCurrentDaemonZoneSnapshot()?.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
{
if (candidate == null)
continue;
if (!(candidate.ChildEntityIndices ?? Array.Empty<int>()).Contains(child.DaemonEntityIndex) &&
!(candidate.DockingBayAssignments ?? Array.Empty<int>()).Contains(child.DaemonEntityIndex))
{
continue;
}
parentSnapshot = candidate;
TryGetObservedEntityFacade(candidate.EntityIndex, out parent);
return true;
}
return false;
}
private bool TryQueryDaemonEntityContact(
Entity observer,
Entity target,
@ -3469,24 +3509,39 @@ public class ActionGameManager : MonoBehaviour
public IEnumerable<EquippedCargoBay> AvailableCargoBays()
{
if (CurrentEntity.Parent != null)
if (!TryGetDaemonParentSnapshot(CurrentEntity, out var parentSnapshot, out var parent))
yield break;
var assignments = parentSnapshot.DockingBayAssignments ?? Array.Empty<int>();
for (var bayIndex = 0; bayIndex < assignments.Count; bayIndex++)
{
foreach (var bay in CurrentEntity.Parent.DockingBays)
{
if (bay.DockedShip.IsPlayerShip) yield return bay;
}
var dockedEntityIndex = assignments[bayIndex];
if (dockedEntityIndex < 0 ||
parent == null ||
bayIndex >= parent.DockingBays.Count ||
!TryGetObservedEntityFacade(dockedEntityIndex, out var dockedEntity) ||
!(dockedEntity is Ship { IsPlayerShip: true }))
continue;
yield return parent.DockingBays[bayIndex];
}
}
public IEnumerable<Entity> AvailableEntities()
{
if(DockedEntity != null)
foreach (var entity in DockedEntity.Children)
if (DockedEntity != null && TryGetDaemonEntitySnapshot(DockedEntity, out var dockedEntitySnapshot))
{
foreach (var childEntityIndex in dockedEntitySnapshot.ChildEntityIndices ?? Array.Empty<int>())
{
if (entity is Ship { IsPlayerShip: true }) yield return entity;
if (TryGetObservedEntityFacade(childEntityIndex, out var entity) &&
entity is Ship { IsPlayerShip: true })
yield return entity;
}
}
else if (CurrentEntity != null)
{
yield return CurrentEntity;
}
}
public void PlayMusic(MusicType type)