Restore fossil tractor and destruction loot parity
This commit is contained in:
parent
59d8620516
commit
f08e11f775
5 changed files with 81 additions and 46 deletions
|
|
@ -42,6 +42,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
{
|
||||
RunCheck(RetainedWorldAdvancesEveryFixedSubstep);
|
||||
RunCheck(StableEntityIdentitySurvivesCrossZoneReindex);
|
||||
RunCheck(TractorRampsAndPullsThroughYmirWithoutTeleportingCargo);
|
||||
RunCheck(PickupIsCapacityCheckedExactlyOnceAndExpires);
|
||||
RunCheck(PickupShieldContactCollectsOrBounces);
|
||||
}
|
||||
|
|
@ -843,8 +844,10 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
Require(!target.IsActive && target.DestroyedFrameId == 1 &&
|
||||
!string.IsNullOrWhiteSpace(target.DestructionId),
|
||||
"lethal daemon damage must commit one durable destruction identity and deactivate the entity");
|
||||
RequireEqual(3, zone.DroppedPickups.Count,
|
||||
"guaranteed fossil loot roll must drop hull, equipment, and every cargo stack");
|
||||
RequireEqual(2, zone.DroppedPickups.Count,
|
||||
"guaranteed fossil loot roll must drop non-hull equipment and every cargo stack");
|
||||
Require(!zone.DroppedPickups.Any(value => value.Item.ItemKey == "drop-hull"),
|
||||
"the equipped hull must remain excluded from fossil destruction loot");
|
||||
RequireEqual(4, zone.DroppedPickups.Single(value => value.Item.ItemKey == "drop-cargo").Item.Quantity,
|
||||
"cargo drops must preserve exact stack quantity");
|
||||
Require(zone.DroppedPickups.All(value => Math.Abs(Math.Sqrt(
|
||||
|
|
@ -852,7 +855,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
value.VelocityZ * value.VelocityZ) - 25) < 0.000001 &&
|
||||
Math.Abs(value.LifetimeSeconds - 30) < 0.000001),
|
||||
"destruction pickups must retain fossil launch speed and lifetime");
|
||||
RequireEqual(3, run.GameEvents.Count(value => value.Kind == "pickup.dropped"),
|
||||
RequireEqual(2, run.GameEvents.Count(value => value.Kind == "pickup.dropped"),
|
||||
"each durable pickup must publish one drop event");
|
||||
RequireEqual(1, run.GameEvents.Count(value => value.Kind == "entity.destroyed"),
|
||||
"destruction chronology must publish exactly once");
|
||||
|
|
@ -871,7 +874,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
|
||||
AetheriaRuntimeDaemonSimulation.Step(run, new AetheriaRuntimeDaemonIntentState(), 0.1, settings,
|
||||
NewPhysics(), null, 2, 0.2);
|
||||
RequireEqual(3, zone.DroppedPickups.Count,
|
||||
RequireEqual(2, zone.DroppedPickups.Count,
|
||||
"later ticks must not duplicate an already committed destruction transaction");
|
||||
RequireEqual(1, run.GameEvents.Count(value => value.Kind == "entity.destroyed"),
|
||||
"later ticks must not duplicate destruction chronology");
|
||||
|
|
@ -2801,6 +2804,41 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
RequireEqual(0, CargoQuantity(ship, "salvage"), "scooping must remain a separate capacity-checked transaction");
|
||||
Require(pickup.AgeSeconds > 0 && pickup.AgeSeconds < pickup.LifetimeSeconds,
|
||||
"daemon-owned pickup lifetime must advance independently of its SoA presentation");
|
||||
|
||||
double PulledVelocity(double power, int frameId)
|
||||
{
|
||||
var actor = Entity(0, 0, "player");
|
||||
actor.DirectionX = 1;
|
||||
actor.DirectionY = 0;
|
||||
actor.TractorPower = power;
|
||||
actor.TractorTargetPower = power;
|
||||
var cargo = new AetheriaRuntimeDroppedPickupCommit
|
||||
{
|
||||
PickupIndex = 30 + frameId,
|
||||
PositionX = 60,
|
||||
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "salvage", Quantity = 1 },
|
||||
LifetimeSeconds = 30
|
||||
};
|
||||
var scenario = new AetheriaRuntimeRunCheckpointCommit
|
||||
{
|
||||
RunId = $"tractor-power-{frameId}",
|
||||
CurrentZoneIndex = 0,
|
||||
CurrentEntityKey = "zone.0.entity.0",
|
||||
Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [actor], DroppedPickups = [cargo] }]
|
||||
};
|
||||
AetheriaRuntimeDaemonTickRunner.Tick(
|
||||
Path.Combine(Path.GetTempPath(), $"aetheria-tractor-power-{frameId}.cc"),
|
||||
scenario,
|
||||
new AetheriaRuntimeDaemonTickOptions
|
||||
{
|
||||
WorldPhysics = NewPhysics(), FrameId = frameId, FixedDeltaSeconds = 0.1,
|
||||
SimulationTimeSeconds = frameId * 0.1, BuildPublications = false
|
||||
});
|
||||
return cargo.VelocityX;
|
||||
}
|
||||
|
||||
RequireNear(PulledVelocity(0.02, 20), PulledVelocity(1, 21), 0.000001,
|
||||
"tractor power above the fossil threshold must gate full traction rather than scale force");
|
||||
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");
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi
|
|||
int simulationStepIndex,
|
||||
ref int commandOrdinal)
|
||||
{
|
||||
foreach (var actor in active.Where(entity => entity.TractorPower > 0))
|
||||
foreach (var actor in active.Where(entity => entity.TractorPower > 0.01))
|
||||
{
|
||||
var forward = Normalize(actor.DirectionX, actor.DirectionY, 0, 1);
|
||||
foreach (var pickup in pickups)
|
||||
|
|
@ -360,7 +360,7 @@ public sealed class AetheriaYmirWorldPhysics : IAetheriaRuntimeWorldPhysics, IDi
|
|||
if (along < 0 || along > TractorDistance || lateral > TractorRadius || distance <= 0.001)
|
||||
continue;
|
||||
|
||||
var force = TractorTraction * actor.TractorPower;
|
||||
var force = TractorTraction;
|
||||
var pickupId = PickupPrefix + pickup.PickupIndex;
|
||||
RequireAccepted(session.ApplyForce(new YmirApplyForceCommand(
|
||||
Header(session, frameId, simulationStepIndex, "tractor", $"{actor.EntityIndex}:{pickup.PickupIndex}", ref commandOrdinal),
|
||||
|
|
|
|||
|
|
@ -2363,12 +2363,8 @@ public class DaemonRuntimeDocumentTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void TerminusPilotTractorScoopsCargoFromTargetedWreck()
|
||||
public void TractorProximityCannotCollectCargoWithoutYmirContact()
|
||||
{
|
||||
var loot = new AetheriaRuntimeLoadoutItemSlotCommit
|
||||
{
|
||||
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "raider-salvage" }
|
||||
};
|
||||
var pilot = new AetheriaRuntimeEntitySnapshotCommit
|
||||
{
|
||||
EntityIndex = 1,
|
||||
|
|
@ -2379,21 +2375,12 @@ public class DaemonRuntimeDocumentTests
|
|||
TractorPower = 1,
|
||||
CargoContents = new[] { new AetheriaRuntimeCargoBayLoadoutCommit() }
|
||||
};
|
||||
var wreck = new AetheriaRuntimeEntitySnapshotCommit
|
||||
var pickup = new AetheriaRuntimeDroppedPickupCommit
|
||||
{
|
||||
EntityIndex = 6,
|
||||
Kind = "ship",
|
||||
FactionKey = "raider",
|
||||
IsActive = false,
|
||||
PickupIndex = 6,
|
||||
PositionX = 10,
|
||||
CargoContents = new[]
|
||||
{
|
||||
new AetheriaRuntimeCargoBayLoadoutCommit { Items = new[] { loot } }
|
||||
},
|
||||
StatGrids = new[]
|
||||
{
|
||||
new AetheriaRuntimeEntityStatGridCommit { Name = "hull", Values = new[] { 0.0 } }
|
||||
}
|
||||
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "raider-salvage" },
|
||||
LifetimeSeconds = 30
|
||||
};
|
||||
var run = new AetheriaRuntimeRunCheckpointCommit
|
||||
{
|
||||
|
|
@ -2405,7 +2392,8 @@ public class DaemonRuntimeDocumentTests
|
|||
new AetheriaRuntimeZoneSnapshotCommit
|
||||
{
|
||||
ZoneIndex = 0,
|
||||
Entities = new[] { pilot, wreck }
|
||||
Entities = new[] { pilot },
|
||||
DroppedPickups = new[] { pickup }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -2417,8 +2405,9 @@ public class DaemonRuntimeDocumentTests
|
|||
AetheriaRuntimeDaemonSimulationSettings.AetheriaDefault,
|
||||
new PassthroughWorldPhysics());
|
||||
|
||||
Assert.IsTrue(pilot.CargoContents.SelectMany(bay => bay.Items).Any(slot => slot.Item.ItemKey == "raider-salvage"));
|
||||
Assert.IsEmpty(wreck.CargoContents);
|
||||
Assert.IsFalse(pilot.CargoContents.SelectMany(bay => bay.Items).Any(slot => slot.Item.ItemKey == "raider-salvage"));
|
||||
Assert.AreEqual(1, run.Zones[0].DroppedPickups.Count,
|
||||
"targeting, tractor power, and proximity must not replace a Ymir Begin contact fact");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
@ -4246,9 +4235,23 @@ public class DaemonRuntimeDocumentTests
|
|||
}
|
||||
|
||||
[Test]
|
||||
public void DaemonOperationsPicksUpLootInDaemonState()
|
||||
public void DaemonOperationsRejectsClientOwnedLootPickup()
|
||||
{
|
||||
var run = RunWithTwoEntities();
|
||||
var zone = run.Zones[0];
|
||||
zone.DroppedPickups = new[]
|
||||
{
|
||||
new AetheriaRuntimeDroppedPickupCommit
|
||||
{
|
||||
PickupIndex = 7,
|
||||
PositionX = 10,
|
||||
PositionY = 11,
|
||||
PositionZ = 12,
|
||||
Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = "loot-cell", Quantity = 1 },
|
||||
LifetimeSeconds = 30
|
||||
}
|
||||
};
|
||||
var cargoCount = zone.Entities[0].CargoContents[0].Items.Count;
|
||||
var command = AetheriaRuntimeDaemonCommandDocument.Create(
|
||||
AetheriaRuntimeDaemonCommandKinds.PickUpLoot,
|
||||
"codex",
|
||||
|
|
@ -4262,6 +4265,7 @@ public class DaemonRuntimeDocumentTests
|
|||
command.PositionZ = 12;
|
||||
command.ScalarValue = 1;
|
||||
command.LootPickup.ItemKey = "loot-cell";
|
||||
command.LootPickup.PickupIndex = 7;
|
||||
command.LootPickup.Quantity = 1;
|
||||
command.LootPickup.PositionX = 10;
|
||||
command.LootPickup.PositionY = 11;
|
||||
|
|
@ -4269,12 +4273,11 @@ public class DaemonRuntimeDocumentTests
|
|||
|
||||
var result = AetheriaRuntimeDaemonOperations.Execute(run, new[] { command });
|
||||
|
||||
var zone = run.Zones[0];
|
||||
var cargo = zone.Entities[0].CargoContents[0].Items;
|
||||
Assert.AreEqual(1, result.AppliedCommandIds.Count);
|
||||
Assert.AreEqual(0, zone.DroppedPickups.Count);
|
||||
Assert.AreEqual(2, cargo.Count);
|
||||
Assert.AreEqual("loot-cell", cargo[1].Item.ItemKey);
|
||||
Assert.AreEqual(0, result.AppliedCommandIds.Count);
|
||||
CollectionAssert.Contains(result.RejectedCommandIds, command.CommandId);
|
||||
Assert.AreEqual(1, zone.DroppedPickups.Count);
|
||||
Assert.AreEqual(cargoCount, zone.Entities[0].CargoContents[0].Items.Count,
|
||||
"client pickup commands must not mutate daemon cargo");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
|
|
|||
|
|
@ -1333,13 +1333,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
});
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(target.HullItemKey) &&
|
||||
ShotRoll(run.GenerationSeed, destructionId, "equipment:hull") < settings.LootDropProbability)
|
||||
Drop(new AetheriaRuntimeLoadoutItemCommit
|
||||
{
|
||||
ItemKey = target.HullItemKey, Quality = 1, Durability = 0,
|
||||
Quantity = 1, Enabled = false
|
||||
}, "equipment", -1);
|
||||
var equipment = target.Equipment ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>();
|
||||
for (var index = 0; index < equipment.Count; index++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2278,11 +2278,12 @@ instantiation, credits, dock assignment, current entity, and checkpoint. Docked
|
|||
current-ship selection follows the same rule: UI requests selection, and the
|
||||
daemon owns `CurrentEntity`, `DockingBay.DockedShip`, and checkpoint. Undocking
|
||||
also owns a collision-free departure pose and clears inherited velocity before
|
||||
the detached ship re-enters world physics. Loot pickup follows the same rule:
|
||||
an active tractor inside its operating envelope requests collection, and the
|
||||
daemon atomically owns capacity validation, cargo storage, pickup removal,
|
||||
monotonic pickup identity, and checkpoint. Physics moves loose bodies but does
|
||||
not decide inventory ownership. The portable Eve entity SoA publishes
|
||||
the detached ship re-enters world physics. Loot pickup is contact-gated: the
|
||||
tractor applies force to loose bodies, Ymir owns typed Begin contact facts, and
|
||||
the daemon alone interprets each persisted fact identity into capacity
|
||||
validation, cargo storage or rejection bounce, pickup removal, feedback, and
|
||||
checkpoint. Targeting, proximity, client commands, and presentation collisions
|
||||
cannot decide inventory ownership. The portable Eve entity SoA publishes
|
||||
`inventory.cargo.quantity`, allowing generic clients and witnesses to observe
|
||||
the committed cargo delta without reading Aetheria internals. Entity destruction follows
|
||||
the same rule: instance code observes death, and the daemon owns drop
|
||||
|
|
|
|||
Loading…
Reference in a new issue