Project wormholes from daemon zone topology

This commit is contained in:
Meta Vens 2026-06-21 16:07:13 +01:00
commit c0e60413a2
5 changed files with 170 additions and 15 deletions

View file

@ -2046,7 +2046,10 @@ public class ActionGameManager : MonoBehaviour
}
}
public void PopulateLevel(GalaxyZone galaxyZone, AetheriaRuntimeZoneSnapshotCommit daemonZone = null)
public void PopulateLevel(
GalaxyZone galaxyZone,
AetheriaRuntimeZoneSnapshotCommit daemonZone = null,
AetheriaRuntimeRunCheckpointCommit daemonRun = null)
{
if (galaxyZone == null) throw new ArgumentNullException(nameof(galaxyZone));
@ -2067,7 +2070,7 @@ public class ActionGameManager : MonoBehaviour
Zone.Log = s => Debug.Log($"Zone: {s}");
ZoneRenderer.LoadZone(Zone, daemonZone);
ZoneRenderer.LoadZone(Zone, daemonZone, daemonRun);
if (CurrentEntity != null)
{
@ -2222,7 +2225,7 @@ public class ActionGameManager : MonoBehaviour
if (Zone?.GalaxyZone != targetZone)
{
PopulateLevel(targetZone, daemonZone);
PopulateLevel(targetZone, daemonZone, run);
}
var actionBarBindings = run.ActionBarBindings?

View file

@ -1083,6 +1083,46 @@ public class DaemonRuntimeDocumentTests
Assert.AreEqual(11, visible[1]);
}
[Test]
public void DaemonRenderQueriesPublishWormholeExitsFromZoneAdjacency()
{
var currentZone = new AetheriaRuntimeZoneSnapshotCommit
{
ZoneIndex = 0,
PositionX = 10,
PositionY = 20,
AdjacentZoneIndices = new[] { 1, 99 }
};
var run = new AetheriaRuntimeRunCheckpointCommit
{
Zones = new[]
{
currentZone,
new AetheriaRuntimeZoneSnapshotCommit
{
ZoneIndex = 1,
PositionX = 13,
PositionY = 24
}
}
};
var exits = new List<AetheriaRuntimeDaemonWormholeExit>();
var count = AetheriaRuntimeDaemonRenderQueries.QueryWormholeExits(
run,
currentZone,
100,
0.5,
exits);
Assert.AreEqual(1, count);
Assert.AreEqual(1, exits[0].TargetZoneIndex);
Assert.AreEqual(0.6, exits[0].DirectionX, 0.0001);
Assert.AreEqual(0.8, exits[0].DirectionZ, 0.0001);
Assert.AreEqual(30, exits[0].PositionX, 0.0001);
Assert.AreEqual(40, exits[0].PositionZ, 0.0001);
}
[Test]
public void SoaViewIndexRejectsInvalidRenderGroups()
{

View file

@ -82,6 +82,7 @@ public class ZoneRenderer : MonoBehaviour
private Entity _perspectiveEntity;
private PlanetObject[] _suns;
private bool _showAsteroidUI;
private AetheriaRuntimeRunCheckpointCommit _daemonRunSnapshot;
private AetheriaRuntimeZoneSnapshotCommit _daemonZoneSnapshot;
private readonly List<AetheriaRuntimeDaemonBodyPose> _daemonBodyPoses = new List<AetheriaRuntimeDaemonBodyPose>();
private readonly Dictionary<string, AetheriaRuntimeDaemonBodyPose> _daemonBodyPosesByBodyKey =
@ -99,6 +100,8 @@ public class ZoneRenderer : MonoBehaviour
private readonly List<int> _daemonVisibleEntityIndices = new List<int>();
private readonly HashSet<int> _daemonVisibleEntityIndicesSet = new HashSet<int>();
private readonly HashSet<int> _visibleDaemonEntityIndices = new HashSet<int>();
private readonly List<AetheriaRuntimeDaemonWormholeExit> _daemonWormholeExits =
new List<AetheriaRuntimeDaemonWormholeExit>();
public Dictionary<Wormhole, (GameObject gravity, CompassIcon icon)> WormholeInstances = new Dictionary<Wormhole, (GameObject, CompassIcon)>();
private List<ItemPickup> _loot = new List<ItemPickup>();
@ -178,10 +181,14 @@ public class ZoneRenderer : MonoBehaviour
_transposer = SceneCamera.GetCinemachineComponent<CinemachineTransposer>();
}
public void LoadZone(Zone zone, AetheriaRuntimeZoneSnapshotCommit daemonZone = null)
public void LoadZone(
Zone zone,
AetheriaRuntimeZoneSnapshotCommit daemonZone = null,
AetheriaRuntimeRunCheckpointCommit daemonRun = null)
{
ClearZone();
Zone = zone;
_daemonRunSnapshot = daemonRun;
_daemonZoneSnapshot = daemonZone;
SectorBrushes.localScale = zone.Radius * 2 * Vector3.one;
SlimeGravityCamera.orthographicSize = zone.Radius;
@ -217,17 +224,24 @@ public class ZoneRenderer : MonoBehaviour
}
}
if (zone.GalaxyZone != null)
AetheriaRuntimeDaemonRenderQueries.QueryWormholeExits(
_daemonRunSnapshot,
_daemonZoneSnapshot,
zone.Radius,
Settings.WormholeDistanceRatio,
_daemonWormholeExits);
foreach (var exit in _daemonWormholeExits)
{
foreach (var adjacentZone in zone.GalaxyZone.AdjacentZones)
var target = zone.Galaxy != null &&
exit.TargetZoneIndex >= 0 &&
exit.TargetZoneIndex < zone.Galaxy.Zones.Length
? zone.Galaxy.Zones[exit.TargetZoneIndex]
: null;
AddWormhole(new Wormhole
{
var dir = normalize(adjacentZone.Position - zone.GalaxyZone.Position);
AddWormhole(new Wormhole
{
Target = adjacentZone,
Position = AetheriaMath.ToCult(dir * zone.Radius * Settings.WormholeDistanceRatio)
});
}
Target = target,
Position = AetheriaMath.ToCult(new float2((float)exit.PositionX, (float)exit.PositionZ))
});
}
}