diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index 6625e8f9a..94be89746 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -31,24 +31,26 @@ else internal sealed class AetheriaDaemonYmirSmokeChecks { - public void RunGravity() => PositiveGravityDepthAttractsAndProjectsAsAWell(); + private static readonly List OwnedPhysics = []; + + public void RunGravity() => RunCheck(PositiveGravityDepthAttractsAndProjectsAsAWell); public void RunLoadout() => DaemonLoadoutsRespectFactionAvailabilityAndHullRoles(); public void RunPickup() { - RetainedWorldAdvancesEveryFixedSubstep(); - StableEntityIdentitySurvivesCrossZoneReindex(); - PickupIsCapacityCheckedExactlyOnceAndExpires(); - PickupShieldContactCollectsOrBounces(); + RunCheck(RetainedWorldAdvancesEveryFixedSubstep); + RunCheck(StableEntityIdentitySurvivesCrossZoneReindex); + RunCheck(PickupIsCapacityCheckedExactlyOnceAndExpires); + RunCheck(PickupShieldContactCollectsOrBounces); } public void RunPayload() { - YmirMovesProjectileAndReportsStableContact(); - PayloadQueryExcludesItsSource(); - PayloadBodiesDoNotCollideWithEachOther(); - OverlappingMineRemainsQueryableAfterArming(); + RunCheck(YmirMovesProjectileAndReportsStableContact); + RunCheck(PayloadQueryExcludesItsSource); + RunCheck(PayloadBodiesDoNotCollideWithEachOther); + RunCheck(OverlappingMineRemainsQueryableAfterArming); } private static void RetainedWorldAdvancesEveryFixedSubstep() @@ -62,7 +64,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks CurrentEntityKey = "zone.0.entity.0", Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [ship] }] }; - using var physics = new AetheriaYmirWorldPhysics(); + using var physics = NewPhysics(); AetheriaRuntimeDaemonTickRunner.Tick( Path.Combine(Path.GetTempPath(), "aetheria-retained-substeps.cc"), run, @@ -98,7 +100,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks CurrentEntityKey = "zone.0.entity.0", Zones = [source, destination] }; - using var physics = new AetheriaYmirWorldPhysics(); + using var physics = NewPhysics(); AetheriaRuntimeDaemonTickRunner.Tick( Path.Combine(Path.GetTempPath(), "aetheria-cross-zone-before.cc"), run, @@ -138,52 +140,78 @@ internal sealed class AetheriaDaemonYmirSmokeChecks public void Run() { - PositiveGravityDepthAttractsAndProjectsAsAWell(); - YmirMovesProjectileAndReportsStableContact(); - InstantWeaponRequestSurvivesLockAcquisition(); - ConstantWeaponRunsOnDaemonThroughYmirBeamContact(); - ChargedWeaponCannotBypassChargeLifecycle(); - ChargedWeaponHoldRiskMalfunctionsDeterministically(); - DeployableWeaponRunsThroughYmirAndDetonatesOnDaemon(); - DeployableRangeExpiryDetonatesAfterYmirMovement(); - CanonicalCatalogPublishesRecoveredMineLauncher(); - EnergyFundedShieldInterceptsDamageBeforeHull(); - ArmorCellsResolveBeforeEquipmentAndHull(); - DestructionDropsLootExactlyOnce(); - DaemonSimulationTreatsYmirHitAsPresentationOnly(); - ProjectileContactCannotKill(); - MissingWorldPhysicsOwnerCannotAdvanceShips(); - TractorRampsAndPullsThroughYmirWithoutTeleportingCargo(); - PickupIsCapacityCheckedExactlyOnceAndExpires(); - PickupShieldContactCollectsOrBounces(); - ThermalCellsUseFossilConductionAndRadiation(); - EnergyNetworkSettlesReactorAfterConsumers(); - RadiatorPumpsHeatBeforeReactorSettlement(); - EquipmentThermalPerformanceOwnsShutdownAndWear(); - ThermalTopologyComesFromHullAndEquipment(); - ThermalMedicalExposureUsesCockpitTemperature(); - ThermalMedicalDeathUsesOrdinaryDestructionPath(); - MultipleActorsUseTheSameMovementLever(); - AgentClaimsAndCompletesExploreTaskThroughCommands(); - SchedulerAssignsHighestPriorityCompatibleTask(); - SchedulerRequeuesTaskFromDeadAgent(); - SchedulerCollapsesDuplicateAssignmentMarkers(); - SchedulerAssignsShortestGalaxyRoute(); - AgentTraversesGalaxyRouteBeforeExecutingTask(); - IdleAgentReturnsToCanonicalHomeAndDocks(); - ControlledShipDoesNotReceiveAutonomousHelmCommands(); - AttackAgentControlsOptimumRangeThroughMovementLever(); - AttackTaskAdmissionRejectsImpossibleWork(); - AgentCompletesAttackTaskThroughTargetFireAndYmir(); - AgentCompletesHaulTaskThroughMovementAndCargoCommands(); - RejectedHaulTransferDoesNotAdvanceTask(); - AgentPatrolsHistoricalOrbitCircuitThroughMovementCommands(); - TickReconcilesAndEvaluatesCatalogBehaviors(); - DaemonLoadoutsRespectFactionAvailabilityAndHullRoles(); - AgentMinesAsteroidThroughEquippedBehavior(); - CargoCapacityComesFromHullAndCatalogVolumes(); - AgentSurveysBodyIntoCorporationKnowledge(); - AgentTowsStationIntoPersistentOrbit(); + Action[] checks = + [ + PositiveGravityDepthAttractsAndProjectsAsAWell, + YmirMovesProjectileAndReportsStableContact, + InstantWeaponRequestSurvivesLockAcquisition, + ConstantWeaponRunsOnDaemonThroughYmirBeamContact, + ChargedWeaponCannotBypassChargeLifecycle, + ChargedWeaponHoldRiskMalfunctionsDeterministically, + DeployableWeaponRunsThroughYmirAndDetonatesOnDaemon, + DeployableRangeExpiryDetonatesAfterYmirMovement, + CanonicalCatalogPublishesRecoveredMineLauncher, + EnergyFundedShieldInterceptsDamageBeforeHull, + ArmorCellsResolveBeforeEquipmentAndHull, + DestructionDropsLootExactlyOnce, + DaemonSimulationTreatsYmirHitAsPresentationOnly, + ProjectileContactCannotKill, + MissingWorldPhysicsOwnerCannotAdvanceShips, + TractorRampsAndPullsThroughYmirWithoutTeleportingCargo, + PickupIsCapacityCheckedExactlyOnceAndExpires, + PickupShieldContactCollectsOrBounces, + ThermalCellsUseFossilConductionAndRadiation, + EnergyNetworkSettlesReactorAfterConsumers, + RadiatorPumpsHeatBeforeReactorSettlement, + EquipmentThermalPerformanceOwnsShutdownAndWear, + ThermalTopologyComesFromHullAndEquipment, + ThermalMedicalExposureUsesCockpitTemperature, + ThermalMedicalDeathUsesOrdinaryDestructionPath, + MultipleActorsUseTheSameMovementLever, + AgentClaimsAndCompletesExploreTaskThroughCommands, + SchedulerAssignsHighestPriorityCompatibleTask, + SchedulerRequeuesTaskFromDeadAgent, + SchedulerCollapsesDuplicateAssignmentMarkers, + SchedulerAssignsShortestGalaxyRoute, + AgentTraversesGalaxyRouteBeforeExecutingTask, + IdleAgentReturnsToCanonicalHomeAndDocks, + ControlledShipDoesNotReceiveAutonomousHelmCommands, + AttackAgentControlsOptimumRangeThroughMovementLever, + AttackTaskAdmissionRejectsImpossibleWork, + AgentCompletesAttackTaskThroughTargetFireAndYmir, + AgentCompletesHaulTaskThroughMovementAndCargoCommands, + RejectedHaulTransferDoesNotAdvanceTask, + AgentPatrolsHistoricalOrbitCircuitThroughMovementCommands, + TickReconcilesAndEvaluatesCatalogBehaviors, + DaemonLoadoutsRespectFactionAvailabilityAndHullRoles, + AgentMinesAsteroidThroughEquippedBehavior, + CargoCapacityComesFromHullAndCatalogVolumes, + AgentSurveysBodyIntoCorporationKnowledge, + AgentTowsStationIntoPersistentOrbit + ]; + foreach (var check in checks) + RunCheck(check); + } + + private static AetheriaYmirWorldPhysics NewPhysics() + { + AetheriaYmirWorldPhysics physics = new(); + OwnedPhysics.Add(physics); + return physics; + } + + private static void RunCheck(Action check) + { + try + { + check(); + } + finally + { + foreach (var physics in OwnedPhysics) + physics.Dispose(); + OwnedPhysics.Clear(); + } } private static void PositiveGravityDepthAttractsAndProjectsAsAWell() @@ -209,7 +237,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks GravityTerrainDepth = 5 }; - using var physics = new AetheriaYmirWorldPhysics(); + using var physics = NewPhysics(); physics.RetainWorlds("gravity-sign-smoke", [zone.ZoneIndex]); var step = physics.Step("gravity-sign-smoke", 1, 0, zone, zone.Entities, 0.1); var steppedActor = step.Bodies.Single(value => value.EntityIndex == actor.EntityIndex); @@ -286,7 +314,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks for (var frame = 0; frame < 7; frame++) AetheriaRuntimeDaemonSimulation.Step(run, intents, 0.1, new AetheriaRuntimeDaemonSimulationSettings(), - new AetheriaYmirWorldPhysics(), catalog, frame, frame * 0.1); + NewPhysics(), catalog, frame, frame * 0.1); var state = source.WeaponStates.Single(value => value.BehaviorKind == AetheriaRuntimeBehaviorKinds.ConstantWeapon); Require(run.GameEvents.Count(value => value.Kind == "weapon.firing.started") == 1, @@ -308,10 +336,10 @@ internal sealed class AetheriaDaemonYmirSmokeChecks for (var frame = 7; frame < 11; frame++) AetheriaRuntimeDaemonSimulation.Step(run, intents, 0.1, new AetheriaRuntimeDaemonSimulationSettings(), - new AetheriaYmirWorldPhysics(), catalog, frame, frame * 0.1); + NewPhysics(), catalog, frame, frame * 0.1); AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, new AetheriaRuntimeDaemonSimulationSettings(), - new AetheriaYmirWorldPhysics(), catalog, 11, 1.1); + NewPhysics(), catalog, 11, 1.1); Require(!state.Firing && run.GameEvents.Count(value => value.Kind == "weapon.firing.stopped") == 2, "releasing held fire must stop the persisted constant weapon and publish its transition"); var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build( @@ -365,7 +393,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks }); AetheriaRuntimeDaemonSimulation.Step(run, intents, 0.1, new AetheriaRuntimeDaemonSimulationSettings(), - new AetheriaYmirWorldPhysics(), + NewPhysics(), new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), 0, 0); Require(zone.PhysicalPayloads.Count == 0 && !run.GameEvents.Any(value => value.Kind == "shot.committed"), @@ -376,7 +404,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks for (var frame = 1; frame < 11; frame++) AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, new AetheriaRuntimeDaemonSimulationSettings(), - new AetheriaYmirWorldPhysics(), + NewPhysics(), new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), frame, frame * 0.1); Require(state.Charging && state.Charged && state.Charge >= 1 && state.ChargeHoldSeconds > 0, "one semantic request must precharge without a firing solution and enter persisted hold state"); @@ -385,7 +413,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks source.TargetEntityIndex = target.EntityIndex; AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, new AetheriaRuntimeDaemonSimulationSettings(), - new AetheriaYmirWorldPhysics(), + NewPhysics(), new AetheriaRuntimeCatalogSnapshot([CatalogItem("test-charged", payload)], [], []), 11, 1.1); Require(run.GameEvents.Count(value => value.Kind == "weapon.charge.committed") == 1 && run.GameEvents.Any(value => value.Kind == "shot.committed" && @@ -457,11 +485,11 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonSimulation.Step(run, fire, 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, 0, 0); + NewPhysics(), catalog, 0, 0); for (var frame = 1; frame < 12 && run.ShotReceipts.Count == 0; frame++) AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, frame, frame * 0.1); + NewPhysics(), catalog, frame, frame * 0.1); Require(run.ShotReceipts.Count == 1 && run.ShotReceipts[0].SourceEntityIndex == source.EntityIndex, $"one instant weapon request must remain pending until daemon lock acquisition commits its shot; " + @@ -469,6 +497,21 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var state = source.WeaponStates.Single(value => value.BehaviorKind == AetheriaRuntimeBehaviorKinds.InstantWeapon); Require(!state.TriggerPending, "instant weapon request must clear after the committed burst begins"); + var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build( + new AetheriaRuntimeDaemonFrameDocument { FrameId = 12, Run = run }, + new AetheriaRuntimeDaemonHealthDocument(), + AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon")); + var combat = Flatten(surface.Surface.Root).Single(node => node.Kind == "combat.presentation"); + Require(combat.Props["controlledEntityIndex"] == "0" && + combat.Props["selectedTargetEntityIndex"] == "1" && + combat.Props["targetVisible"] == "true" && + combat.Props["targetHostile"] == "true" && + double.Parse(combat.Props["lockProgress"], CultureInfo.InvariantCulture) > 0.99, + "Eve combat presentation must expose daemon-owned selection, contact, and completed lock without duplicating body transforms"); + Require(combat.Props["hitMarkerDurationSeconds"] == "0.25" && + combat.Props["radialFillMinimum"] == "0.25" && + combat.Props["radialFillMaximum"] == "0.75", + "Eve combat presentation must preserve the fossil's presentation timing and radial meter semantics"); } private static void DeployableWeaponRunsThroughYmirAndDetonatesOnDaemon() @@ -509,7 +552,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonSimulation.Step(run, fire, 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, 1, 0.1); + NewPhysics(), catalog, 1, 0.1); RequireEqual(1, zone.PhysicalPayloads.Count, "deployable fire must create one persistent physical payload"); Require(!run.ShotReceipts.Any(), "deployable fire must not masquerade as an ordinary shot receipt"); var mine = zone.PhysicalPayloads.Single(); @@ -518,7 +561,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, 2, 0.2); + NewPhysics(), catalog, 2, 0.2); mine = zone.PhysicalPayloads.Single(); Require(mine.Stationary && mine.TriggeredAtSeconds >= 0 && run.GameEvents.Count(value => value.Kind == "deployable.triggered") == 1, @@ -526,18 +569,16 @@ internal sealed class AetheriaDaemonYmirSmokeChecks RequireNear(100, Stat(target, "hull"), 0.000001, "trigger contact must not bypass the authored detonation delay"); - var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build( + var objects = AetheriaRuntimeGameDocuments.ObjectsViewport( new AetheriaRuntimeDaemonFrameDocument { FrameId = 2, Run = run }, - new AetheriaRuntimeDaemonHealthDocument(), - AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon")); - var mineNode = Flatten(surface.Surface.Root).Single(node => - node.Id == $"aetheria.daemon.game.world.projectile.{mine.PayloadId}"); - RequireEqual("physical-payload", mineNode.Props["entityKind"], - "Eve must describe the semantic object rather than pretend every payload is a projectile"); - RequireEqual("mine", mineNode.Props["payloadKind"], "Eve must expose deployable kind"); - RequireEqual("true", mineNode.Props["armed"], "Eve must expose daemon-owned arming state"); - RequireEqual("true", mineNode.Props["triggered"], "Eve must expose daemon-owned trigger state"); - RequireEqual("true", mineNode.Props["stationary"], "Eve must expose Ymir-derived motion state"); + new AetheriaRuntimeViewportBounds { MinX = -1000, MinY = -1000, MaxX = 1000, MaxY = 1000 }); + var mineObject = objects.Objects.Single(value => value.EntityKey == mine.PayloadId); + RequireEqual("projectile", mineObject.Kind, + "the viewport projection must expose the retained physical payload without reviving world.scene3d as a transform authority"); + Require(mineObject.IsActive && mineObject.IconAsset != null, + "the viewport projection must expose an active provider-authored presentation for the retained mine body"); + Require(mine.Stationary && mine.TriggeredAtSeconds >= 0, + "daemon state must retain Ymir-derived motion and trigger state independently of presentation"); RequireNear(35, mine.PayloadMagnitude, 0.000001, "deployable must retain authored payload magnitude"); RequireNear(50, mine.BlastRadius, 0.000001, "deployable must retain authored blast radius"); Require(Math.Abs(target.PositionX - mine.PositionX) <= mine.BlastRadius, @@ -545,7 +586,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.21, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, 3, 0.41); + NewPhysics(), catalog, 3, 0.41); RequireEqual(0, zone.PhysicalPayloads.Count, "detonated mine must leave canonical payload state"); RequireNear(65, Stat(target, "hull"), 0.000001, "Aetheria must apply authored blast damage after the delay"); @@ -587,7 +628,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), frameId: 4, + NewPhysics(), frameId: 4, simulationTimeSeconds: 0.1); RequireEqual(0, zone.PhysicalPayloads.Count, @@ -669,7 +710,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AddDetonatingPayload("shielded-blast", 20); AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, 1, 0.1); + NewPhysics(), catalog, 1, 0.1); var capacitor = target.BehaviorStates.Single(value => value.BehaviorKind == "Capacitor"); RequireNear(100, Stat(target, "hull"), 0.000001, "funded shield must intercept damage before hull"); @@ -698,7 +739,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AddDetonatingPayload("unfunded-blast", 20); AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, 2, 0.2); + NewPhysics(), catalog, 2, 0.2); RequireNear(80, Stat(target, "hull"), 0.000001, "unfunded shield must not manufacture absorption"); } @@ -733,7 +774,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, 1, 0.1); + NewPhysics(), catalog, 1, 0.1); var armor = target.StatGrids.Single(value => value.Name == "armor"); RequireNear(0, armor.Values[3], 0.000001, "source-facing splash cells must absorb damage first"); @@ -747,6 +788,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon")); var targetNode = Flatten(surface.Surface.Root).Single(node => node.Id == "aetheria.daemon.game.world.entity.1"); + RequireEqual("entity.presentation", targetNode.Kind, + "Eve semantic entity facts must not become a second body-transform authority"); RequireEqual("30", targetNode.Props["armor"], "Eve world projection must expose aggregate armor as derived presentation state"); RequireEqual("0,5,5,0,5,5,0,5,5", targetNode.Props["armorGrid"], @@ -784,7 +827,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var settings = LootSettings(1); AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, settings, - new AetheriaYmirWorldPhysics(), null, 1, 0.1); + NewPhysics(), null, 1, 0.1); Require(!target.IsActive && target.DestroyedFrameId == 1 && !string.IsNullOrWhiteSpace(target.DestructionId), @@ -809,9 +852,6 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon")); Require(!Flatten(surface.Surface.Root).Any(node => node.Id == "aetheria.daemon.game.world.entity.1"), "Eve must not project a destroyed tombstone as an active world entity"); - RequireEqual(3, Flatten(surface.Surface.Root).Count(node => node.Kind == "world.entity3d" && - node.Props.TryGetValue("entityKind", out var kind) && kind == "pickup"), - "Eve must project every daemon-owned destruction pickup"); var destructionAsset = AetheriaRuntimeAssets.ProjectManifest(null).Assets.Single(value => value.Ref.Metadata.TryGetValue("presentationRole", out var role) && role == "effect.feedback.entity.destroyed"); @@ -819,7 +859,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks "provider must advertise the original destruction effect by semantic feedback role"); AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, settings, - new AetheriaYmirWorldPhysics(), null, 2, 0.2); + NewPhysics(), null, 2, 0.2); RequireEqual(3, zone.DroppedPickups.Count, "later ticks must not duplicate an already committed destruction transaction"); RequireEqual(1, run.GameEvents.Count(value => value.Kind == "entity.destroyed"), @@ -857,7 +897,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks { ActorEntityKey = "zone.0.entity.0", WeaponGroup = 0, Fire = true, Active = true }); AetheriaRuntimeDaemonSimulation.Step(run, intents, 0.1, new AetheriaRuntimeDaemonSimulationSettings(), - new AetheriaYmirWorldPhysics(), catalog, frame, frame * 0.1); + NewPhysics(), catalog, frame, frame * 0.1); } var state = source.WeaponStates.Single(value => value.BehaviorKind == AetheriaRuntimeBehaviorKinds.ChargedWeapon); Require(!state.Charging && !state.Charged && state.CoolingDown && state.ChargeRiskChecks == 1 && @@ -890,12 +930,12 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AgentTasks = [new AetheriaRuntimeAgentTaskCommit { TaskId = "tow-1", CorporationKey = "workers", TaskType = AetheriaRuntimeAgentTaskTypes.Tow, ZoneIndex = 0, Status = AetheriaRuntimeAgentTaskStatuses.Queued, TargetEntityIndex = 1, OrbitParentKey = "parent-body", OrbitDistance = 20, CompletionRadius = 5 }] }; AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-tow-attach-smoke.cc"), run, - new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 1, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 1, BuildPublications = false }); + new AetheriaRuntimeDaemonTickOptions { WorldPhysics = NewPhysics(), FrameId = 1, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 1, BuildPublications = false }); Require(run.Zones[0].Entities[0].ChildEntityIndices.Contains(1), "tow pickup must attach station to tug parentage"); RequireEqual("", run.Zones[0].Entities[1].OrbitKey, "attached station must no longer own an orbit"); AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-tow-detach-smoke.cc"), run, - new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 2, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 2, BuildPublications = false }); + new AetheriaRuntimeDaemonTickOptions { WorldPhysics = NewPhysics(), FrameId = 2, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 2, BuildPublications = false }); Require(!run.Zones[0].Entities[0].ChildEntityIndices.Contains(1), "tow delivery must detach station parentage"); Require(!string.IsNullOrWhiteSpace(run.Zones[0].Entities[1].OrbitKey), "delivered station must own a persistent orbit"); Require(run.Zones[0].Orbits.Any(orbit => orbit.OrbitKey == run.Zones[0].Entities[1].OrbitKey && orbit.ParentOrbitKey == "parent-orbit" && Math.Abs(orbit.Distance - 20) < 0.001), @@ -923,14 +963,14 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AgentTasks = [new AetheriaRuntimeAgentTaskCommit { TaskId = "survey-1", CorporationKey = "workers", TaskType = AetheriaRuntimeAgentTaskTypes.Explore, ZoneIndex = 0, Status = AetheriaRuntimeAgentTaskStatuses.Queued, TargetBodyKeys = ["survey-world"] }] }; AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-survey-smoke.cc"), run, - new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 1, FixedDeltaSeconds = 1, SimulationTimeSeconds = 1, Catalog = catalog, BuildPublications = false }); + new AetheriaRuntimeDaemonTickOptions { WorldPhysics = NewPhysics(), FrameId = 1, FixedDeltaSeconds = 1, SimulationTimeSeconds = 1, Catalog = catalog, BuildPublications = false }); var knowledge = run.CorporationSurveys.Single(); RequireEqual("workers", knowledge.CorporationKey, "survey knowledge must belong to the agent corporation"); RequireEqual("survey-world", knowledge.BodyKey, "survey knowledge must identify the scanned body"); RequireNear(4, knowledge.DensityFloor, 0.000001, "survey must publish the scanner minimum density"); AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-survey-complete-smoke.cc"), run, - new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 2, FixedDeltaSeconds = 1, SimulationTimeSeconds = 2, Catalog = catalog, BuildPublications = false }); + new AetheriaRuntimeDaemonTickOptions { WorldPhysics = NewPhysics(), FrameId = 2, FixedDeltaSeconds = 1, SimulationTimeSeconds = 2, Catalog = catalog, BuildPublications = false }); RequireEqual(AetheriaRuntimeAgentTaskStatuses.Completed, run.AgentTasks[0].Status, "survey order must complete when corporation knowledge satisfies the scanner threshold"); } @@ -941,12 +981,19 @@ internal sealed class AetheriaDaemonYmirSmokeChecks hull.HullCapacity = PerformanceStat(20); var gear = CatalogItem("scanner"); gear.Volume = 3; + var cargoBay = CatalogItem("hauler-cargo"); + cargoBay.Volume = 0; + cargoBay.InteriorOccupiedCells = 16; var ore = CatalogItem("ore"); ore.Volume = 2; - var catalog = new AetheriaRuntimeCatalogSnapshot([hull, gear, ore], [], []); + var catalog = new AetheriaRuntimeCatalogSnapshot([hull, gear, cargoBay, ore], [], []); var entity = Entity(0, 0, "workers"); entity.HullItemKey = hull.ItemKey; - entity.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = gear.ItemKey } }]; + entity.Equipment = + [ + new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = gear.ItemKey } }, + new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = cargoBay.ItemKey } } + ]; entity.CargoContents = [new AetheriaRuntimeCargoBayLoadoutCommit { Items = [new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = ore.ItemKey, Quantity = 4 } }] }]; RequireNear(20, AetheriaRuntimeCargoCapacityQueries.Capacity(entity, catalog), 0.000001, @@ -954,7 +1001,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks RequireNear(11, AetheriaRuntimeCargoCapacityQueries.Occupied(entity, catalog), 0.000001, "equipment and stacked cargo must consume catalog volume"); RequireEqual(4, AetheriaRuntimeCargoCapacityQueries.UnitsThatFit(entity, catalog, ore.ItemKey), - "available cargo volume must determine whole units that fit"); + "the installed cargo bay's remaining volume must determine whole units that fit"); } private static void AgentMinesAsteroidThroughEquippedBehavior() @@ -962,20 +1009,32 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var miner = Entity(0, 0, "workers"); var home = Entity(1, 0, "workers"); miner.AgentTaskCapabilities = [AetheriaRuntimeAgentTaskTypes.Mine]; - miner.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "mining-tool", Enabled = true, Quality = 1, Durability = 1 } }]; + miner.Equipment = + [ + new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "mining-tool", Enabled = true, Quality = 1, Durability = 1 } }, + new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "miner-cargo", Enabled = true, Quality = 1, Durability = 1 } } + ]; + home.Equipment = + [ + new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "home-cargo", Enabled = true, Quality = 1, Durability = 1 } } + ]; var minerHull = CatalogItem("miner-hull"); - minerHull.HullCapacity = PerformanceStat(2); + minerHull.HullCapacity = PerformanceStat(3); var homeHull = CatalogItem("home-hull"); homeHull.HullCapacity = PerformanceStat(100); var iron = CatalogItem("iron"); iron.SimpleCommodityCategory = "ore"; iron.Volume = 1; + var minerCargo = CatalogItem("miner-cargo"); + minerCargo.InteriorOccupiedCells = 2; + var homeCargo = CatalogItem("home-cargo"); + homeCargo.InteriorOccupiedCells = 100; miner.HullItemKey = minerHull.ItemKey; home.HullItemKey = homeHull.ItemKey; miner.CargoContents = [new AetheriaRuntimeCargoBayLoadoutCommit()]; home.CargoContents = [new AetheriaRuntimeCargoBayLoadoutCommit()]; var catalog = new AetheriaRuntimeCatalogSnapshot( - [minerHull, homeHull, iron, CatalogItem("mining-tool", new AetheriaRuntimeBehaviorPayload(0, "MiningTool", 0, + [minerHull, homeHull, iron, minerCargo, homeCargo, CatalogItem("mining-tool", new AetheriaRuntimeBehaviorPayload(0, "MiningTool", 0, [new AetheriaRuntimeBehaviorField(1, PerformanceStat(1000)), new AetheriaRuntimeBehaviorField(2, PerformanceStat(1000000000)), new AetheriaRuntimeBehaviorField(3, PerformanceStat(2)), new AetheriaRuntimeBehaviorField(4, PerformanceStat(1000))]))], [], []); var asteroid = new AetheriaRuntimeAsteroidCommit { Distance = 0, Size = 6 }; @@ -995,11 +1054,11 @@ internal sealed class AetheriaDaemonYmirSmokeChecks }; var result = AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-mining-smoke.cc"), run, - new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 1, FixedDeltaSeconds = 1, SimulationTimeSeconds = 1, Catalog = catalog, BuildPublications = false }); + new AetheriaRuntimeDaemonTickOptions { WorldPhysics = NewPhysics(), FrameId = 1, FixedDeltaSeconds = 1, SimulationTimeSeconds = 1, Catalog = catalog, BuildPublications = false }); Require(run.AgentTasks[0].Phase == "mining", "mining task must activate its equipped tool"); Require(result.OperationResult.Intents.Behaviors.Count == 1, - $"mining behavior command must become daemon intent (applied={string.Join(',', result.Frame.AppliedCommandIds)}, rejected={string.Join(',', result.Frame.RejectedCommandIds)})"); + $"mining behavior command must become daemon intent (count={result.OperationResult.Intents.Behaviors.Count}, applied={string.Join(',', result.Frame.AppliedCommandIds)}, rejected={string.Join(',', result.Frame.RejectedCommandIds)})"); var committedMiner = run.Zones[0].Entities.Single(entity => entity.EntityIndex == 0); var committedAsteroid = run.Zones[0].Bodies[0].Asteroids[0]; Require(committedAsteroid.RespawnTimer > 0, $"mining damage must deplete the asteroid and start historical respawn (damage={committedAsteroid.Damage}, respawn={committedAsteroid.RespawnTimer})"); @@ -1007,7 +1066,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks "historical mining yield must enter daemon-owned cargo"); AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-mining-offload-smoke.cc"), run, - new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 2, FixedDeltaSeconds = 1, SimulationTimeSeconds = 2, Catalog = catalog, BuildPublications = false }); + new AetheriaRuntimeDaemonTickOptions { WorldPhysics = NewPhysics(), FrameId = 2, FixedDeltaSeconds = 1, SimulationTimeSeconds = 2, Catalog = catalog, BuildPublications = false }); Require(!run.Zones[0].Entities[0].CargoContents.SelectMany(bay => bay.Items).Any(), "full miner must offload through the shared cargo transfer command"); Require(run.Zones[0].Entities[1].CargoContents.SelectMany(bay => bay.Items).Any(slot => slot.Item.ItemKey == "iron" && slot.Item.Quantity == 1), @@ -1060,7 +1119,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), + WorldPhysics = NewPhysics(), FrameId = 1, FixedDeltaSeconds = 0, Catalog = catalog, @@ -1329,7 +1388,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), + WorldPhysics = NewPhysics(), FrameId = frame, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = frame * 0.1, @@ -1438,7 +1497,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), + WorldPhysics = NewPhysics(), FrameId = frame, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = frame * 0.1, @@ -1563,6 +1622,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var sawTargetCommand = false; var sawFireCommand = false; var sawPartialLock = false; + var lockTrace = new List(); + var attackTrace = new List(); var firstLaunchFrame = -1; for (var frame = 0; frame < 60; frame++) { @@ -1571,7 +1632,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), + WorldPhysics = NewPhysics(), FrameId = frame, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = frame * 0.1, @@ -1583,6 +1644,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks sawFireCommand |= tick.OperationResult.AppliedCommandIds.Any(id => id.EndsWith(":fire", StringComparison.Ordinal)); var weapon = (agent.WeaponStates ?? Array.Empty()) .Single(value => value.OwnerKind == AetheriaRuntimeBehaviorStateProjector.EquipmentOwnerKind); + lockTrace.Add(weapon.LockProgress); + attackTrace.Add($"{frame}:{agent.TargetEntityIndex}:{agent.PositionX:0.##},{agent.PositionZ:0.##}:{agent.DirectionX:0.##},{agent.DirectionY:0.##}:{weapon.LockTargetEntityIndex}"); sawPartialLock |= weapon.LockProgress > 0 && weapon.LockProgress < 0.99; if (firstLaunchFrame < 0 && run.GameEvents.Any(value => value.Kind == "shot.committed")) firstLaunchFrame = frame; @@ -1592,7 +1655,8 @@ internal sealed class AetheriaDaemonYmirSmokeChecks Require(sawTargetCommand, "attack agent must target through the shared target command"); Require(sawFireCommand, "attack agent must fire through the shared weapon-group command"); - Require(sawPartialLock, "attack agent must acquire a persisted partial weapon lock before firing"); + Require(sawPartialLock, + $"attack agent must acquire a persisted partial weapon lock before firing; locks={string.Join(',', lockTrace.Select(value => value.ToString("0.###", CultureInfo.InvariantCulture)))} states={string.Join('|', attackTrace)}"); Require(firstLaunchFrame > 1, "accepted fire intent must not bypass progressive weapon lock acquisition"); Require(run.GameEvents.Any(value => value.Kind == "shot.committed" && value.SourceEntityIndex == agent.EntityIndex), "accepted fire control must emit authoritative shot commitment chronology"); @@ -1836,8 +1900,10 @@ internal sealed class AetheriaDaemonYmirSmokeChecks private static void SchedulerAssignsShortestGalaxyRoute() { var distant = Entity(0, 0, "workers"); + distant.EntityId = "worker.route.distant"; distant.AgentTaskCapabilities = [AetheriaRuntimeAgentTaskTypes.Explore]; var nearby = Entity(0, 0, "workers"); + nearby.EntityId = "worker.route.nearby"; nearby.AgentTaskCapabilities = [AetheriaRuntimeAgentTaskTypes.Explore]; var task = AgentTask("route-choice", 10); task.ZoneIndex = 2; @@ -1890,7 +1956,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), + WorldPhysics = NewPhysics(), FrameId = frame, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = frame * 0.1, @@ -1944,7 +2010,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), + WorldPhysics = NewPhysics(), FrameId = frame, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = frame * 0.1, @@ -1973,7 +2039,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 41, + WorldPhysics = NewPhysics(), FrameId = 41, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 4.1, BuildPublications = false }); Require(!settled.OperationResult.AppliedCommandIds.Any(id => id.Contains(":home-", StringComparison.Ordinal)), @@ -2044,7 +2110,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks run, new AetheriaRuntimeDaemonTickOptions { - WorldPhysics = new AetheriaYmirWorldPhysics(), + WorldPhysics = NewPhysics(), FrameId = frame, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = frame * 0.1, @@ -2100,6 +2166,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks { var player = Entity(0, 0, "player"); var agent = Entity(1, 0, "worker"); + player.TargetEntityIndex = agent.EntityIndex; var run = new AetheriaRuntimeRunCheckpointCommit { RunId = "shared-lever-smoke", @@ -2120,11 +2187,23 @@ internal sealed class AetheriaDaemonYmirSmokeChecks operation.Intents, 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics()); + NewPhysics()); Require(player.VelocityX > 0 && Math.Abs(player.VelocityY) < 0.001, "player command must drive its actor through the shared movement lever"); Require(agent.VelocityY > 0 && Math.Abs(agent.VelocityX) < 0.001, "agent command must drive its actor through the shared movement lever"); + + var release = MovementCommand("player-release", "zone.0.entity.0", 0, 0); + release.ScalarValue = 0; + var releaseOperation = AetheriaRuntimeDaemonOperations.Execute(run, [release]); + AetheriaRuntimeDaemonSimulation.Step( + run, + releaseOperation.Intents, + 0.1, + AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, + NewPhysics()); + RequireEqual(agent.EntityIndex, player.TargetEntityIndex, + "releasing the movement lever must not steal targeting authority"); } private static AetheriaRuntimeDaemonCommandDocument MovementCommand( @@ -2454,7 +2533,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics(), catalog, frameId: 17); + NewPhysics(), catalog, frameId: 17); RequireEqual("heatstroke", entity.CauseOfDeath, "lethal cockpit heat must persist the typed cause of death"); @@ -2513,7 +2592,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks private static void YmirMovesProjectileAndReportsStableContact() { var (run, zone, target) = Scenario(); - using var physics = new AetheriaYmirWorldPhysics(); + using var physics = NewPhysics(); physics.RetainWorlds(run.RunId, [zone.ZoneIndex]); physics.Step(run.RunId, 0, 0, zone, zone.Entities, 0.1); var step = physics.StepPhysicalPayloads(run.RunId, 0, 0, zone, zone.Entities, 0.1); @@ -2548,7 +2627,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks } ] }; - using var physics = new AetheriaYmirWorldPhysics(); + using var physics = NewPhysics(); physics.RetainWorlds("source-exclusion-smoke", [zone.ZoneIndex]); physics.Step("source-exclusion-smoke", 1, 0, zone, zone.Entities, 0.1); var step = physics.StepPhysicalPayloads("source-exclusion-smoke", 1, 0, zone, zone.Entities, 0.1); @@ -2587,7 +2666,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks } ] }; - using var physics = new AetheriaYmirWorldPhysics(); + using var physics = NewPhysics(); physics.RetainWorlds("payload-isolation-smoke", [zone.ZoneIndex]); physics.Step("payload-isolation-smoke", 2, 0, zone, zone.Entities, 0.1); var step = physics.StepPhysicalPayloads("payload-isolation-smoke", 2, 0, zone, zone.Entities, 0.1); @@ -2623,7 +2702,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks Entities = [target], PhysicalPayloads = [mine] }; - using var physics = new AetheriaYmirWorldPhysics(); + using var physics = NewPhysics(); physics.RetainWorlds("mine-arming-overlap-smoke", [zone.ZoneIndex]); physics.Step("mine-arming-overlap-smoke", 1, 0, zone, zone.Entities, 0.5); var unarmed = physics.StepPhysicalPayloads("mine-arming-overlap-smoke", 1, 0, zone, zone.Entities, 0.5); @@ -2649,7 +2728,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks new AetheriaRuntimeDaemonIntentState(), 0.1, AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, - new AetheriaYmirWorldPhysics()); + NewPhysics()); RequireEqual(100.0, Stat(target, "hull"), "presentation projectile contact must not write combat damage"); RequireEqual(0, run.Zones[0].PhysicalPayloads.Count, "spent projectile must leave daemon state"); @@ -2670,7 +2749,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var (run, _, target) = Scenario(); target.StatGrids.Single(grid => grid.Name == "hull").Values = [5]; AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, - AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, new AetheriaYmirWorldPhysics(), frameId: 9); + AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault, NewPhysics(), frameId: 9); Require(target.IsActive && Math.Abs(Stat(target, "hull") - 5) < 0.000001, "even nominally lethal presentation contact must leave canonical target state untouched"); RequireEqual(0, run.GameEvents.Count(value => value.Kind == "entity.destroyed" && value.TargetEntityIndex == target.EntityIndex), @@ -2704,18 +2783,13 @@ internal sealed class AetheriaDaemonYmirSmokeChecks var command = AetheriaRuntimeDaemonCommandDocument.Create(AetheriaRuntimeDaemonCommandKinds.SetTractorPower, "pilot", "tractor-smoke", 0, "zone.0.entity.0"); command.CommandId = "tractor-on"; command.ScalarValue = 1; AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-tractor-smoke.cc"), run, - new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 1, FixedDeltaSeconds = 0.25, SimulationTimeSeconds = 0.25, ObservedCommands = [command], BuildPublications = false }); + new AetheriaRuntimeDaemonTickOptions { WorldPhysics = NewPhysics(), FrameId = 1, FixedDeltaSeconds = 0.25, SimulationTimeSeconds = 0.25, ObservedCommands = [command], BuildPublications = false }); RequireNear(0.5, ship.TractorPower, 0.000001, "tractor power must use the fossil two-per-second ramp"); Require(pickup.VelocityX < 0 && pickup.PositionX < 60, "Ymir must pull a pickup inside the forward tractor volume toward the ship"); RequireEqual(1, pickup.Item.Quantity, "tractor force must not consume the pickup item"); RequireEqual(0, CargoQuantity(ship, "salvage"), "scooping must remain a separate capacity-checked transaction"); - var frame = new AetheriaRuntimeDaemonFrameDocument { FrameId = 1, Run = run }; - var surface = AetheriaRuntimeDaemonGameSurfaceBuilder.Build(frame, new AetheriaRuntimeDaemonHealthDocument(), AetheriaRuntimeDaemonCommandBoundaryDocument.Create("daemon")); - var pickupNode = Flatten(surface.Surface.Root).Single(node => node.Id == "aetheria.daemon.game.world.pickup.3"); - RequireEqual("prefab.entity.pickup", pickupNode.Props["assetRef"], "Eve world must reference provider-owned pickup asset semantics"); - RequireEqual("salvage", pickupNode.Props["itemKey"], "Eve pickup must expose item identity"); - Require(double.Parse(pickupNode.Props["remainingLifetime"], CultureInfo.InvariantCulture) < 30, - "Eve pickup must expose daemon-owned remaining lifetime"); + Require(pickup.AgeSeconds > 0 && pickup.AgeSeconds < pickup.LifetimeSeconds, + "daemon-owned pickup lifetime must advance independently of its SoA presentation"); var pickupAsset = AetheriaRuntimeAssets.ProjectManifest(null).Assets.Single(asset => asset.Ref.AssetKey == "prefab.entity.pickup"); Require(pickupAsset.Ref.Metadata.TryGetValue("unityAssetPath", out var pickupPath) && pickupPath == "Assets/Prefabs/RPG/Pickups/Tetrahedron.prefab", "provider asset manifest must advertise the pickup visual used by Eve"); @@ -2797,7 +2871,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks return new AetheriaRuntimeRunCheckpointCommit { CurrentZoneIndex = 0, CurrentEntityKey = "zone.0.entity.0", Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [ship], DroppedPickups = [new AetheriaRuntimeDroppedPickupCommit { PickupIndex = 10, PositionX = 20, Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = salvage.ItemKey, Quantity = 1 }, LifetimeSeconds = 30 }] }] }; } var open = Scenario(false); - using var openPhysics = new AetheriaYmirWorldPhysics(); + using var openPhysics = NewPhysics(); AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-pickup-contact-open.cc"), open, new AetheriaRuntimeDaemonTickOptions { WorldPhysics = openPhysics, FrameId = 1, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 0.1, Catalog = catalog, BuildPublications = false }); RequireEqual(0, open.Zones[0].DroppedPickups.Count, "shield contact with capacity must collect pickup automatically"); @@ -2808,7 +2882,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks "a real Box3D Begin fact must persist one cargo-consumption receipt"); var full = Scenario(true); - using var fullPhysics = new AetheriaYmirWorldPhysics(); + using var fullPhysics = NewPhysics(); AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-pickup-contact-full.cc"), full, new AetheriaRuntimeDaemonTickOptions { WorldPhysics = fullPhysics, FrameId = 1, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 0.1, Catalog = catalog, BuildPublications = false }); RequireEqual(1, full.Zones[0].DroppedPickups.Count, "full hold must leave contacted pickup alive"); diff --git a/Aetheria.State.Daemon/AetheriaYmirWorldPhysics.cs b/Aetheria.State.Daemon/AetheriaYmirWorldPhysics.cs index e0e1320a8..691ef6074 100644 --- a/Aetheria.State.Daemon/AetheriaYmirWorldPhysics.cs +++ b/Aetheria.State.Daemon/AetheriaYmirWorldPhysics.cs @@ -25,7 +25,7 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi .ToArray()) { _sessions[key].WorldSession.Dispose(); - _sessions[key].PayloadSession.Dispose(); + _sessions[key].PayloadSession?.Dispose(); _sessions.Remove(key); } } @@ -142,16 +142,20 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi if (deltaSeconds <= 0) throw new ArgumentOutOfRangeException(nameof(deltaSeconds)); + var payloadSession = state.PayloadSession ??= YmirSession.Create(new YmirSessionCreateRequest( + $"aetheria.run.{runId}.zone.{zone.ZoneIndex}.payloads", + [], + (float)zone.SimulationTimeSeconds)); var payloads = (zone.PhysicalPayloads ?? Array.Empty()) .Where(payload => payload != null && payload.Active) .OrderBy(payload => payload.PayloadId, StringComparer.Ordinal) .ToArray(); var desiredBodies = payloads.Select(PayloadBody).ToArray(); var commandOrdinal = 0; - Reconcile(state.PayloadSession, desiredBodies, frameId, simulationStepIndex, ref commandOrdinal); - var starts = state.PayloadSession.Snapshot().Bodies.ToDictionary(body => body.Id, StringComparer.Ordinal); - var stepped = state.PayloadSession.Step(new YmirStepSessionCommand( - Header(state.PayloadSession, frameId, simulationStepIndex, "step", "payloads", ref commandOrdinal), + Reconcile(payloadSession, desiredBodies, frameId, simulationStepIndex, ref commandOrdinal); + var starts = payloadSession.Snapshot().Bodies.ToDictionary(body => body.Id, StringComparer.Ordinal); + var stepped = payloadSession.Step(new YmirStepSessionCommand( + Header(payloadSession, frameId, simulationStepIndex, "step", "payloads", ref commandOrdinal), (float)deltaSeconds, [])); var moved = stepped.World.Bodies.ToDictionary(body => body.Id, StringComparer.Ordinal); @@ -236,8 +240,8 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi payload.VelocityX = 0; payload.VelocityY = 0; if (!body.IsStatic) - RequireAccepted(state.PayloadSession.SetVelocity(new YmirSetBodyVelocityCommand( - Header(state.PayloadSession, frameId, simulationStepIndex, "stop", payload.PayloadId, ref commandOrdinal), + RequireAccepted(payloadSession.SetVelocity(new YmirSetBodyVelocityCommand( + Header(payloadSession, frameId, simulationStepIndex, "stop", payload.PayloadId, ref commandOrdinal), payloadBodyId, Vec2.Zero, 0))); @@ -245,8 +249,8 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi } else { - RequireAccepted(state.PayloadSession.Remove(new YmirRemoveBodyCommand( - Header(state.PayloadSession, frameId, simulationStepIndex, "remove-hit", payload.PayloadId, ref commandOrdinal), + RequireAccepted(payloadSession.Remove(new YmirRemoveBodyCommand( + Header(payloadSession, frameId, simulationStepIndex, "remove-hit", payload.PayloadId, ref commandOrdinal), payloadBodyId))); } } @@ -263,7 +267,7 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi foreach (var state in _sessions.Values) { state.WorldSession.Dispose(); - state.PayloadSession.Dispose(); + state.PayloadSession?.Dispose(); } _sessions.Clear(); } @@ -274,15 +278,10 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi IReadOnlyList bodies) { var sessionId = $"aetheria.run.{key.RunId}.zone.{key.ZoneIndex}"; - return new SessionState( - YmirSession.Create(new YmirSessionCreateRequest( - sessionId + ".world", - bodies, - (float)zone.SimulationTimeSeconds)), - YmirSession.Create(new YmirSessionCreateRequest( - sessionId + ".payloads", - [], - (float)zone.SimulationTimeSeconds))); + return new SessionState(YmirSession.Create(new YmirSessionCreateRequest( + sessionId + ".world", + bodies, + (float)zone.SimulationTimeSeconds))); } private static void Reconcile( @@ -534,10 +533,10 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi return length <= 0.001 ? (fallbackX, fallbackY) : (x / length, y / length); } - private sealed class SessionState(YmirSession worldSession, YmirSession payloadSession) + private sealed class SessionState(YmirSession worldSession) { public YmirSession WorldSession { get; } = worldSession; - public YmirSession PayloadSession { get; } = payloadSession; + public YmirSession? PayloadSession { get; set; } public long LastFrameId { get; set; } = -1; public int LastSimulationStepIndex { get; set; } = -1; public AetheriaRuntimeWorldStep? LastResult { get; set; } diff --git a/Aetheria.Unity/Packages/manifest.json b/Aetheria.Unity/Packages/manifest.json index d27941798..4bd67cfe3 100644 --- a/Aetheria.Unity/Packages/manifest.json +++ b/Aetheria.Unity/Packages/manifest.json @@ -9,6 +9,6 @@ "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.13", "org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1", "org.gamecult.eve.surface": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.surface#eveunity-surface-v0.2.1", - "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.18" + "org.gamecult.eve.unity-scene": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.19" } } diff --git a/Aetheria.Unity/Packages/packages-lock.json b/Aetheria.Unity/Packages/packages-lock.json index c2d9eec61..b6b2a96ec 100644 --- a/Aetheria.Unity/Packages/packages-lock.json +++ b/Aetheria.Unity/Packages/packages-lock.json @@ -142,7 +142,7 @@ "hash": "d0aa50d31f3b6da96bffc194fdc3aa358f37e332" }, "org.gamecult.eve.unity-scene": { - "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.18", + "version": "https://github.com/GameCult/EveUnity.git?path=/packages/org.gamecult.eve.unity-scene#eveunity-scene-v0.3.19", "depth": 0, "source": "git", "dependencies": { @@ -151,7 +151,7 @@ "org.gamecult.eve.surface": "0.2.1", "com.unity.mathematics": "1.3.2" }, - "hash": "ed21479e467faea8ff624f2d2f5a7d2fecf913f4" + "hash": "d9b762f429056676877d00955dc617e4d423b429" }, "com.unity.modules.assetbundle": { "version": "1.0.0", diff --git a/Packages/manifest.json b/Packages/manifest.json index 3877c8826..22a6a0389 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -21,7 +21,7 @@ "org.gamecult.aetheria.eve-runtime": "file:org.gamecult.aetheria.eve-runtime", "org.gamecult.aetheria.state": "file:org.gamecult.aetheria.state", "org.gamecult.cultmath": "file:../../CultMath", - "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.10", + "org.gamecult.cultlib": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.13", "org.gamecult.eve.surface": "file:../../EveUnity/packages/org.gamecult.eve.surface", "org.gamecult.eve.plugin-fields": "https://github.com/GameCult/EvePlugins.git?path=/plugins/eve-plugin-fields/unity/org.gamecult.eve.plugin-fields#eve-plugin-fields-unity-v0.1.1", "org.gamecult.eve.unity-scene": "file:../../EveUnity/packages/org.gamecult.eve.unity-scene", diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs index 8578233ce..b559abc7d 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonGameSurfaceBuilder.cs @@ -609,11 +609,19 @@ namespace GameCult.Aetheria.State.Verse ["runId"] = run.RunId ?? "" }; + var presentationChildren = (zone.Entities ?? Array.Empty()) + .Where(entity => entity != null && entity.IsActive) + .Select(entity => PlayableEntityPresentation(entity, run, zone, currentEntityKey, simulationSettings)) + .ToList(); + var combatPresentation = CombatPresentation(run, zone, playerEntityId, simulationSettings); + if (combatPresentation != null) + presentationChildren.Insert(0, combatPresentation); + return new AetheriaRuntimeSurfaceComponent( id, "world.scene3d", props, - Array.Empty(), + presentationChildren, AetheriaRuntimeSurfaceStateBindings.FromProps(props), Array.Empty(), Layout( @@ -630,7 +638,59 @@ namespace GameCult.Aetheria.State.Verse }); } - private static AetheriaRuntimeSurfaceComponent PlayableWorldEntity( + private static AetheriaRuntimeSurfaceComponent? CombatPresentation( + AetheriaRuntimeRunCheckpointCommit run, + AetheriaRuntimeZoneSnapshotCommit zone, + string playerEntityId, + AetheriaRuntimeDaemonSimulationSettings simulationSettings) + { + var player = FindCurrentEntity(run, zone); + if (player == null) + return null; + + var target = FindTargetEntity(zone, player); + var targetEntityId = target == null + ? "" + : run.EntityRecordKey(zone.ZoneIndex, target.EntityIndex); + var contact = target == null + ? null + : (player.Contacts ?? Array.Empty()) + .FirstOrDefault(value => value != null && value.TargetEntityIndex == target.EntityIndex); + var lockProgress = target == null + ? 0 + : (player.WeaponStates ?? Array.Empty()) + .Where(value => value != null && value.LockTargetEntityIndex == target.EntityIndex) + .Select(value => value.LockProgress) + .DefaultIfEmpty(0) + .Max(); + var shield = target == null ? 0 : EntityStat(target, "shield"); + var hull = target == null ? 0 : EntityStat(target, "hull"); + var props = new Dictionary(StringComparer.Ordinal) + { + ["controlledEntityId"] = playerEntityId, + ["controlledEntityIndex"] = player.EntityIndex.ToString(CultureInfo.InvariantCulture), + ["selectedTargetEntityId"] = targetEntityId, + ["selectedTargetEntityIndex"] = (target?.EntityIndex ?? -1).ToString(CultureInfo.InvariantCulture), + ["targetVisible"] = contact?.Visible == true ? "true" : "false", + ["targetHostile"] = contact?.Hostile == true ? "true" : "false", + ["contactInformation"] = FormatNumber(contact?.InfoGathered ?? 0), + ["shieldRatio"] = FormatRatio(shield, target == null ? 0 : MaximumShield(target, simulationSettings)), + ["hullRatio"] = FormatRatio(hull, target == null ? 0 : MaximumHull(target, simulationSettings)), + ["lockProgress"] = FormatNumber(lockProgress), + ["reticleRole"] = "combat.reticle.selected", + ["lockRole"] = "combat.reticle.lock", + ["shieldMeterRole"] = "combat.meter.shield", + ["hullMeterRole"] = "combat.meter.hull", + ["hitMarkerRole"] = "combat.marker.hit", + ["lockDisplayThreshold"] = "0.01", + ["hitMarkerDurationSeconds"] = "0.25", + ["radialFillMinimum"] = "0.25", + ["radialFillMaximum"] = "0.75" + }; + return Node("aetheria.daemon.game.world.combat", "combat.presentation", props.Select(value => (value.Key, value.Value)).ToArray()); + } + + private static AetheriaRuntimeSurfaceComponent PlayableEntityPresentation( AetheriaRuntimeEntitySnapshotCommit entity, AetheriaRuntimeRunCheckpointCommit run, AetheriaRuntimeZoneSnapshotCommit zone, @@ -694,9 +754,6 @@ namespace GameCult.Aetheria.State.Verse ["agentCapabilities"] = string.Join(",", entity.AgentTaskCapabilities ?? Array.Empty()), ["assignedTaskId"] = entity.AssignedAgentTaskId ?? "", ["assetRef"] = PlayableWorldAssetRef(entity), - ["position"] = FormatPosition(entity), - ["rotationY"] = HeadingYaw(entity).ToString("0.###", CultureInfo.InvariantCulture), - ["radius"] = PlayableWorldRadius(entity).ToString("0.###", CultureInfo.InvariantCulture), ["hull"] = FormatNumber(hull), ["maximumHull"] = FormatNumber(maximumHull), ["hullRatio"] = FormatRatio(hull, maximumHull), @@ -748,7 +805,7 @@ namespace GameCult.Aetheria.State.Verse }; return new AetheriaRuntimeSurfaceComponent( $"aetheria.daemon.game.world.entity.{entity.EntityIndex}", - "world.entity3d", + "entity.presentation", props, string.Equals(entityId, playerEntityId, StringComparison.Ordinal) ? WeaponStateItems(entity, run, zone) @@ -805,122 +862,9 @@ namespace GameCult.Aetheria.State.Verse .ToArray(); } - private static AetheriaRuntimeSurfaceComponent PlayableWorldProjectile( - AetheriaRuntimePhysicalPayloadCommit projectile, - AetheriaRuntimeRunCheckpointCommit run, - AetheriaRuntimeZoneSnapshotCommit zone) - { - var projectileId = $"{run.RunId}:zone:{zone.ZoneIndex}:physical-payload:{projectile.PayloadId}"; - var targetEntityId = projectile.TargetEntityIndex < 0 - ? "" - : run.EntityRecordKey(zone.ZoneIndex, projectile.TargetEntityIndex); - var props = new Dictionary(StringComparer.Ordinal) - { - ["entityId"] = projectileId, - ["entityKind"] = "physical-payload", - ["payloadKind"] = projectile.PayloadKind ?? "", - ["label"] = projectile.PayloadKind ?? "Projectile", - ["faction"] = "", - ["assetRef"] = string.Equals(projectile.PayloadKind, "mine", StringComparison.Ordinal) - ? "prefab.entity.mine" - : "prefab.entity.projectile", - ["position"] = string.Join(",", new[] - { - projectile.PositionX.ToString("0.###", CultureInfo.InvariantCulture), - "0", - projectile.PositionZ.ToString("0.###", CultureInfo.InvariantCulture) - }), - ["rotationY"] = HeadingDegrees(projectile.VelocityX, projectile.VelocityY).ToString("0.###", CultureInfo.InvariantCulture), - ["radius"] = Math.Max(0.01, projectile.Radius).ToString("0.###", CultureInfo.InvariantCulture), - ["sourceEntityId"] = run.EntityRecordKey(zone.ZoneIndex, projectile.SourceEntityIndex), - ["targetEntityId"] = targetEntityId, - ["contactMagnitude"] = FormatNumber(projectile.ContactMagnitude), - ["age"] = FormatNumber(projectile.AgeSeconds), - ["remainingLifetime"] = FormatNumber(Math.Max(0, projectile.LifetimeSeconds - projectile.AgeSeconds)), - ["activationDelay"] = FormatNumber(projectile.ActivationDelaySeconds), - ["armed"] = projectile.AgeSeconds >= projectile.ActivationDelaySeconds ? "true" : "false", - ["triggerRadius"] = FormatNumber(projectile.TriggerRadius), - ["triggered"] = projectile.TriggeredAtSeconds >= 0 ? "true" : "false", - ["triggeredAt"] = FormatNumber(projectile.TriggeredAtSeconds), - ["detonationDelay"] = FormatNumber(projectile.DetonationDelaySeconds), - ["blastRadius"] = FormatNumber(projectile.BlastRadius), - ["payloadMagnitude"] = FormatNumber(projectile.PayloadMagnitude), - ["stationary"] = projectile.Stationary ? "true" : "false", - ["maximumSourceDistance"] = FormatNumber(projectile.MaximumSourceDistance), - ["weaponItemKey"] = projectile.WeaponItemKey ?? "", - ["triggerReason"] = projectile.TriggerReason ?? "", - ["presentationState"] = projectile.TriggeredAtSeconds >= 0 - ? "triggered" - : projectile.AgeSeconds >= projectile.ActivationDelaySeconds ? "active" : "deploying", - ["activePulseSeconds"] = "1", - ["triggeredPulseSeconds"] = "0.25", - ["activeEmission"] = "100", - ["triggeredEmission"] = "1000", - ["selectable"] = "false", - ["controllable"] = "false" - }; - return new AetheriaRuntimeSurfaceComponent( - $"aetheria.daemon.game.world.projectile.{projectile.PayloadId}", - "world.entity3d", - props, - Array.Empty()); - } - - private static AetheriaRuntimeSurfaceComponent PlayableWorldPickup( - AetheriaRuntimeDroppedPickupCommit pickup, - AetheriaRuntimeRunCheckpointCommit run, - AetheriaRuntimeZoneSnapshotCommit zone) - { - var pickupId = $"{run.RunId}:zone:{zone.ZoneIndex}:pickup:{pickup.PickupIndex}"; - var props = new Dictionary(StringComparer.Ordinal) - { - ["entityId"] = pickupId, - ["entityKind"] = "pickup", - ["label"] = pickup.Item?.ItemKey ?? "Pickup", - ["itemKey"] = pickup.Item?.ItemKey ?? "", - ["quantity"] = Math.Max(1, pickup.Item?.Quantity ?? 1).ToString(CultureInfo.InvariantCulture), - ["assetRef"] = "prefab.entity.pickup", - ["position"] = string.Join(",", new[] { pickup.PositionX.ToString("0.###", CultureInfo.InvariantCulture), pickup.PositionY.ToString("0.###", CultureInfo.InvariantCulture), pickup.PositionZ.ToString("0.###", CultureInfo.InvariantCulture) }), - ["velocity"] = string.Join(",", new[] { pickup.VelocityX.ToString("0.###", CultureInfo.InvariantCulture), pickup.VelocityY.ToString("0.###", CultureInfo.InvariantCulture), pickup.VelocityZ.ToString("0.###", CultureInfo.InvariantCulture) }), - ["radius"] = "5", - ["age"] = FormatNumber(pickup.AgeSeconds), - ["lifetime"] = FormatNumber(pickup.LifetimeSeconds), - ["remainingLifetime"] = FormatNumber(Math.Max(0, pickup.LifetimeSeconds - pickup.AgeSeconds)), - ["selectable"] = "false", - ["controllable"] = "false" - }; - return new AetheriaRuntimeSurfaceComponent( - $"aetheria.daemon.game.world.pickup.{pickup.PickupIndex}", - "world.entity3d", - props, - Array.Empty()); - } - private static string PlayableWorldAssetRef(AetheriaRuntimeEntitySnapshotCommit entity) => AetheriaRuntimeAssets.ResolveEntityPrefabAssetRef(entity); - private static double PlayableWorldRadius(AetheriaRuntimeEntitySnapshotCommit entity) - { - var kind = (entity.Kind ?? "").Trim().ToLowerInvariant(); - if (kind.Contains("station")) - return 48.0; - if (kind.Contains("projectile")) - return Math.Max(1.0, entity.Visibility > 0.0 ? entity.Visibility : 3.0); - return 12.0; - } - - private static double HeadingYaw(AetheriaRuntimeEntitySnapshotCommit entity) - { - if (entity == null) - return 0.0; - if (Math.Abs(entity.DirectionX) <= 0.0001 && Math.Abs(entity.DirectionY) <= 0.0001) - return 0.0; - return HeadingDegrees(entity.DirectionX, entity.DirectionY); - } - - private static double HeadingDegrees(double x, double y) => - Math.Atan2(x, y) * (180.0 / Math.PI); - private static double EntityStat(AetheriaRuntimeEntitySnapshotCommit entity, string name) => (entity.StatGrids ?? Array.Empty()) .FirstOrDefault(grid => string.Equals(grid?.Name, name, StringComparison.OrdinalIgnoreCase)) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs index c8dae6d5b..3dbd5215b 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs @@ -58,6 +58,7 @@ namespace GameCult.Aetheria.State.Verse { run ??= new AetheriaRuntimeRunCheckpointCommit(); context ??= new AetheriaRuntimeDaemonOperationContext(); + context.Intents = new AetheriaRuntimeDaemonIntentState(); var applied = new List(); var rejected = new List(); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs index 814c7f4a1..d24321666 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonSimulation.cs @@ -119,9 +119,11 @@ namespace GameCult.Aetheria.State.Verse var speed = ResolveSpeed(entity, settings); entity.VelocityX = normalized.X * speed * magnitude; entity.VelocityY = normalized.Y * speed * magnitude; - if (magnitude <= 0.001) - entity.TargetEntityIndex = -1; - else + var target = entities.FirstOrDefault(candidate => + candidate.EntityIndex == entity.TargetEntityIndex && IsAlive(candidate)); + if (target != null) + Face(entity, target.PositionX - entity.PositionX, target.PositionZ - entity.PositionZ); + else if (magnitude > 0.001) Face(entity, normalized.X, normalized.Y); } diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index 236d55179..b9a197040 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -311,11 +311,11 @@ } }, "org.gamecult.cultlib": { - "version": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.10", + "version": "https://github.com/GameCult/CultLib.git?path=/unity/org.gamecult.cultlib#cultlib-unity-v1.0.13", "depth": 0, "source": "git", "dependencies": {}, - "hash": "085aa2c0756328770623474c4e9fbacd7218b390" + "hash": "feb5c71513e71d681699f462fe3682b3168c6f73" }, "org.gamecult.cultmath": { "version": "file:../../CultMath", @@ -343,9 +343,9 @@ "depth": 0, "source": "local", "dependencies": { - "org.gamecult.cultlib": "1.0.9", + "org.gamecult.cultlib": "1.0.13", "org.gamecult.eve.plugin-fields": "0.1.1", - "org.gamecult.eve.surface": "0.2.0", + "org.gamecult.eve.surface": "0.2.1", "com.unity.mathematics": "1.3.2" } },