diff --git a/Aetheria.State.Daemon.Smoke/Program.cs b/Aetheria.State.Daemon.Smoke/Program.cs index 144504b02..49f8e7558 100644 --- a/Aetheria.State.Daemon.Smoke/Program.cs +++ b/Aetheria.State.Daemon.Smoke/Program.cs @@ -173,6 +173,7 @@ internal sealed class AetheriaDaemonYmirSmokeChecks TractorRampsAndPullsThroughYmirWithoutTeleportingCargo, PickupIsCapacityCheckedExactlyOnceAndExpires, TradePurchaseDerivesAcceptanceFromDaemonState, + TradeSaleIsDaemonPricedSpatialAndAtomic, StationBodiesCannotConsumePickups, PickupShieldContactCollectsOrBounces, YmirRestartDoesNotReplayConsumedPickupContact, @@ -4897,6 +4898,131 @@ internal sealed class AetheriaDaemonYmirSmokeChecks RequireEqual(2, zone.Entities.Count, "forged ship-creation opinion must not materialize an entity"); } + private static void TradeSaleIsDaemonPricedSpatialAndAtomic() + { + var ore = CatalogItem("sale-ore"); + ore.Price = 40; + ore.Stackable = true; + ore.MaxStack = 10; + ore.ShapeWidth = 1; + ore.ShapeHeight = 1; + ore.ShapeCells = [new AetheriaRuntimeShapeCell(0, 0)]; + var cargoBay = CatalogItem("sale-cargo-bay"); + cargoBay.InteriorShapeWidth = 2; + cargoBay.InteriorShapeHeight = 1; + cargoBay.InteriorShapeCells = + [ + new AetheriaRuntimeShapeCell(0, 0), + new AetheriaRuntimeShapeCell(1, 0) + ]; + var catalog = new AetheriaRuntimeCatalogSnapshot([ore, cargoBay], [], []); + + var station = Entity(0, 0, "station"); + station.Kind = "station"; + station.CargoBays = [new AetheriaRuntimeLoadoutItemSlotCommit + { + Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = cargoBay.ItemKey, Quantity = 1 } + }]; + station.CargoContents = [Cargo((ore.ItemKey, 8, 0, 0))]; + station.DockingBayAssignments = [1]; + + var ship = Entity(1, 0, "player"); + ship.CargoBays = [new AetheriaRuntimeLoadoutItemSlotCommit + { + Item = new AetheriaRuntimeLoadoutItemCommit { ItemKey = cargoBay.ItemKey, Quantity = 1 } + }]; + ship.CargoContents = [new AetheriaRuntimeCargoBayLoadoutCommit + { + Items = [new AetheriaRuntimeLoadoutItemSlotCommit + { + X = 0, + Y = 0, + Item = new AetheriaRuntimeLoadoutItemCommit + { + ItemKey = ore.ItemKey, + Quantity = 5, + Quality = 0.75, + Temperature = 333 + } + }] + }]; + + var run = new AetheriaRuntimeRunCheckpointCommit + { + RunId = "trade-sale-smoke", + CurrentZoneIndex = 0, + CurrentEntityKey = "zone.0.entity.1", + Credits = 100, + Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [station, ship] }] + }; + var sale = AetheriaRuntimeDaemonCommandDocument.Create( + AetheriaRuntimeDaemonCommandKinds.TradeSale, + "pilot", + "trade-sale-smoke", + 1, + run.CurrentEntityKey); + sale.TradeSale.ItemKey = ore.ItemKey; + sale.TradeSale.Quantity = 3; + sale.TradeSale.SourceCargoIndex = 0; + sale.TradeSale.SourceX = 0; + sale.TradeSale.SourceY = 0; + + var unitPrice = AetheriaRuntimeDaemonTradeItemQueries.TradeItemValue( + ore, + ship.CargoContents[0].Items[0].Item, + catalog.TradeValueSettings).Price; + var result = AetheriaRuntimeDaemonOperations.Execute( + run, + [sale], + new AetheriaRuntimeDaemonOperationContext { Catalog = catalog }); + + Require(result.AppliedCommandIds.Contains(sale.CommandId), + "valid docked sale must commit through the daemon economy transaction"); + RequireEqual(100 + unitPrice * 3, run.Credits, + "sale payout must be derived from the authoritative source instance and catalog"); + RequireEqual(2, CargoQuantity(ship, ore.ItemKey), + "sale must remove exactly the accepted quantity from seller cargo"); + RequireEqual(11, CargoQuantity(station, ore.ItemKey), + "station stock must receive the exact sold quantity"); + RequireEqual(10, station.CargoContents[0].Items[0].Item.Quantity, + "station stock must fill the first compatible stack before allocating a new cell"); + var allocated = station.CargoContents[0].Items.Single(slot => slot.X == 1 && slot.Y == 0); + RequireEqual(1, allocated.Item.Quantity, + "station stock overflow must use the first free authored cargo cell"); + RequireNear(0.75, allocated.Item.Quality, 0.000001, + "sale placement must preserve source instance quality"); + RequireNear(333, allocated.Item.Temperature, 0.000001, + "sale placement must preserve source instance temperature"); + + station.CargoContents[0].Items[1].Item.Quantity = 10; + var rejectedSale = AetheriaRuntimeDaemonCommandDocument.Create( + AetheriaRuntimeDaemonCommandKinds.TradeSale, + "pilot", + "trade-sale-smoke", + 2, + run.CurrentEntityKey); + rejectedSale.TradeSale.ItemKey = ore.ItemKey; + rejectedSale.TradeSale.Quantity = 1; + rejectedSale.TradeSale.SourceCargoIndex = 0; + rejectedSale.TradeSale.SourceX = 0; + rejectedSale.TradeSale.SourceY = 0; + var creditsBeforeRejection = run.Credits; + result = AetheriaRuntimeDaemonOperations.Execute( + run, + [rejectedSale], + new AetheriaRuntimeDaemonOperationContext { Catalog = catalog }); + + Require(result.RejectedCommandIds.Contains(rejectedSale.CommandId), + "station stock without spatial capacity must reject the sale"); + RequireEqual(AetheriaRuntimeDaemonRejectionReasons.TradeStationNoFit, + result.RejectedCommandReasons[rejectedSale.CommandId], + "full station stock must expose the exact trade rejection reason"); + RequireEqual(creditsBeforeRejection, run.Credits, + "rejected sale must not credit the seller"); + RequireEqual(2, CargoQuantity(ship, ore.ItemKey), + "rejected sale must not remove seller cargo"); + } + private static void StationBodiesCannotConsumePickups() { var hull = CatalogItem("station-filter-hull"); hull.HullCapacity = PerformanceStat(1); diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 42b814204..7a76a6baf 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -107,6 +107,7 @@ RequireLootPickupRequestAuthority(root); RequireEntityDestroyedRequestAuthority(root); RequireDroppedPickupCheckpointState(root); RequireTradePurchaseRequestAuthority(root); +RequireTradeSaleAuthority(root); RequireInventoryDocumentSlotIdentity(root); RequireInventoryValidationUsesManagedTypedDocuments(root); RequireMenuDockingUsesManagedTypedSnapshot(root); @@ -20120,6 +20121,90 @@ static void RequireTradePurchaseRequestAuthority(string root) } } +static void RequireTradeSaleAuthority(string root) +{ + var runtime = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime"); + var documents = File.ReadAllText(Path.Combine(runtime, "AetheriaRuntimeDaemonDocuments.cs")); + var operations = File.ReadAllText(Path.Combine(runtime, "AetheriaRuntimeDaemonOperations.cs")); + var operationClient = File.ReadAllText(Path.Combine(runtime, "AetheriaRuntimeDaemonOperationClient.cs")); + var surfaceClient = File.ReadAllText(Path.Combine(runtime, "AetheriaRuntimeDaemonOperationsClient.cs")); + var inputCapabilities = File.ReadAllText(Path.Combine(runtime, "AetheriaRuntimeInputCapabilityDocuments.cs")); + + var required = new Dictionary + { + ["command contract"] = + [ + "TradeSale", + "public sealed class AetheriaRuntimeTradeSaleCommand", + "public AetheriaRuntimeTradeSaleCommand TradeSale" + ], + ["daemon transaction"] = + [ + "ApplyTradeSale(run, command, context)", + "AetheriaRuntimeRefitTransactions.TryTransferCargo(", + "run.Credits += (int)payout", + "TradeStationNoFit" + ], + ["operation client"] = + [ + "internal AetheriaRuntimeDaemonCommandEnvelope TradeSale(", + "command.TradeSale.ItemKey", + "command.TradeSale.Quantity" + ], + ["generic Eve translation"] = + [ + "public CultMeshOperationReceipt TradeSale(", + "AetheriaRuntimeDaemonCommandKinds.TradeSale => client.TradeSale(" + ], + ["advertised gameplay lever"] = + [ + "trade.sell.", + "Sell {typedItem.Name}", + "\"TradeSale\"" + ] + }; + var sources = new Dictionary + { + ["command contract"] = documents, + ["daemon transaction"] = operations, + ["operation client"] = operationClient, + ["generic Eve translation"] = surfaceClient, + ["advertised gameplay lever"] = inputCapabilities + }; + var missing = required + .SelectMany(group => group.Value + .Where(symbol => !sources[group.Key].Contains(symbol, StringComparison.Ordinal)) + .Select(symbol => $"{group.Key}: {symbol}")) + .ToArray(); + if (missing.Length > 0) + { + throw new InvalidOperationException( + "Docked sale no longer crosses the complete daemon/Eve authority boundary: " + + string.Join(", ", missing)); + } + + var forbiddenClientOpinions = new[] + { + "TradeSale.UnitPrice", + "TradeSale.TotalPrice", + "TradeSale.StationEntityKey", + "TradeSale.StationCargoIndex" + }; + var clientOpinionHits = forbiddenClientOpinions + .Where(symbol => operationClient.Contains(symbol, StringComparison.Ordinal) || + surfaceClient.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (clientOpinionHits.Length > 0) + { + throw new InvalidOperationException( + "Trade sale client still supplies daemon-owned station or payout opinions: " + + string.Join(", ", clientOpinionHits)); + } + + Console.WriteLine( + "Trade sale authority: generic Eve advertises source-stack intent; daemon owns station placement and payout"); +} + static void RequireLootPickupRequestAuthority(string root) { var actionGameManagerPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "ActionGameManager.cs"); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs index 38b5085cc..397ce1a40 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaControl.cs @@ -178,6 +178,14 @@ namespace GameCult.Aetheria.State.Verse sourceX, sourceY); + public CultMeshOperationReceipt TradeSale( + string itemKey, + int quantity, + int sourceCargoIndex, + int sourceX, + int sourceY) => + _operations.TradeSale(itemKey, quantity, sourceCargoIndex, sourceX, sourceY); + public CultMeshOperationReceipt RestoreLoadout( string dockedEntityKey, string templateName, diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs index 39b0e4a00..223107359 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonDocuments.cs @@ -196,7 +196,8 @@ namespace GameCult.Aetheria.State.Verse IssueAgentTask, CancelAgentTask, SetSimulationRate, - AdvanceSimulationStep + AdvanceSimulationStep, + TradeSale } [CultDocument("gamecult.aetheria.daemon_provider_advertisement", "gamecult.aetheria.daemon_provider_advertisement.v1")] @@ -440,6 +441,8 @@ namespace GameCult.Aetheria.State.Verse return nameof(AetheriaRuntimeCargoTransferCommand); case AetheriaRuntimeDaemonCommandKinds.TradePurchase: return nameof(AetheriaRuntimeTradePurchaseCommand); + case AetheriaRuntimeDaemonCommandKinds.TradeSale: + return nameof(AetheriaRuntimeTradeSaleCommand); case AetheriaRuntimeDaemonCommandKinds.RestoreLoadout: return nameof(AetheriaRuntimeLoadoutRestoreCommand); case AetheriaRuntimeDaemonCommandKinds.EquipItem: @@ -672,6 +675,9 @@ namespace GameCult.Aetheria.State.Verse [Key(30)] public AetheriaRuntimeAgentTaskCommand AgentTask { get; set; } = new AetheriaRuntimeAgentTaskCommand(); + [Key(31)] + public AetheriaRuntimeTradeSaleCommand TradeSale { get; set; } = new AetheriaRuntimeTradeSaleCommand(); + public static AetheriaRuntimeDaemonCommandDocument Create( AetheriaRuntimeDaemonCommandKinds kind, string clientId, @@ -905,6 +911,18 @@ namespace GameCult.Aetheria.State.Verse } + [MessagePackObject] + public sealed class AetheriaRuntimeTradeSaleCommand + { + // The daemon derives station identity, destination bay, unit value, + // payout, and stock placement from authoritative state. + [Key(0)] public string ItemKey { get; set; } = ""; + [Key(1)] public int Quantity { get; set; } = 1; + [Key(2)] public int SourceCargoIndex { get; set; } = -1; + [Key(3)] public int SourceX { get; set; } = int.MinValue; + [Key(4)] public int SourceY { get; set; } = int.MinValue; + } + public static class AetheriaRuntimeDaemonReceiptProjector { public static EveCommandReceiptDocument Project( diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs index 6fb041bc4..92c2c3722 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationClient.cs @@ -477,6 +477,28 @@ namespace GameCult.Aetheria.State.Verse return Send(command); } + internal AetheriaRuntimeDaemonCommandEnvelope TradeSale( + AetheriaRuntimeDaemonFrameDocument? frame, + string itemKey, + int quantity, + int sourceCargoIndex, + int sourceX, + int sourceY) + { + var command = Create(AetheriaRuntimeDaemonCommandKinds.TradeSale, frame); + command.TextValue = itemKey ?? ""; + command.EquipmentIndex = sourceCargoIndex; + command.PositionX = sourceX; + command.PositionY = sourceY; + command.ScalarValue = quantity; + command.TradeSale.ItemKey = itemKey ?? ""; + command.TradeSale.Quantity = quantity; + command.TradeSale.SourceCargoIndex = sourceCargoIndex; + command.TradeSale.SourceX = sourceX; + command.TradeSale.SourceY = sourceY; + return Send(command); + } + internal AetheriaRuntimeDaemonCommandEnvelope RestoreLoadout( AetheriaRuntimeDaemonFrameDocument? frame, string dockedEntityKey, diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs index 5ccdae231..84fe25163 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperations.cs @@ -82,6 +82,10 @@ namespace GameCult.Aetheria.State.Verse public const string InvalidCargoSource = "invalid-cargo-source"; public const string CargoNoFit = "cargo-no-fit"; public const string CargoStackLimit = "cargo-stack-limit"; + public const string TradeRequiresDocked = "trade-requires-docked"; + public const string InvalidTradeSource = "invalid-trade-source"; + public const string TradeStationNoFit = "trade-station-no-fit"; + public const string InvalidTradePayout = "invalid-trade-payout"; } public static class AetheriaRuntimeDaemonOperations @@ -200,6 +204,8 @@ namespace GameCult.Aetheria.State.Verse return ApplyToggleHullConductivity(run, command); case AetheriaRuntimeDaemonCommandKinds.TradePurchase: return ApplyTradePurchase(run, command, context.Catalog); + case AetheriaRuntimeDaemonCommandKinds.TradeSale: + return ApplyTradeSale(run, command, context); case AetheriaRuntimeDaemonCommandKinds.RestoreLoadout: return ApplyRestoreLoadout(run, command, context); case AetheriaRuntimeDaemonCommandKinds.SetMoveVector: @@ -1032,6 +1038,76 @@ namespace GameCult.Aetheria.State.Verse return true; } + private static bool ApplyTradeSale( + AetheriaRuntimeRunCheckpointCommit run, + AetheriaRuntimeDaemonCommandDocument command, + AetheriaRuntimeDaemonOperationContext context) + { + var sale = command.TradeSale ?? new AetheriaRuntimeTradeSaleCommand(); + var catalog = context.Catalog; + if (catalog == null || sale.Quantity <= 0 || string.IsNullOrWhiteSpace(sale.ItemKey)) + return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidTradeSource); + + if (!TryResolveEntity(run, run.CurrentEntityKey, out _, out _, out var seller) || + !TryResolveDockParent(run, run.CurrentEntityKey, out _, out var station) || + !IsEntityDockedAt(run, run.CurrentEntityKey, station)) + { + return context.Reject(AetheriaRuntimeDaemonRejectionReasons.TradeRequiresDocked); + } + + var sellerCargo = seller.CargoContents ?? Array.Empty(); + if (sale.SourceCargoIndex < 0 || sale.SourceCargoIndex >= sellerCargo.Count || + !TryFindCargoItem( + sellerCargo[sale.SourceCargoIndex], + sale.ItemKey, + sale.SourceX, + sale.SourceY, + out var sourceSlot) || + sourceSlot.Item == null || + sale.Quantity > sourceSlot.Item.Quantity) + { + return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidTradeSource); + } + + var typedItem = catalog.FindItem(sale.ItemKey); + var unitPrice = AetheriaRuntimeDaemonTradeItemQueries.TradeItemValue( + typedItem, + sourceSlot.Item, + catalog.TradeValueSettings).Price; + var payout = (long)unitPrice * sale.Quantity; + if (typedItem == null || unitPrice < 0 || payout < 0 || payout > int.MaxValue - (long)run.Credits) + return context.Reject(AetheriaRuntimeDaemonRejectionReasons.InvalidTradePayout); + + var stationBayCount = Math.Min( + station.CargoBays?.Count ?? 0, + station.CargoContents?.Count ?? 0); + for (var stationCargoIndex = 0; stationCargoIndex < stationBayCount; stationCargoIndex++) + { + if (!AetheriaRuntimeRefitTransactions.TryTransferCargo( + seller, + sale.SourceCargoIndex, + sale.SourceX, + sale.SourceY, + station, + stationCargoIndex, + sale.ItemKey, + sale.Quantity, + 0, + 0, + false, + catalog, + out _)) + { + continue; + } + + run.Credits += (int)payout; + return true; + } + + return context.Reject(AetheriaRuntimeDaemonRejectionReasons.TradeStationNoFit); + } + private static bool TryResolveDockParent( AetheriaRuntimeRunCheckpointCommit run, string childEntityKey, diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs index 7676e3f09..10bb42d1f 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonOperationsClient.cs @@ -311,6 +311,22 @@ public sealed class AetheriaRuntimeDaemonOperationsClient sourceY)); } + public CultMeshOperationReceipt TradeSale( + string itemKey, + int quantity, + int sourceCargoIndex, + int sourceX, + int sourceY) + { + return Send((client, frame) => client.TradeSale( + frame, + itemKey, + quantity, + sourceCargoIndex, + sourceX, + sourceY)); + } + public CultMeshOperationReceipt RestoreLoadout( string dockedEntityKey, string templateName, @@ -507,6 +523,13 @@ public sealed class AetheriaRuntimeDaemonOperationsClient (int)ReadPayloadDouble(request, "targetCargoIndex", -1), (int)ReadPayloadDouble(request, "sourceX", int.MinValue), (int)ReadPayloadDouble(request, "sourceY", int.MinValue)), + AetheriaRuntimeDaemonCommandKinds.TradeSale => client.TradeSale( + frame, + ReadPayloadString(request, "itemKey", ""), + (int)ReadPayloadDouble(request, "quantity", 1), + (int)ReadPayloadDouble(request, "sourceCargoIndex", -1), + (int)ReadPayloadDouble(request, "sourceX", int.MinValue), + (int)ReadPayloadDouble(request, "sourceY", int.MinValue)), _ => AetheriaRuntimeDaemonSurfaceCommandCatalog.TrySubmitArgumentless( client, frame, diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs index 178921839..84b4b1f07 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeInputCapabilityDocuments.cs @@ -164,6 +164,46 @@ namespace GameCult.Aetheria.State.Verse yield return action; } } + + var sellerCargo = entity.CargoContents ?? Array.Empty(); + for (var bayIndex = 0; bayIndex < sellerCargo.Count; bayIndex++) + { + foreach (var slot in sellerCargo[bayIndex]?.Items ?? Array.Empty()) + { + var itemKey = slot?.Item?.ItemKey ?? ""; + var typedItem = catalog.FindItem(itemKey); + if (typedItem == null || slot?.Item == null || slot.Item.Quantity <= 0) + continue; + + var value = AetheriaRuntimeDaemonTradeItemQueries.TradeItemValue( + typedItem, + slot.Item, + catalog.TradeValueSettings).Price; + var stationCanReceive = Enumerable.Range(0, parent.CargoBays?.Count ?? 0) + .Any(stationBayIndex => + stationBayIndex < (parent.CargoContents?.Count ?? 0) && + AetheriaRuntimeCargoCapacityQueries.UnitsThatFit( + parent, + catalog, + itemKey, + stationBayIndex) > 0); + var action = Action( + $"trade.sell.{StableToken(itemKey)}.{bayIndex}.{slot.X}.{slot.Y}", + $"Sell {typedItem.Name} (+{value})", + "TradeSale", + "trade", + $"{run.CurrentEntityKey}#cargo/{bayIndex}/{slot.X}/{slot.Y}", + ("itemKey", itemKey), + ("quantity", "1"), + ("sourceCargoIndex", bayIndex.ToString()), + ("sourceX", slot.X.ToString()), + ("sourceY", slot.Y.ToString())); + action.Availability = value >= 0 && stationCanReceive + ? "available" + : "unavailable"; + yield return action; + } + } } private static string StableToken(string value) => diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseAuthorityPolicy.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseAuthorityPolicy.cs index 66cde5be2..50abacec2 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseAuthorityPolicy.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseAuthorityPolicy.cs @@ -303,6 +303,7 @@ namespace GameCult.Aetheria.State.Verse case AetheriaRuntimeDaemonCommandKinds.ToggleHullConductivity: return AetheriaRuntimeClaimKinds.Inventory; case AetheriaRuntimeDaemonCommandKinds.TradePurchase: + case AetheriaRuntimeDaemonCommandKinds.TradeSale: return AetheriaRuntimeClaimKinds.Economy; case AetheriaRuntimeDaemonCommandKinds.SetEntityName: return AetheriaRuntimeClaimKinds.Metadata; @@ -345,6 +346,7 @@ namespace GameCult.Aetheria.State.Verse case AetheriaRuntimeDaemonCommandKinds.SetDockedCurrentShip: case AetheriaRuntimeDaemonCommandKinds.TowToStation: case AetheriaRuntimeDaemonCommandKinds.TradePurchase: + case AetheriaRuntimeDaemonCommandKinds.TradeSale: case AetheriaRuntimeDaemonCommandKinds.TransferCargoItem: case AetheriaRuntimeDaemonCommandKinds.EquipItem: case AetheriaRuntimeDaemonCommandKinds.StoreItem: diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index efd9266b9..dde9ba62e 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -1797,6 +1797,13 @@ First Aetheria surfaces to publish: but no longer subtracts credits, transfers purchased cargo, or constructs purchased ships directly. The daemon owns the purchase mutation and typed run checkpoint. + - Done: make docked sale a daemon-owned atomic economy transaction. The + command identifies only the seller cargo cell and quantity; the daemon + derives the dock parent, instance-sensitive catalog value, payout, and + first fitting typed station-stock placement. Generic Eve action rows are + derived availability levers. Clients cannot name a station, payout, or + destination stock cell, and a rejected placement changes neither cargo + nor credits. - Done: move TradeMenu dynamic behavior columns onto typed behavior payload fields; the menu no longer hydrates `ItemData` or `BehaviorData` for row display, filtering, sorting, or buy decisions. diff --git a/docs/original-game-migration-matrix.md b/docs/original-game-migration-matrix.md index 35ac70a54..2f899d807 100644 --- a/docs/original-game-migration-matrix.md +++ b/docs/original-game-migration-matrix.md @@ -30,7 +30,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity. | Dock/undock | wormhole-first interact; first eligible bay; component prerequisites | daemon + Ymir placement | dock commands/context | camera/UI transition | daemon docking now preserves the fossil transaction: stable zone order selects the first entity with a real empty bay inside the fixed 25-unit XZ center radius; undock checks installed Cockpit, Thruster-or-AetherDrive, Reactor, then empty bay cargo in source order; rejection reasons survive committed command facts into generic Eve receipts; success removes parentage without moving, stopping, or rotating the ship. Ymir world entities retain gravity/query bodies but do not invent ship/station rigidbody collision response that would make the 25-unit rule unreachable; ship/pickup Begin contacts remain enabled. The live generic Unity witness also proves advertised actions, bay assignment, dock-parent SoA inclusion and sensor sharing, camera retargeting, controlled-subject hiding, movement suppression, and restoration on undock | reconnect, docked inventory/trade surfaces, and authored dock-camera blend/effect chronology | | Wormhole travel | `ActionGameManager.EnterWormhole` plus `Ship` enter/exit state | daemon fixed-step transition plus Ymir exclusion | current-entity transition state and feedback chronology | provider-selected generic transition lowering | command acceptance no longer moves an entity immediately; player interact, explicit travel, and agent routing derive the same canonical adjacent-zone wormhole and proximity gate, then persist four-second `entering`, authoritative transfer, four-second `exiting`, and one-frame `completed` phases. The daemon owns smootherstep XZ motion, the fossil 1000-unit visual-depth lever, deterministic 20-unit exit direction, 50-unit exit radius, target-adjacency discovery, and exactly-once start/transfer/completion events. Flight and every world-physics implementation receive no transitioning body; Ymir resumes on the tick after completion. Smoke serializes and rehydrates mid-entry and proves agents traverse multi-edge routes through the same command boundary | generic provider transition effect/camera lowering and live multi-zone pilot witness | | Inventory/equipment | `Entity.ItemFits`, `TryEquip`, `TryUnequip`, `EquippedCargoBay.ItemFits`/`TryStore`, inventory panels + ServerShared | daemon atomic inventory transactions | typed inventory/equipment state, commands, exact receipts | generic UI | generated cargo and docking bays now occupy their typed collections instead of masquerading as ordinary equipment; docked equip/reposition/store validates the complete destination on cloned state before committing either side, uses authored hull interior and hardpoint geometry, forces hardpoint rotation, rejects occupied cells and deployed ships, preserves exact item instance fields and weapon-group membership, routes bay categories with aligned content/assignment arrays, and refuses to unequip nonempty/occupied bays. Cargo transfer now uses the same plan-first rule with typed bay interiors, rotated item footprints, deterministic free-cell search, exact stack maxima, and no partial source/destination mutation on rejection; exact reasons reach generic Eve receipts | live generic refit controls, reconnect after accepted and rejected moves, commodity multi-stack chronology, and full fossil inventory feedback parity | -| Trade | trade UI/economy | daemon | stock, quote, purchase commands | generic UI | daemon derives station, stock row, catalog item, current price, quantity, credits, target capacity, and hull-vs-cargo result; Eve advertises only currently available stock actions; generic Unity live witness receives an authoritative purchase receipt while paused | sell flow, quote expiry, contested stock, and full trade surface parity | +| Trade | trade UI/economy | daemon | stock, quote, purchase/sale commands | generic UI | daemon derives station, stock row, catalog item, current price, quantity, credits, target capacity, and hull-vs-cargo result; purchases ignore client opinions about price and destination kind. Docked sales identify only the source stack and quantity: the daemon derives station, instance-sensitive value, payout, deterministic typed stock placement, and commits cargo/credits atomically; generic Eve advertises available buy and sell actions. The generic Unity live witness receives an authoritative purchase receipt while paused | live sale receipt witness, quote expiry, contested stock, and full trade surface parity | | Action bar/input | input shell and rebinding UI | daemon advertises actions; client owns bindings | input capability and action descriptors | universal binding UI | contracts wired; cargo actions are catalog-filtered to consumables the current actor can actually activate, including suppression of active non-stackable items | dynamic equipment behavior validity and runtime action-bar quantity/fill proof | | Pilot camera | ARPG follow/dock cameras | Eve view semantics + runtime | camera rig and semantic view id | EveUnity camera rig | daemon dock state selects distinct contracts instead of collapsing both fossil cameras: undocked flight advertises the entity-forward `Third Person Rig` framing (distance 30, screen 0.64/0.19, FOV 60, lens 1-4096) and the shared `aim.presentation` convergence point as its look-at; Aetheria translates the fossil Cinemachine top-origin screen Y of `0.81` to Eve's bottom-origin viewport Y of `0.19`; EveUnity solves native pose while preserving both optical aim and advertised entity framing, without provider types; the retained dock projection remains separate | reproduce the dock camera's separate follow/look-at subjects, blend timeline, noise, and reconnect state | | Render channels | Unity layers/culling masks | provider surface policy + runtime asset variant | semantic channel exclusions | EveUnity native layer mapping | wired, exclusive, and lowered: the pilot surface excludes the semantic `map` channel; the Unity asset variant maps `map` to its authored native layer; EveUnity subtracts that layer from the configured camera mask; portable state contains no Unity layer or mask; provider conversion preserves the source icon shader's unlit lighting model; the released witness proves the pilot camera excludes map glyphs while the map camera retains readable white glyphs without a scene light | preserve the channel proof while world presentation and transport continue to evolve |