Make equipped behavior graphs executable daemon input
This commit is contained in:
parent
f011d81c9f
commit
21c469565a
5 changed files with 196 additions and 1 deletions
|
|
@ -20,8 +20,96 @@ internal sealed class AetheriaDaemonYmirSmokeChecks
|
|||
AgentCompletesHaulTaskThroughMovementAndCargoCommands();
|
||||
RejectedHaulTransferDoesNotAdvanceTask();
|
||||
AgentPatrolsHistoricalOrbitCircuitThroughMovementCommands();
|
||||
TickReconcilesAndEvaluatesCatalogBehaviors();
|
||||
}
|
||||
|
||||
private static void TickReconcilesAndEvaluatesCatalogBehaviors()
|
||||
{
|
||||
var entity = Entity(0, 0, "workers");
|
||||
entity.Equipment =
|
||||
[
|
||||
new AetheriaRuntimeLoadoutItemSlotCommit
|
||||
{
|
||||
Item = new AetheriaRuntimeLoadoutItemCommit
|
||||
{
|
||||
ItemKey = "mining-tool",
|
||||
Quality = 1,
|
||||
Durability = 1,
|
||||
Enabled = true
|
||||
}
|
||||
}
|
||||
];
|
||||
entity.BehaviorStates = Array.Empty<AetheriaRuntimeBehaviorStateCommit>();
|
||||
var payload = new AetheriaRuntimeBehaviorPayload(
|
||||
0,
|
||||
"MiningTool",
|
||||
0,
|
||||
[
|
||||
new AetheriaRuntimeBehaviorField(1, PerformanceStat(12)),
|
||||
new AetheriaRuntimeBehaviorField(2, PerformanceStat(0.8)),
|
||||
new AetheriaRuntimeBehaviorField(3, PerformanceStat(2)),
|
||||
new AetheriaRuntimeBehaviorField(4, PerformanceStat(50))
|
||||
]);
|
||||
var catalog = new AetheriaRuntimeCatalogSnapshot(
|
||||
[CatalogItem("mining-tool", payload)],
|
||||
Array.Empty<AetheriaRuntimeCorporation>(),
|
||||
Array.Empty<AetheriaRuntimeNameFile>());
|
||||
var run = new AetheriaRuntimeRunCheckpointCommit
|
||||
{
|
||||
RunId = "behavior-query-smoke",
|
||||
CurrentZoneIndex = 0,
|
||||
CurrentEntityKey = "zone.0.entity.0",
|
||||
Zones = [new AetheriaRuntimeZoneSnapshotCommit { ZoneIndex = 0, Entities = [entity] }]
|
||||
};
|
||||
|
||||
AetheriaRuntimeDaemonTickRunner.Tick(
|
||||
Path.Combine(Path.GetTempPath(), "aetheria-behavior-query-smoke.cc"),
|
||||
run,
|
||||
new AetheriaRuntimeDaemonTickOptions
|
||||
{
|
||||
FrameId = 1,
|
||||
FixedDeltaSeconds = 0,
|
||||
Catalog = catalog,
|
||||
BuildPublications = false
|
||||
});
|
||||
|
||||
var behavior = AetheriaRuntimeEquippedBehaviorQueries.Find(entity, catalog, "MiningTool").Single();
|
||||
RequireEqual("MiningTool", behavior.State.BehaviorKind,
|
||||
"tick must reconcile equipped catalog payloads into persistent behavior state");
|
||||
RequireNear(12, behavior.EvaluateStat(1), 0.000001, "behavior query must evaluate mining damage from catalog");
|
||||
RequireNear(50, behavior.EvaluateStat(4), 0.000001, "behavior query must evaluate mining range from catalog");
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeBehaviorValue PerformanceStat(double value) => new(
|
||||
"performance-stat",
|
||||
"",
|
||||
0,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
[Number(value), Number(value), Number(0), Number(0), Number(0)],
|
||||
Array.Empty<AetheriaRuntimeBehaviorMapEntry>());
|
||||
|
||||
private static AetheriaRuntimeBehaviorValue Number(double value) => new(
|
||||
"number",
|
||||
"",
|
||||
value,
|
||||
false,
|
||||
"",
|
||||
"",
|
||||
Array.Empty<AetheriaRuntimeBehaviorValue>(),
|
||||
Array.Empty<AetheriaRuntimeBehaviorMapEntry>());
|
||||
|
||||
private static AetheriaRuntimeCatalogItem CatalogItem(string itemKey, params AetheriaRuntimeBehaviorPayload[] payloads) => new(
|
||||
itemKey, itemKey, "equipment", "", "", 0, 1, 1, 1, 1,
|
||||
1, 1, 1, Array.Empty<AetheriaRuntimeShapeCell>(),
|
||||
0, 0, 0, Array.Empty<AetheriaRuntimeShapeCell>(),
|
||||
Array.Empty<AetheriaRuntimeHardpoint>(), payloads,
|
||||
"utility", "", payloads.Select(payload => payload.Kind).ToArray(),
|
||||
1, false, 0, 1, "", "", "", "", "",
|
||||
0, 1000, Array.Empty<AetheriaRuntimeCurveKey>(), "", 1, 0, 0, 0, false,
|
||||
0, 0, "", Array.Empty<AetheriaRuntimeAudioStat>(), Array.Empty<AetheriaRuntimeCurveKey>(), "", "");
|
||||
|
||||
private static void AgentPatrolsHistoricalOrbitCircuitThroughMovementCommands()
|
||||
{
|
||||
var agent = Entity(0, 0, "workers");
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
run ??= new AetheriaRuntimeRunCheckpointCommit();
|
||||
options ??= new AetheriaRuntimeDaemonTickOptions();
|
||||
options.OperationContext ??= new AetheriaRuntimeDaemonOperationContext();
|
||||
EnsureBehaviorStates(run, options.Catalog);
|
||||
|
||||
var observedCommands = (options.ObservedCommands ?? Array.Empty<AetheriaRuntimeDaemonCommandDocument>())
|
||||
.Where(command => command != null)
|
||||
|
|
@ -273,6 +274,20 @@ namespace GameCult.Aetheria.State.Verse
|
|||
editorSurface);
|
||||
}
|
||||
|
||||
private static void EnsureBehaviorStates(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
AetheriaRuntimeCatalogSnapshot? catalog)
|
||||
{
|
||||
if (catalog == null)
|
||||
return;
|
||||
foreach (var entity in (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
|
||||
.Where(zone => zone != null)
|
||||
.SelectMany(zone => zone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>()))
|
||||
{
|
||||
AetheriaRuntimeBehaviorStateProjector.EnsureEquipmentBehaviorStates(entity, catalog);
|
||||
}
|
||||
}
|
||||
|
||||
private static void StampZoneSimulationTime(
|
||||
AetheriaRuntimeRunCheckpointCommit run,
|
||||
double simulationTimeSeconds)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace GameCult.Aetheria.State.Verse
|
||||
{
|
||||
public sealed class AetheriaRuntimeEquippedBehavior
|
||||
{
|
||||
public AetheriaRuntimeEquippedBehavior(
|
||||
int equipmentIndex,
|
||||
int behaviorIndex,
|
||||
AetheriaRuntimeLoadoutItemCommit item,
|
||||
AetheriaRuntimeCatalogItem catalogItem,
|
||||
AetheriaRuntimeBehaviorPayload payload,
|
||||
AetheriaRuntimeBehaviorStateCommit state)
|
||||
{
|
||||
EquipmentIndex = equipmentIndex;
|
||||
BehaviorIndex = behaviorIndex;
|
||||
Item = item;
|
||||
CatalogItem = catalogItem;
|
||||
Payload = payload;
|
||||
State = state;
|
||||
}
|
||||
|
||||
public int EquipmentIndex { get; }
|
||||
public int BehaviorIndex { get; }
|
||||
public AetheriaRuntimeLoadoutItemCommit Item { get; }
|
||||
public AetheriaRuntimeCatalogItem CatalogItem { get; }
|
||||
public AetheriaRuntimeBehaviorPayload Payload { get; }
|
||||
public AetheriaRuntimeBehaviorStateCommit State { get; }
|
||||
|
||||
public double EvaluateStat(int fieldKey, double thermalPerformance = 1.0)
|
||||
{
|
||||
var field = (Payload.Fields ?? Array.Empty<AetheriaRuntimeBehaviorField>())
|
||||
.FirstOrDefault(candidate => candidate != null && candidate.Key == fieldKey);
|
||||
return AetheriaRuntimeDaemonItemStatQueries.EvaluatePerformanceStat(
|
||||
field?.Value,
|
||||
Item,
|
||||
Math.Max(0, Math.Min(1, thermalPerformance)));
|
||||
}
|
||||
}
|
||||
|
||||
public static class AetheriaRuntimeEquippedBehaviorQueries
|
||||
{
|
||||
public static IReadOnlyList<AetheriaRuntimeEquippedBehavior> Find(
|
||||
AetheriaRuntimeEntitySnapshotCommit? entity,
|
||||
AetheriaRuntimeCatalogSnapshot? catalog,
|
||||
string behaviorKind)
|
||||
{
|
||||
if (entity == null || catalog == null || string.IsNullOrWhiteSpace(behaviorKind))
|
||||
return Array.Empty<AetheriaRuntimeEquippedBehavior>();
|
||||
|
||||
AetheriaRuntimeBehaviorStateProjector.EnsureEquipmentBehaviorStates(entity, catalog);
|
||||
var states = (entity.BehaviorStates ?? Array.Empty<AetheriaRuntimeBehaviorStateCommit>())
|
||||
.Where(state => state != null && string.Equals(state.OwnerKind, AetheriaRuntimeBehaviorStateProjector.EquipmentOwnerKind, StringComparison.Ordinal))
|
||||
.ToDictionary(state => (state.OwnerIndex, state.BehaviorIndex));
|
||||
var found = new List<AetheriaRuntimeEquippedBehavior>();
|
||||
var equipment = entity.Equipment ?? Array.Empty<AetheriaRuntimeLoadoutItemSlotCommit>();
|
||||
for (var equipmentIndex = 0; equipmentIndex < equipment.Count; equipmentIndex++)
|
||||
{
|
||||
var item = equipment[equipmentIndex]?.Item;
|
||||
var catalogItem = catalog.FindItem(item?.ItemKey ?? "");
|
||||
if (item == null || catalogItem == null)
|
||||
continue;
|
||||
|
||||
var payloads = catalogItem.BehaviorPayloads ?? Array.Empty<AetheriaRuntimeBehaviorPayload>();
|
||||
for (var behaviorIndex = 0; behaviorIndex < payloads.Count; behaviorIndex++)
|
||||
{
|
||||
var payload = payloads[behaviorIndex];
|
||||
if (payload == null ||
|
||||
!AetheriaRuntimeBehaviorMetadataCatalog.IsKindOrDescendant(payload.Kind, behaviorKind) ||
|
||||
!states.TryGetValue((equipmentIndex, behaviorIndex), out var state))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
found.Add(new AetheriaRuntimeEquippedBehavior(
|
||||
equipmentIndex,
|
||||
behaviorIndex,
|
||||
item,
|
||||
catalogItem,
|
||||
payload,
|
||||
state));
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2b7af91c0bad4b87a6550e9e0217dad6
|
||||
|
|
@ -40,7 +40,7 @@ validation proves contract shape, not wiring, exclusivity, lowering, or parity.
|
|||
| Save/resume | original persistence paths | daemon/CultCache | published current state | clients rehydrate | owner-exists; not parity-proven | mid-loop restart |
|
||||
| Terminus loop | original game composition | daemon/Ymir/Eve | pilot surface | Aetheria.Unity | incomplete; no scenario proof | fly/fire/loot/dock/trade |
|
||||
| Starbridge | original/shared architecture intent | one daemon session | pilot + commander surfaces | Unity + Electron | commander task board and autonomous explore execution wired; Electron Eve lowering and split-target proof missing | commander orders plus four pilots and autonomous workers |
|
||||
| Behavior engine | `ServerShared/Behaviors` composition | daemon | executable action/status projection | action bar and feedback | reference | every behavior family and modifier lifecycle |
|
||||
| Behavior engine | `ServerShared/Behaviors` composition | daemon | executable action/status projection | action bar and feedback | tick reconciles equipped catalog payloads into persistent behavior state; shared evaluated-stat query proven; execution families remain partial | every behavior family, ordering, resource transaction and modifier lifecycle |
|
||||
| Sensors/visibility | decaying sources and observer information thresholds | daemon | contacts and ping events | indicators/maps | reference | threshold, decay, ping and classification timelines |
|
||||
| AI/tasks | corporation task scheduler plus agent state machines | daemon | commander task board and shared semantic controls | Eve commander/pilot clients | explore, attack, same-zone haul, and persistent orbit patrol wired through shared commands; capability/priority assignment and rejected-transfer behavior proven | original optimum-range control, cross-zone haul, mining, towing, survey-tool timelines, cancellation and reconnect |
|
||||
| Consumables | cargo-backed timed behavior containers | daemon | dynamic actions and active effects | action bar/schematic | reference | consume, stacking, duration and cleanup |
|
||||
|
|
|
|||
Loading…
Reference in a new issue