Make loot pickup capacity checked and exactly once

This commit is contained in:
Meta Vens 2026-07-11 19:07:29 +01:00
commit def4a5b906
8 changed files with 68 additions and 6 deletions

View file

@ -14,6 +14,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
MissingPhysicsOwnerCannotAdvanceProjectiles();
MissingWorldPhysicsOwnerCannotAdvanceShips();
TractorRampsAndPullsThroughYmirWithoutTeleportingCargo();
PickupIsCapacityCheckedExactlyOnceAndExpires();
ThermalCellsUseFossilConductionAndRadiation();
MultipleActorsUseTheSameMovementLever();
AgentClaimsAndCompletesExploreTaskThroughCommands();
@ -815,6 +816,34 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
RequireEqual(0, CargoQuantity(ship, "salvage"), "scooping must remain a separate capacity-checked transaction");
}
private static void PickupIsCapacityCheckedExactlyOnceAndExpires()
{
var hull = CatalogItem("pickup-hull"); hull.HullCapacity = PerformanceStat(1);
var salvage = CatalogItem("salvage"); salvage.Volume = 1;
var catalog = new AetheriaRuntimeCatalogSnapshot([hull, salvage], [], []);
var ship = Entity(0, 0, "player"); ship.HullItemKey = hull.ItemKey; ship.CargoContents = [Cargo()];
var zone = new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [ship], DroppedPickups = [new AetheriaRuntimeDroppedPickupCommit { PickupIndex = 7, PositionX = 10, Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = salvage.ItemKey, Quantity = 1 }, LifetimeSeconds = 30 }] };
var run = new AetheriaRuntimeRunCheckpointCommit { CurrentZoneIndex = 0, CurrentEntityKey = "zone.0.entity.0", Zones = [zone] };
AetheriaRuntimeDaemonCommandDocument Pickup(string id, int index)
{
var command = AetheriaRuntimeDaemonCommandDocument.Create(AetheriaRuntimeDaemonCommandKinds.PickUpLoot, "pilot", "pickup-smoke", 0, "zone.0.entity.0");
command.CommandId = id; command.TargetEntityKey = "zone.0.entity.0"; command.LootPickup.ItemKey = salvage.ItemKey; command.LootPickup.Quantity = 1; command.LootPickup.PickupIndex = index; return command;
}
var first = AetheriaRuntimeDaemonOperations.Execute(run, [Pickup("pickup-first", 7)], new AetheriaRuntimeDaemonOperationContext { Catalog = catalog });
Require(first.AppliedCommandIds.Contains("pickup-first"), "nearby pickup with capacity must apply");
RequireEqual(1, CargoQuantity(ship, salvage.ItemKey), "successful pickup must enter cargo");
var duplicate = AetheriaRuntimeDaemonOperations.Execute(run, [Pickup("pickup-duplicate", 7)], new AetheriaRuntimeDaemonOperationContext { Catalog = catalog });
Require(duplicate.RejectedCommandIds.Contains("pickup-duplicate"), "consumed pickup identity must reject duplicate collection");
zone.DroppedPickups = [new AetheriaRuntimeDroppedPickupCommit { PickupIndex = 8, PositionX = 10, Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = salvage.ItemKey, Quantity = 1 }, LifetimeSeconds = 30 }];
var full = AetheriaRuntimeDaemonOperations.Execute(run, [Pickup("pickup-full", 8)], new AetheriaRuntimeDaemonOperationContext { Catalog = catalog });
Require(full.RejectedCommandIds.Contains("pickup-full") && zone.DroppedPickups.Count == 1,
"full cargo must reject without deleting pickup");
AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-pickup-expiry-smoke.cc"), run,
new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new AetheriaYmirWorldPhysics(), FrameId = 1, FixedDeltaSeconds = 30, SimulationTimeSeconds = 30, ProjectilePhysics = AetheriaRuntimeProjectilePhysicsUnavailable.Instance, BuildPublications = false });
RequireEqual(0, zone.DroppedPickups.Count, "pickup must expire after the fossil thirty-second lifetime");
}
private static (AetheriaRuntimeRunCheckpointCommit Run, AetheriaRuntimeZoneSnapshotCommit Zone, AetheriaRuntimeEntitySnapshotCommit Target) Scenario()
{
var source = Entity(1, -100, "player");

View file

@ -905,6 +905,9 @@ namespace GameCult.Aetheria.State.Verse
[Key(4)]
public double PositionZ { get; set; }
[Key(5)]
public int PickupIndex { get; set; } = -1;
}
[MessagePackObject]

View file

@ -483,7 +483,8 @@ namespace GameCult.Aetheria.State.Verse
int quantity,
double positionX,
double positionY,
double positionZ)
double positionZ,
int pickupIndex = -1)
{
var command = Create(AetheriaRuntimeDaemonCommandKinds.PickUpLoot, frame);
command.TargetEntityKey = targetEntityKey ?? "";
@ -497,6 +498,7 @@ namespace GameCult.Aetheria.State.Verse
command.LootPickup.PositionX = positionX;
command.LootPickup.PositionY = positionY;
command.LootPickup.PositionZ = positionZ;
command.LootPickup.PickupIndex = pickupIndex;
return Send(command);
}

View file

