Move the ServerShared data model onto CultLib's CultCache

Cut 8b. Aetheria.Shared builds headless against GameCult.Caching and
GameCult.Caching.MessagePack at the pinned CultLib; the pin guard also
checks the Caching project exists.

Documents: [CultDocument("aetheria.<type>", "1")] with [MessagePackObject]
and integer [Key]s on the Q7 concrete types (the eight ItemData leaves,
Faction, FactionProductData, PersonalityAttribute, NameFile, OrbitData, the
four BodyData leaves, SavedZone, SavedGame, PlayerSettings, InputLayout).
SavedGame and PlayerSettings are [CultGlobal]; Name members are [CultName].
ItemData, CraftedItemData, EquippableItemData, BodyData and AgentTask lose
[MessagePackObject]; BodyData and AgentTask lose their [Union]s. InputLayout
moves into ServerShared so AetheriaStores can route it.

References: Guid and DatabaseLink<T> members become CultRecordRef<T>;
Guid-keyed maps become ref-keyed with [CultReference(..., many: true)];
ZonePack holds refs to orbit and body records. Runtime maps (Zone orbits,
bodies and belts, cargo ItemsOfType, agent targets) key by CultRecordKey.
Identity is the record key: ID comparisons become reference or key
comparisons. StatModifierData.RequireBehavior is a simple type name.

AetheriaStores.Open composes the catalog (read-only unless writable), run
and player stores, one home per type. CultRecordRefs carries IsSet, a
null-safe Get(ref), RefOf (key from TryGetHandle) and Upsert.
ItemManager.GetData is the one item resolution path. MathResolver is
declared by [assembly: CultCacheFormatterResolver].

Inspector attributes: text, range and asset path map onto CultLib's
CultInspector attributes (asset path only on string members); every
replaced Aetheria attribute keeps [Inspectable] for the runtime panel.

Builds: Aetheria.Shared. Does not build: AetherDb and the Unity project,
which follow.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-14 19:00:42 +02:00
commit a2b54889b4
50 changed files with 537 additions and 542 deletions

View file

@ -1,4 +1,5 @@
using GameCult.Caching;
using System;
using CultMath;
using static CultMath.math;
@ -29,7 +30,7 @@ public abstract class MoveToState : BaseState
public class MoveToOrbitState : MoveToState
{
public Guid Orbit { get; set; }
public CultRecordKey Orbit { get; set; }
public MoveToOrbitState(Agent agent) : base(agent) { }
protected override float2 TargetPosition => _agent.Ship.Zone.GetOrbitPosition(Orbit);

View file

@ -1,31 +1,23 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
Union(0, typeof(StationTowing)),
Union(1, typeof(Mining)),
Union(2, typeof(Survey)),
Union(3, typeof(HaulingTask)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
public abstract class AgentTask : DatabaseEntry
// Agent tasks are owned by their Agent and not persisted.
[JsonObject(MemberSerialization.OptIn)]
public abstract class AgentTask
{
[JsonProperty("priority"), Key(1)]
public int Priority;
[JsonProperty("zone"), Key(2)]
public Guid Zone;
[JsonProperty("reserved"), Key(3)]
public bool Reserved;
[IgnoreMember] public abstract TaskType Type { get; }
}

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using GameCult.Caching;
using System;
using System.Collections;
using System.Collections.Generic;
@ -19,7 +20,7 @@ public class HaulingTask : AgentTask
public Entity Target;
[JsonProperty("itemType"), Key(6)]
public Guid ItemType;
public CultRecordKey ItemType;
[JsonProperty("quantity"), Key(7)]
public int Quantity;

View file

@ -2,19 +2,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using GameCult.Caching;
using System;
using System.Collections;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
JsonObject(MemberSerialization.OptIn)]
public class Mining : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Mine;
[JsonProperty("asteroids"), Key(4)]
public Guid Asteroids;
public CultRecordKey Asteroids;
}

View file

@ -1,15 +1,16 @@
using GameCult.Caching;
using System;
public class PatrolOrbitsTask : AgentTask
{
public override TaskType Type => TaskType.Defend;
public Guid[] Circuit;
public CultRecordKey[] Circuit;
}
public class PatrolOrbitsState : BaseState
{
public PatrolOrbitsTask Task;
public Guid CurrentTarget
public CultRecordKey CurrentTarget
{
get => Task.Circuit[_currentTargetIndex];
}

View file

@ -2,15 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using GameCult.Caching;
using System;
using System.Collections;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
JsonObject(MemberSerialization.OptIn)]
public class StationTowing : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Tow;
@ -19,7 +19,7 @@ public class StationTowing : AgentTask
public OrbitalEntity Station;
[JsonProperty("orbitParent"), Key(5)]
public Guid OrbitParent;
public CultRecordKey OrbitParent;
[JsonProperty("orbitDistance"), Key(6)]
public float OrbitDistance;

View file

@ -2,19 +2,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using GameCult.Caching;
using System;
using System.Collections;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
JsonObject(MemberSerialization.OptIn)]
public class Survey : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Explore;
[JsonProperty("station"), Key(4)]
public List<Guid> Planets;
public List<CultRecordKey> Planets;
}