Gate loot collection on Ymir contacts
This commit is contained in:
parent
a45c3f9801
commit
6b881c7d05
10 changed files with 158 additions and 172 deletions
|
|
@ -8,6 +8,11 @@ if (args.Contains("--loadout", StringComparer.Ordinal))
|
|||
checks.RunLoadout();
|
||||
Console.WriteLine("Daemon loadout hardpoint smoke passed.");
|
||||
}
|
||||
else if (args.Contains("--pickup", StringComparer.Ordinal))
|
||||
{
|
||||
checks.RunPickup();
|
||||
Console.WriteLine("Daemon Ymir pickup-contact smoke passed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
checks.Run();
|
||||
|
|
@ -18,6 +23,12 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
{
|
||||
public void RunLoadout() => DaemonLoadoutsRespectFactionAvailabilityAndHullRoles();
|
||||
|
||||
public void RunPickup()
|
||||
{
|
||||
PickupIsCapacityCheckedExactlyOnceAndExpires();
|
||||
PickupShieldContactCollectsOrBounces();
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
YmirMovesProjectileAndReportsStableContact();
|
||||
|
|
@ -2483,27 +2494,36 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
{
|
||||
var hull = CatalogItem("pickup-hull"); hull.HullCapacity = PerformanceStat(1);
|
||||
var salvage = CatalogItem("salvage"); salvage.Volume = 1;
|
||||
var catalog = new AetheriaRuntimeCatalogSnapshot([hull, salvage], [], []);
|
||||
var cargoBay = CatalogItem("pickup-cargo-bay"); cargoBay.InteriorOccupiedCells = 1;
|
||||
var catalog = new AetheriaRuntimeCatalogSnapshot([hull, salvage, cargoBay], [], []);
|
||||
var ship = Entity(0, 0, "player"); ship.HullItemKey = hull.ItemKey; ship.CargoContents = [Cargo()];
|
||||
ship.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = cargoBay.ItemKey, Quantity = 1 } }];
|
||||
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");
|
||||
var forbiddenCommand = AetheriaRuntimeDaemonCommandDocument.Create(AetheriaRuntimeDaemonCommandKinds.PickUpLoot, "pilot", "pickup-smoke", 0, "zone.0.entity.0");
|
||||
forbiddenCommand.CommandId = "pickup-command-forbidden";
|
||||
forbiddenCommand.TargetEntityKey = "zone.0.entity.0";
|
||||
forbiddenCommand.LootPickup.PickupIndex = 7;
|
||||
var forbidden = AetheriaRuntimeDaemonOperations.Execute(run, [forbiddenCommand], new AetheriaRuntimeDaemonOperationContext { Catalog = catalog });
|
||||
Require(forbidden.RejectedCommandIds.Contains(forbiddenCommand.CommandId),
|
||||
"client pickup commands must not own cargo collection");
|
||||
|
||||
AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-pickup-no-contact.cc"), run,
|
||||
new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new ScriptedWorldPhysics(), FrameId = 1, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 0.1, Catalog = catalog, PhysicalPayloadPhysics = AetheriaRuntimePhysicalPayloadPhysicsUnavailable.Instance, BuildPublications = false });
|
||||
RequireEqual(1, zone.DroppedPickups.Count, "nearby pickup without a Ymir contact fact must remain in the world");
|
||||
RequireEqual(0, CargoQuantity(ship, salvage.ItemKey), "proximity must not mutate cargo");
|
||||
|
||||
var contact = new AetheriaRuntimeWorldContact { EntityAIndex = 0, PickupIndex = 7, NormalX = 1 };
|
||||
AetheriaRuntimeDaemonTickRunner.Tick(Path.Combine(Path.GetTempPath(), "aetheria-pickup-contact-dedup.cc"), run,
|
||||
new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new ScriptedWorldPhysics(contact, contact), FrameId = 2, FixedDeltaSeconds = 0.1, SimulationTimeSeconds = 0.2, Catalog = catalog, PhysicalPayloadPhysics = AetheriaRuntimePhysicalPayloadPhysicsUnavailable.Instance, BuildPublications = false });
|
||||
RequireEqual(0, zone.DroppedPickups.Count, "one Ymir contact must consume the pickup");
|
||||
RequireEqual(1, CargoQuantity(ship, salvage.ItemKey), "duplicate contact facts must commit cargo exactly once");
|
||||
RequireEqual(1, run.GameEvents.Count(value => value.Kind == "pickup.collected" && value.PickupIndex == 7),
|
||||
"duplicate contact facts must emit one collection event");
|
||||
|
||||
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, PhysicalPayloadPhysics = AetheriaRuntimePhysicalPayloadPhysicsUnavailable.Instance, BuildPublications = false });
|
||||
new AetheriaRuntimeDaemonTickOptions { WorldPhysics = new ScriptedWorldPhysics(), FrameId = 3, FixedDeltaSeconds = 30, SimulationTimeSeconds = 30, PhysicalPayloadPhysics = AetheriaRuntimePhysicalPayloadPhysicsUnavailable.Instance, BuildPublications = false });
|
||||
RequireEqual(0, zone.DroppedPickups.Count, "pickup must expire after the fossil thirty-second lifetime");
|
||||
Require(run.GameEvents.Any(value => value.Kind == "pickup.expired" && value.PickupIndex == 8),
|
||||
"daemon lifetime owner must emit authoritative pickup expiry event");
|
||||
|
|
@ -2513,10 +2533,12 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
{
|
||||
var hull = CatalogItem("contact-hull"); hull.HullCapacity = PerformanceStat(1);
|
||||
var salvage = CatalogItem("contact-salvage"); salvage.Volume = 1;
|
||||
var catalog = new AetheriaRuntimeCatalogSnapshot([hull, salvage], [], []);
|
||||
var cargoBay = CatalogItem("contact-cargo-bay"); cargoBay.InteriorOccupiedCells = 1;
|
||||
var catalog = new AetheriaRuntimeCatalogSnapshot([hull, salvage, cargoBay], [], []);
|
||||
AetheriaRuntimeRunCheckpointCommit Scenario(bool full)
|
||||
{
|
||||
var ship = Entity(0, 0, "player"); ship.HullItemKey = hull.ItemKey;
|
||||
ship.Equipment = [new AetheriaRuntimeLoadoutItemSlotCommit { Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = cargoBay.ItemKey, Quantity = 1 } }];
|
||||
ship.CargoContents = [full ? Cargo((salvage.ItemKey, 1, 0, 0)) : Cargo()];
|
||||
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 }] }] };
|
||||
}
|
||||
|
|
@ -2638,4 +2660,14 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
if (Math.Abs(expected - actual) > tolerance)
|
||||
throw new InvalidOperationException($"{message}. Expected {expected}; actual {actual}.");
|
||||
}
|
||||
|
||||
private sealed class ScriptedWorldPhysics(params AetheriaRuntimeWorldContact[] contacts) : IAetheriaRuntimeWorldPhysics
|
||||
{
|
||||
public string ImplementationId => "smoke.scripted-world";
|
||||
|
||||
public AetheriaRuntimeWorldStep Step(
|
||||
AetheriaRuntimeZoneSnapshotCommit zone,
|
||||
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
|
||||
double deltaSeconds) => new([], [], contacts);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,15 +190,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
sourceY,
|
||||
createsDockedShip);
|
||||
|
||||
public CultMeshOperationReceipt PickUpLoot(
|
||||
string targetEntityKey,
|
||||
string itemKey,
|
||||
int quantity,
|
||||
double positionX,
|
||||
double positionY,
|
||||
double positionZ) =>
|
||||
_operations.PickUpLoot(targetEntityKey, itemKey, quantity, positionX, positionY, positionZ);
|
||||
|
||||
public CultMeshOperationReceipt RestoreLoadout(
|
||||
string dockedEntityKey,
|
||||
string templateName,
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
SetItemEnabled,
|
||||
SetItemOverrideShutdown,
|
||||
SetThermotoggleTargetTemperature,
|
||||
PickUpLoot,
|
||||
PickUpLoot, // Reserved serialized slot. Collection is owned by daemon interpretation of Ymir contacts.
|
||||
RestoreLoadout,
|
||||
Dock,
|
||||
DockNearest,
|
||||
|
|
@ -440,8 +440,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return nameof(AetheriaRuntimeCargoTransferCommand);
|
||||
case AetheriaRuntimeDaemonCommandKinds.TradePurchase:
|
||||
return nameof(AetheriaRuntimeTradePurchaseCommand);
|
||||
case AetheriaRuntimeDaemonCommandKinds.PickUpLoot:
|
||||
return nameof(AetheriaRuntimeLootPickupCommand);
|
||||
case AetheriaRuntimeDaemonCommandKinds.RestoreLoadout:
|
||||
return nameof(AetheriaRuntimeLoadoutRestoreCommand);
|
||||
case AetheriaRuntimeDaemonCommandKinds.EquipItem:
|
||||
|
|
|
|||
|
|
@ -491,32 +491,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return Send(command);
|
||||
}
|
||||
|
||||
internal AetheriaRuntimeDaemonCommandEnvelope PickUpLoot(
|
||||
AetheriaRuntimeDaemonFrameDocument? frame,
|
||||
string targetEntityKey,
|
||||
string itemKey,
|
||||
int quantity,
|
||||
double positionX,
|
||||
double positionY,
|
||||
double positionZ,
|
||||
int pickupIndex = -1)
|
||||
{
|
||||
var command = Create(AetheriaRuntimeDaemonCommandKinds.PickUpLoot, frame);
|
||||
command.TargetEntityKey = targetEntityKey ?? "";
|
||||
command.TextValue = itemKey ?? "";
|
||||
command.ScalarValue = quantity;
|
||||
command.PositionX = positionX;
|
||||
command.PositionY = positionY;
|
||||
command.PositionZ = positionZ;
|
||||
command.LootPickup.ItemKey = itemKey ?? "";
|
||||
command.LootPickup.Quantity = quantity;
|
||||
command.LootPickup.PositionX = positionX;
|
||||
command.LootPickup.PositionY = positionY;
|
||||
command.LootPickup.PositionZ = positionZ;
|
||||
command.LootPickup.PickupIndex = pickupIndex;
|
||||
return Send(command);
|
||||
}
|
||||
|
||||
internal AetheriaRuntimeDaemonCommandEnvelope RestoreLoadout(
|
||||
AetheriaRuntimeDaemonFrameDocument? frame,
|
||||
string dockedEntityKey,
|
||||
|
|
|
|||
|
|
@ -138,8 +138,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return ApplyEquipItem(run, command);
|
||||
case AetheriaRuntimeDaemonCommandKinds.StoreItem:
|
||||
return ApplyStoreItem(run, command);
|
||||
case AetheriaRuntimeDaemonCommandKinds.PickUpLoot:
|
||||
return ApplyPickUpLoot(run, command, context.Catalog);
|
||||
case AetheriaRuntimeDaemonCommandKinds.ToggleHullConductivity:
|
||||
return ApplyToggleHullConductivity(run, command);
|
||||
case AetheriaRuntimeDaemonCommandKinds.TradePurchase:
|
||||
|
|
@ -866,40 +864,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return true;
|
||||
}
|
||||
|
||||
private static bool ApplyPickUpLoot(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeDaemonCommandDocument command,
|
||||
AetheriaRuntimeCatalogSnapshot? catalog)
|
||||
{
|
||||
if (!TryResolveEntity(run, command.TargetEntityKey, out var zoneIndex, out _, out var entity))
|
||||
return false;
|
||||
|
||||
var zone = (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
|
||||
.FirstOrDefault(candidate => candidate != null && candidate.ZoneIndex == zoneIndex);
|
||||
if (zone == null)
|
||||
return false;
|
||||
|
||||
var pickups = (zone.DroppedPickups ?? Array.Empty<AetheriaRuntimeDroppedPickupCommit>()).ToList();
|
||||
var pickupIndex = pickups.FindIndex(pickup => IsPickupMatch(pickup, command));
|
||||
if (pickupIndex < 0)
|
||||
return false;
|
||||
|
||||
var pickup = pickups[pickupIndex];
|
||||
var collected = AetheriaRuntimePickupTransactions.TryCollect(zone, entity, pickup.PickupIndex, catalog);
|
||||
AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit
|
||||
{
|
||||
EventId = $"command:{command.CommandId}:{(collected ? "pickup-collected" : "pickup-rejected")}",
|
||||
Kind = collected ? "pickup.collected" : "pickup.rejected",
|
||||
FrameId = command.ObservedFrameId,
|
||||
ZoneIndex = zoneIndex,
|
||||
TargetEntityIndex = entity.EntityIndex,
|
||||
PickupIndex = pickup.PickupIndex,
|
||||
ItemKey = pickup.Item?.ItemKey ?? "",
|
||||
ScalarValue = Math.Max(1, pickup.Item?.Quantity ?? 1)
|
||||
});
|
||||
return collected;
|
||||
}
|
||||
|
||||
private static bool ApplyToggleHullConductivity(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeDaemonCommandDocument command)
|
||||
|
|
@ -2102,24 +2066,5 @@ namespace GameCult.Aetheria.State.Verse
|
|||
string.Equals(item.ItemKey ?? "", itemKey ?? "", StringComparison.Ordinal));
|
||||
}
|
||||
|
||||
private static bool IsPickupMatch(
|
||||
AetheriaRuntimeDroppedPickupCommit pickup,
|
||||
AetheriaRuntimeDaemonCommandDocument command)
|
||||
{
|
||||
var pickupCommand = command.LootPickup ?? new AetheriaRuntimeLootPickupCommand();
|
||||
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;
|
||||
return Math.Abs(pickup.PositionX - expectedX) < 0.001 &&
|
||||
Math.Abs(pickup.PositionY - expectedY) < 0.001 &&
|
||||
Math.Abs(pickup.PositionZ - expectedZ) < 0.001;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -323,26 +323,6 @@ public sealed class AetheriaRuntimeDaemonOperationsClient
|
|||
createsDockedShip));
|
||||
}
|
||||
|
||||
public CultMeshOperationReceipt PickUpLoot(
|
||||
string targetEntityKey,
|
||||
string itemKey,
|
||||
int quantity,
|
||||
double positionX,
|
||||
double positionY,
|
||||
double positionZ,
|
||||
int pickupIndex = -1)
|
||||
{
|
||||
return Send((client, frame) => client.PickUpLoot(
|
||||
frame,
|
||||
targetEntityKey,
|
||||
itemKey,
|
||||
quantity,
|
||||
positionX,
|
||||
positionY,
|
||||
positionZ,
|
||||
pickupIndex));
|
||||
}
|
||||
|
||||
public CultMeshOperationReceipt RestoreLoadout(
|
||||
string dockedEntityKey,
|
||||
string templateName,
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
foreach (var movement in intents?.Movements ?? Enumerable.Empty<AetheriaRuntimeDaemonMovementIntent>())
|
||||
ApplyMovementIntent(run, entities, movement, settings);
|
||||
StepTractorPower(entities, deltaSeconds);
|
||||
StepWorldPhysics(zone, entities, deltaSeconds, worldPhysics);
|
||||
ResolveTractorCollections(run, zone, entities, catalog, frameId);
|
||||
var worldStep = StepWorldPhysics(zone, entities, deltaSeconds, worldPhysics);
|
||||
ResolvePickupContacts(run, zone, entities, worldStep.Contacts, catalog, frameId);
|
||||
StepCombat(run, zone, entities, intents, deltaSeconds, settings, physicalPayloadPhysics, catalog,
|
||||
frameId, simulationTimeSeconds);
|
||||
AetheriaRuntimeMiningSimulation.Step(run, zone, entities, intents, catalog, frameId, simulationTimeSeconds, deltaSeconds);
|
||||
|
|
@ -154,40 +154,48 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return result;
|
||||
}
|
||||
|
||||
private static void ResolveTractorCollections(
|
||||
private static void ResolvePickupContacts(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeZoneSnapshotCommit zone,
|
||||
IReadOnlyList<AetheriaRuntimeEntitySnapshotCommit> entities,
|
||||
IReadOnlyList<AetheriaRuntimeWorldContact> contacts,
|
||||
AetheriaRuntimeCatalogSnapshot? catalog,
|
||||
long frameId)
|
||||
{
|
||||
foreach (var entity in entities.Where(value =>
|
||||
value != null && value.IsActive && value.TractorPower > 0.001))
|
||||
var entitiesByIndex = entities
|
||||
.Where(value => value != null && value.IsActive)
|
||||
.ToDictionary(value => value.EntityIndex);
|
||||
foreach (var contact in (contacts ?? Array.Empty<AetheriaRuntimeWorldContact>())
|
||||
.Where(value => value != null && value.PickupIndex >= 0)
|
||||
.GroupBy(value => (value.EntityAIndex, value.EntityBIndex, value.PickupIndex))
|
||||
.Select(group => group.First()))
|
||||
{
|
||||
foreach (var pickup in (zone.DroppedPickups ?? Array.Empty<AetheriaRuntimeDroppedPickupCommit>())
|
||||
.Where(value => value != null)
|
||||
.ToArray())
|
||||
var entityIndex = contact.EntityAIndex >= 0 ? contact.EntityAIndex : contact.EntityBIndex;
|
||||
if (!entitiesByIndex.TryGetValue(entityIndex, out var entity))
|
||||
continue;
|
||||
var pickup = (zone.DroppedPickups ?? Array.Empty<AetheriaRuntimeDroppedPickupCommit>())
|
||||
.FirstOrDefault(value => value != null && value.PickupIndex == contact.PickupIndex);
|
||||
if (pickup == null)
|
||||
continue;
|
||||
var itemKey = pickup.Item?.ItemKey ?? "";
|
||||
var quantity = Math.Max(1, pickup.Item?.Quantity ?? 1);
|
||||
var result = AetheriaRuntimePickupTransactions.ApplyContact(zone, entity, contact, catalog);
|
||||
if (result == AetheriaRuntimePickupContactResult.Ignored)
|
||||
continue;
|
||||
var kind = result == AetheriaRuntimePickupContactResult.Collected
|
||||
? "pickup.collected"
|
||||
: "pickup.rejected";
|
||||
AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit
|
||||
{
|
||||
if (!AetheriaRuntimePickupTransactions.TryCollect(
|
||||
zone,
|
||||
entity,
|
||||
pickup.PickupIndex,
|
||||
catalog,
|
||||
requireRange: true,
|
||||
collectionRange: 75))
|
||||
continue;
|
||||
AetheriaRuntimeGameEvents.Append(run, new AetheriaRuntimeGameEventCommit
|
||||
{
|
||||
EventId = $"frame:{frameId}:zone:{zone.ZoneIndex}:entity:{entity.EntityIndex}:pickup:{pickup.PickupIndex}:collected",
|
||||
Kind = "pickup.collected",
|
||||
FrameId = frameId,
|
||||
ZoneIndex = zone.ZoneIndex,
|
||||
TargetEntityIndex = entity.EntityIndex,
|
||||
PickupIndex = pickup.PickupIndex,
|
||||
ItemKey = pickup.Item?.ItemKey ?? "",
|
||||
ScalarValue = Math.Max(1, pickup.Item?.Quantity ?? 1)
|
||||
});
|
||||
}
|
||||
EventId = $"frame:{frameId}:zone:{zone.ZoneIndex}:entity:{entity.EntityIndex}:pickup:{contact.PickupIndex}:{kind}",
|
||||
Kind = kind,
|
||||
FrameId = frameId,
|
||||
ZoneIndex = zone.ZoneIndex,
|
||||
TargetEntityIndex = entity.EntityIndex,
|
||||
PickupIndex = contact.PickupIndex,
|
||||
ItemKey = itemKey,
|
||||
ScalarValue = quantity
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,30 +5,65 @@ using System.Linq;
|
|||
|
||||
namespace GameCult.Aetheria.State.Verse
|
||||
{
|
||||
public static class AetheriaRuntimePickupTransactions
|
||||
internal enum AetheriaRuntimePickupContactResult
|
||||
{
|
||||
public static bool TryCollect(AetheriaRuntimeZoneSnapshotCommit zone, AetheriaRuntimeEntitySnapshotCommit entity,
|
||||
int pickupIndex, AetheriaRuntimeCatalogSnapshot? catalog, bool requireRange = true,
|
||||
double collectionRange = 25)
|
||||
Ignored,
|
||||
Collected,
|
||||
RejectedCapacity
|
||||
}
|
||||
|
||||
internal static class AetheriaRuntimePickupTransactions
|
||||
{
|
||||
public static AetheriaRuntimePickupContactResult ApplyContact(
|
||||
AetheriaRuntimeZoneSnapshotCommit zone,
|
||||
AetheriaRuntimeEntitySnapshotCommit entity,
|
||||
AetheriaRuntimeWorldContact contact,
|
||||
AetheriaRuntimeCatalogSnapshot? catalog)
|
||||
{
|
||||
if (zone == null || entity == null || contact == null || !entity.IsActive ||
|
||||
contact.PickupIndex < 0 ||
|
||||
(contact.EntityAIndex != entity.EntityIndex && contact.EntityBIndex != entity.EntityIndex))
|
||||
return AetheriaRuntimePickupContactResult.Ignored;
|
||||
|
||||
var pickups = (zone.DroppedPickups ?? Array.Empty<AetheriaRuntimeDroppedPickupCommit>()).ToList();
|
||||
var index = pickups.FindIndex(pickup => pickup != null && pickup.PickupIndex == pickupIndex);
|
||||
if (index < 0) return false;
|
||||
var index = pickups.FindIndex(pickup => pickup != null && pickup.PickupIndex == contact.PickupIndex);
|
||||
if (index < 0) return AetheriaRuntimePickupContactResult.Ignored;
|
||||
var pickup = pickups[index];
|
||||
var quantity = Math.Max(1, pickup.Item?.Quantity ?? 1);
|
||||
if (pickup.AgeSeconds >= pickup.LifetimeSeconds ||
|
||||
(requireRange && Math.Pow(pickup.PositionX - entity.PositionX, 2) + Math.Pow(pickup.PositionZ - entity.PositionZ, 2) > collectionRange * collectionRange) ||
|
||||
quantity > AetheriaRuntimeCargoCapacityQueries.UnitsThatFit(entity, catalog, pickup.Item?.ItemKey ?? ""))
|
||||
return false;
|
||||
pickup.Item == null)
|
||||
return AetheriaRuntimePickupContactResult.Ignored;
|
||||
var cargoBayCount = (entity.Equipment ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>())
|
||||
.Select(slot => catalog?.FindItem(slot?.Item?.ItemKey ?? ""))
|
||||
.Count(item => item != null && item.InteriorOccupiedCells > 0);
|
||||
var cargoIndex = Enumerable.Range(0, cargoBayCount)
|
||||
.Where(index => quantity <= AetheriaRuntimeCargoCapacityQueries.UnitsThatFit(
|
||||
entity, catalog, pickup.Item.ItemKey ?? "", index))
|
||||
.DefaultIfEmpty(-1)
|
||||
.First();
|
||||
if (cargoIndex < 0)
|
||||
{
|
||||
var normalSign = contact.EntityAIndex == entity.EntityIndex ? 1.0 : -1.0;
|
||||
var length = Math.Sqrt(contact.NormalX * contact.NormalX + contact.NormalZ * contact.NormalZ);
|
||||
var normalX = length > 0.000001
|
||||
? contact.NormalX / length * normalSign
|
||||
: pickup.PositionX >= entity.PositionX ? 1.0 : -1.0;
|
||||
var normalZ = length > 0.000001
|
||||
? contact.NormalZ / length * normalSign
|
||||
: 0.0;
|
||||
pickup.VelocityX += normalX * 25.0;
|
||||
pickup.VelocityZ += normalZ * 25.0;
|
||||
return AetheriaRuntimePickupContactResult.RejectedCapacity;
|
||||
}
|
||||
var bays = (entity.CargoContents ?? Array.Empty<AetheriaRuntimeCargoBayLoadoutCommit>()).ToList();
|
||||
if (bays.Count == 0) bays.Add(new AetheriaRuntimeCargoBayLoadoutCommit());
|
||||
var slots = (bays[0].Items ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>()).ToList();
|
||||
while (bays.Count <= cargoIndex) bays.Add(new AetheriaRuntimeCargoBayLoadoutCommit());
|
||||
var slots = (bays[cargoIndex].Items ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>()).ToList();
|
||||
var existing = slots.FirstOrDefault(slot => string.Equals(slot?.Item?.ItemKey, pickup.Item.ItemKey, StringComparison.Ordinal));
|
||||
if (existing != null) existing.Item.Quantity += quantity;
|
||||
else slots.Add(new AetheriaRuntimeLoadoutItemSlotCommit { Item = pickup.Item });
|
||||
bays[0].Items = slots; entity.CargoContents = bays;
|
||||
bays[cargoIndex].Items = slots; entity.CargoContents = bays;
|
||||
pickups.RemoveAt(index); zone.DroppedPickups = pickups;
|
||||
return true;
|
||||
return AetheriaRuntimePickupContactResult.Collected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -296,7 +296,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
case AetheriaRuntimeDaemonCommandKinds.SetItemEnabled:
|
||||
case AetheriaRuntimeDaemonCommandKinds.SetItemOverrideShutdown:
|
||||
case AetheriaRuntimeDaemonCommandKinds.SetThermotoggleTargetTemperature:
|
||||
case AetheriaRuntimeDaemonCommandKinds.PickUpLoot:
|
||||
case AetheriaRuntimeDaemonCommandKinds.RestoreLoadout:
|
||||
case AetheriaRuntimeDaemonCommandKinds.TransferCargoItem:
|
||||
case AetheriaRuntimeDaemonCommandKinds.EquipItem:
|
||||
|
|
@ -352,7 +351,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
case AetheriaRuntimeDaemonCommandKinds.TransferCargoItem:
|
||||
case AetheriaRuntimeDaemonCommandKinds.EquipItem:
|
||||
case AetheriaRuntimeDaemonCommandKinds.StoreItem:
|
||||
case AetheriaRuntimeDaemonCommandKinds.PickUpLoot:
|
||||
case AetheriaRuntimeDaemonCommandKinds.RestoreLoadout:
|
||||
return true;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -814,6 +814,31 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
EveUnity resolves `effect.feedback.entity.destroyed` only after the provider
|
||||
has published authoritative destruction chronology.
|
||||
|
||||
### Daemon Pickup Contact Transaction
|
||||
|
||||
- Owner: the daemon simulation owns pickup collection by interpreting typed
|
||||
entity-pickup contact facts returned by embedded Ymir physics.
|
||||
- Inputs: the exact Ymir contact, canonical active entity and live pickup,
|
||||
catalog-backed cargo capacity, and current frame identity. Tractor power and
|
||||
range influence pickup motion only.
|
||||
- Outputs: capacity permits one atomic cargo insertion, pickup removal, and
|
||||
`pickup.collected` event. Capacity refusal retains the pickup, applies the
|
||||
fossil 25-unit outward kick along the contact normal, and emits
|
||||
`pickup.rejected`.
|
||||
- Derived state: pickup transforms, tractor visuals, Eve world nodes, Unity
|
||||
colliders, and client selection are presentation or control projections and
|
||||
cannot admit collection.
|
||||
- Forbidden writers: the reserved `PickUpLoot` command, proximity/range scans,
|
||||
Unity collision callbacks, and generic Eve lowerers cannot mutate cargo or
|
||||
despawn pickups.
|
||||
- Shared paths: destruction drops, generated pickups, and restored live pickup
|
||||
rows all enter the same next-tick Ymir body/contact path. Duplicate contact
|
||||
facts for one entity-pickup pair in a frame reduce once; a collected pickup
|
||||
identity cannot commit again.
|
||||
- Cut line: the command executor/builders and distance-based collection helper
|
||||
are deleted. The old enum ordinal remains reserved only to avoid shifting
|
||||
serialized command values and is rejected by the daemon.
|
||||
|
||||
- Owner: `Aetheria.State` owns the new typed state spine for durable state.
|
||||
The embedded `GameCult.Aetheria.State.Unity` package owns Unity's runtime
|
||||
typed state file path plus the boot-time state-file probe, and is the landing
|
||||
|
|
|
|||
Loading…
Reference in a new issue