Query compass markers from daemon contacts

This commit is contained in:
Meta Vens 2026-06-21 15:57:11 +01:00
commit 9af4f4f2da
4 changed files with 239 additions and 9 deletions

View file

@ -933,6 +933,100 @@ public class DaemonRuntimeDocumentTests
Assert.AreEqual(0, poses[2].Size, 0.0001);
}
[Test]
public void DaemonRenderQueriesPublishCompassMarkersFromVisibleContacts()
{
var zone = new AetheriaRuntimeZoneSnapshotCommit
{
Entities = new[]
{
new AetheriaRuntimeEntitySnapshotCommit
{
EntityIndex = 0,
PositionX = 10,
PositionZ = 20,
Contacts = new[]
{
new AetheriaRuntimeEntityContactCommit
{
TargetEntityIndex = 1,
InfoGathered = 0.8,
Visible = true,
Hostile = true
},
new AetheriaRuntimeEntityContactCommit
{
TargetEntityIndex = 2,
InfoGathered = 0.2,
Visible = true
},
new AetheriaRuntimeEntityContactCommit
{
TargetEntityIndex = 3,
InfoGathered = 0.9,
Visible = false
},
new AetheriaRuntimeEntityContactCommit
{
TargetEntityIndex = 4,
InfoGathered = 0.9,
Visible = true
},
new AetheriaRuntimeEntityContactCommit
{
TargetEntityIndex = 99,
InfoGathered = 0.9,
Visible = true
}
}
},
new AetheriaRuntimeEntitySnapshotCommit
{
EntityIndex = 1,
PositionX = 13,
PositionZ = 24
},
new AetheriaRuntimeEntitySnapshotCommit
{
EntityIndex = 2,
PositionX = 100,
PositionZ = 20
},
new AetheriaRuntimeEntitySnapshotCommit
{
EntityIndex = 3,
PositionX = 10,
PositionZ = 200
},
new AetheriaRuntimeEntitySnapshotCommit
{
EntityIndex = 4,
PositionX = 11,
PositionZ = 20
}
}
};
var markers = new List<AetheriaRuntimeDaemonCompassMarker>();
var count = AetheriaRuntimeDaemonRenderQueries.QueryCompassMarkers(
zone,
0,
0.5,
2,
markers);
Assert.AreEqual(1, count);
Assert.AreEqual(1, markers.Count);
Assert.AreEqual(1, markers[0].TargetEntityIndex);
Assert.AreEqual(13, markers[0].PositionX, 0.0001);
Assert.AreEqual(24, markers[0].PositionZ, 0.0001);
Assert.AreEqual(3, markers[0].DeltaX, 0.0001);
Assert.AreEqual(4, markers[0].DeltaZ, 0.0001);
Assert.AreEqual(5, markers[0].Distance, 0.0001);
Assert.AreEqual(0.8, markers[0].InfoGathered, 0.0001);
Assert.IsTrue(markers[0].Hostile);
}
[Test]
public void SoaViewIndexRejectsInvalidRenderGroups()
{

View file

@ -94,6 +94,10 @@ public class ZoneRenderer : MonoBehaviour
new Dictionary<string, AetheriaRuntimeDaemonAsteroidBeltPose>(StringComparer.Ordinal);
private readonly List<AetheriaRuntimeDaemonAsteroidInstancePose> _visibleAsteroidInstancePoses =
new List<AetheriaRuntimeDaemonAsteroidInstancePose>();
private readonly List<AetheriaRuntimeDaemonCompassMarker> _daemonCompassMarkers =
new List<AetheriaRuntimeDaemonCompassMarker>();
private readonly Dictionary<int, AetheriaRuntimeDaemonCompassMarker> _daemonCompassMarkersByEntityIndex =
new Dictionary<int, AetheriaRuntimeDaemonCompassMarker>();
public Dictionary<Wormhole, (GameObject gravity, CompassIcon icon)> WormholeInstances = new Dictionary<Wormhole, (GameObject, CompassIcon)>();
private List<ItemPickup> _loot = new List<ItemPickup>();
@ -471,6 +475,7 @@ public class ZoneRenderer : MonoBehaviour
Shader.SetGlobalFloat("_AsteroidVerticalOffset", ActionGameManager.Instance.Settings.PlanetSettings.AsteroidVerticalOffset);
RefreshDaemonBodyPoses();
RefreshDaemonAsteroidBeltPoses();
RefreshDaemonCompassMarkers();
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(MainCamera);
bool isVisible(Bounds bounds) => GeometryUtility.TestPlanesAABB(planes, bounds);
@ -556,14 +561,16 @@ public class ZoneRenderer : MonoBehaviour
{
if(entityInstance.CompassIcon)
{
var difference = entityInstance.Entity.CultPositionXZ - PerspectiveEntity.CultPositionXZ;
var distance = CultMath.math.length(difference);
entityInstance.CompassIcon.gameObject.SetActive(
PerspectiveEntity.EntityInfoGathered.ContainsKey(entityInstance.Entity) &&
PerspectiveEntity.EntityInfoGathered[entityInstance.Entity] > Settings.GameplaySettings.TargetDetectionInfoThreshold &&
distance > _minimapDistance);
entityInstance.CompassIcon.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90);
var active = entityInstance.Entity != null &&
_daemonCompassMarkersByEntityIndex.TryGetValue(entityInstance.Entity.DaemonEntityIndex, out var marker);
entityInstance.CompassIcon.gameObject.SetActive(active);
if (active)
{
entityInstance.CompassIcon.transform.rotation = Quaternion.Euler(
0,
0,
Mathf.Atan2((float)marker.DeltaZ, (float)marker.DeltaX) * Mathf.Rad2Deg - 90);
}
}
}
@ -616,6 +623,19 @@ public class ZoneRenderer : MonoBehaviour
}
}
private void RefreshDaemonCompassMarkers()
{
AetheriaRuntimeDaemonRenderQueries.QueryCompassMarkers(
_daemonZoneSnapshot,
PerspectiveEntity?.DaemonEntityIndex ?? -1,
Settings.GameplaySettings.TargetDetectionInfoThreshold,
_minimapDistance,
_daemonCompassMarkers);
_daemonCompassMarkersByEntityIndex.Clear();
foreach (var marker in _daemonCompassMarkers)
_daemonCompassMarkersByEntityIndex[marker.TargetEntityIndex] = marker;
}
private float GetTerrainHeight(float2 position)
{
return (float)AetheriaRuntimeDaemonRenderQueries.EvaluateGravityTerrainHeight(