@ -141,7 +141,7 @@ namespace GameCult.Aetheria.State.Verse
case AetheriaRuntimeDaemonCommandKinds.StoreItem:
return ApplyStoreItem(run, command);
case AetheriaRuntimeDaemonCommandKinds.PickUpLoot:
return ApplyPickUpLoot(run, command);
return ApplyPickUpLoot(run, command, context.Catalog);
case AetheriaRuntimeDaemonCommandKinds.ToggleHullConductivity:
return ApplyToggleHullConductivity(run, command);
case AetheriaRuntimeDaemonCommandKinds.TradePurchase:
@ -786,7 +786,8 @@ namespace GameCult.Aetheria.State.Verse
private static bool ApplyPickUpLoot(
AetheriaRuntimeRunCheckpointCommit run,
AetheriaRuntimeDaemonCommandDocument command)
AetheriaRuntimeDaemonCommandDocument command,
AetheriaRuntimeCatalogSnapshot? catalog)
{
if (!TryResolveEntity(run, command.TargetEntityKey, out var zoneIndex, out _, out var entity))
return false;
@ -802,6 +803,11 @@ namespace GameCult.Aetheria.State.Verse
return false;
var pickup = pickups[pickupIndex];
var quantity = Math.Max(1, pickup.Item?.Quantity ?? command.LootPickup.Quantity);
if (pickup.AgeSeconds >= pickup.LifetimeSeconds ||
Math.Pow(pickup.PositionX - entity.PositionX, 2) + Math.Pow(pickup.PositionZ - entity.PositionZ, 2) > 25 * 25 ||
quantity > AetheriaRuntimeCargoCapacityQueries.UnitsThatFit(entity, catalog, pickup.Item?.ItemKey ?? command.LootPickup.ItemKey))
return false;
pickups.RemoveAt(pickupIndex);
zone.DroppedPickups = pickups.ToArray();
@ -1956,6 +1962,9 @@ namespace GameCult.Aetheria.State.Verse
if (pickup == null || !IsItemMatch(pickup.Item, pickupCommand.ItemKey))
return false;
if (pickupCommand.PickupIndex >= 0)
return pickup.PickupIndex == pickupCommand.PickupIndex;
var expectedX = pickupCommand.PositionX;
var expectedY = pickupCommand.PositionY;
var expectedZ = pickupCommand.PositionZ;

View file

@ -328,7 +328,8 @@ public sealed class AetheriaRuntimeDaemonOperationsClient
int quantity,
double positionX,
double positionY,
double positionZ)
double positionZ,
int pickupIndex = -1)
{
return Send((client, frame) => client.PickUpLoot(
frame,
@ -337,7 +338,8 @@ public sealed class AetheriaRuntimeDaemonOperationsClient
quantity,
positionX,
positionY,
positionZ));
positionZ,
pickupIndex));
}
public CultMeshOperationReceipt RestoreLoadout(

View file

@ -41,6 +41,8 @@ namespace GameCult.Aetheria.State.Verse
if (entities.Length == 0)
continue;
StepPickupLifetimes(zone, deltaSeconds);
EnsureStats(entities, settings);
foreach (var entity in entities)
AetheriaRuntimeThermalSimulation.EnsureState(entity);
@ -57,6 +59,15 @@ namespace GameCult.Aetheria.State.Verse
}
}
private static void StepPickupLifetimes(AetheriaRuntimeZoneSnapshotCommit zone, double deltaSeconds)
{
foreach (var pickup in zone.DroppedPickups ?? Array.Empty<AetheriaRuntimeDroppedPickupCommit>())
if (pickup != null) pickup.AgeSeconds += deltaSeconds;
zone.DroppedPickups = (zone.DroppedPickups ?? Array.Empty<AetheriaRuntimeDroppedPickupCommit>())
.Where(pickup => pickup != null && pickup.AgeSeconds < pickup.LifetimeSeconds)
.ToArray();
}
private static void StepTractorPower(IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities, double deltaSeconds)
{
foreach (var entity in entities)

View file

@ -592,6 +592,12 @@ namespace GameCult.Aetheria.State.Verse
[Key(7)]
public AetheriaRuntimeLoadoutItemCommit Item { get; set; } = new AetheriaRuntimeLoadoutItemCommit();
[Key(8)]
public double AgeSeconds { get; set; }
[Key(9)]
public double LifetimeSeconds { get; set; } = 30;
}
[MessagePackObject]

View file

@ -25,7 +25,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
| Thermal/energy | cell conduction and capacitor/reactor/radiator network | daemon | ship/equipment status and warnings | schematic/post effects | cell conduction/radiation wired; energy network and medical thresholds remain reference | capacitor/reactor/radiator ordering, shared energy and medical timelines |
| Weapons | ServerShared behaviors + Unity effects | daemon + Ymir where spatial | action capability, weapon state, attack events | effects/audio/HUD | one synthetic weapon wired; original engine reference-only | each weapon family |
| Destruction/drops | entity death and pickup paths | daemon | death/drop events and world entities | effects and pickups | fragments wired; chronology and original drop transaction absent | exactly-once drops and cleanup |
| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, target, pickup entity and receipt | beam/interaction feedback | fossil 2/s power ramp and authored radius/traction/distance move targets through Ymir; instant cargo teleport deleted; pickup transaction remains partial | sphere-cast filtering, failed capacity, pickup lifetime and exactly-once receipt |
| Tractor/scoop | analog tractor and physical timed pickups | daemon + Ymir | tractor power, target, pickup entity and receipt | beam/interaction feedback | fossil 2/s power ramp and authored radius/traction/distance move targets through Ymir; pickup uses stable identity, range/capacity validation, exactly-once removal, and 30s daemon lifetime; instant cargo teleport deleted | put dropped pickup trajectories and failed-capacity bounce into the Ymir world; prove runtime feedback |
| Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon path wired/projected; Ymir placement and parity unproven | priority, eligibility, placement and reconnect |
| Inventory/equipment | inventory panels + ServerShared | daemon | inventory/equipment surfaces | generic UI | owner-exists; wired/projected in fragments; not proven | all transfer directions and rejection |
| Trade | trade UI/economy | daemon | stock, quote, purchase commands | generic UI | purchase owner wired/projected; not proven | atomic purchase and capacity |