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:
parent
b4c06b50cb
commit
a2b54889b4
50 changed files with 537 additions and 542 deletions
|
|
@ -1,34 +1,35 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Caching;
|
||||
using MessagePack;
|
||||
using CultMath;
|
||||
using static CultMath.math;
|
||||
|
||||
[MessagePackObject]
|
||||
[CultDocument("aetheria.savedgame", "1"), CultGlobal, MessagePackObject]
|
||||
public class SavedGame
|
||||
{
|
||||
[Key(0)]
|
||||
public SavedZone[] Zones;
|
||||
|
||||
public CultRecordRef<SavedZone>[] Zones;
|
||||
|
||||
[Key(1)]
|
||||
public Guid[] Factions;
|
||||
|
||||
public CultRecordRef<Faction>[] Factions;
|
||||
|
||||
[Key(2)]
|
||||
public Dictionary<int, int> HomeZones;
|
||||
|
||||
|
||||
[Key(3)]
|
||||
public Dictionary<int, int> BossZones;
|
||||
|
||||
|
||||
[Key(4)]
|
||||
public int Entrance;
|
||||
|
||||
|
||||
[Key(5)]
|
||||
public int Exit;
|
||||
|
||||
|
||||
[Key(6)]
|
||||
public int CurrentZone;
|
||||
|
||||
|
||||
[Key(7)]
|
||||
public int CurrentZoneEntity;
|
||||
|
||||
|
|
@ -46,59 +47,61 @@ public class SavedGame
|
|||
|
||||
[Key(12)]
|
||||
public FactionRelationship[] Relationships;
|
||||
|
||||
|
||||
public SavedGame() { }
|
||||
|
||||
public SavedGame(Galaxy galaxy, Zone currentZone, Entity currentEntity)
|
||||
// Writes a SavedZone record for every galaxy zone through the cache.
|
||||
public SavedGame(CultCache cache, Galaxy galaxy, Zone currentZone, Entity currentEntity)
|
||||
{
|
||||
DiscoveredZones = galaxy.DiscoveredZones.Select(dz => Array.IndexOf(galaxy.Zones, dz)).ToArray();
|
||||
Background = galaxy.Background;
|
||||
Factions = galaxy.HomeZones.Keys.Select(f => f.ID).ToArray();
|
||||
var factions = galaxy.HomeZones.Keys.ToArray();
|
||||
Factions = factions.Select(f => cache.RefOf(f)).ToArray();
|
||||
Relationships = galaxy.Factions.Select(f => galaxy.FactionRelationships[f]).ToArray();
|
||||
|
||||
|
||||
HomeZones = galaxy.HomeZones.ToDictionary(
|
||||
x => Array.IndexOf(Factions, x.Key.ID),
|
||||
x => Array.IndexOf(factions, x.Key),
|
||||
x => Array.IndexOf(galaxy.Zones, x.Value));
|
||||
BossZones = galaxy.BossZones.ToDictionary(
|
||||
x => Array.IndexOf(Factions, x.Key.ID),
|
||||
x => Array.IndexOf(factions, x.Key),
|
||||
x => Array.IndexOf(galaxy.Zones, x.Value));
|
||||
|
||||
Zones = galaxy.Zones.Select(zone => new SavedZone
|
||||
|
||||
Zones = galaxy.Zones.Select(zone => cache.Upsert(new SavedZone
|
||||
{
|
||||
Name = zone.Name,
|
||||
Position = zone.Position,
|
||||
AdjacentZones = zone.AdjacentZones.Select(az=> Array.IndexOf(galaxy.Zones, az)).ToArray(),
|
||||
Factions = zone.Factions.Select(f=> Array.IndexOf(Factions, f.ID)).ToArray(),
|
||||
Factions = zone.Factions.Select(f=> Array.IndexOf(factions, f)).ToArray(),
|
||||
Contents = zone.Contents?.PackZone(),
|
||||
Owner = zone.Owner == null ? -1 : Array.IndexOf(Factions, zone.Owner.ID)
|
||||
}).ToArray();
|
||||
Owner = zone.Owner == null ? -1 : Array.IndexOf(factions, zone.Owner)
|
||||
})).ToArray();
|
||||
|
||||
CurrentZone = Array.FindIndex(galaxy.Zones, zone => zone.Contents == currentZone);
|
||||
CurrentZoneEntity = currentZone.Entities.IndexOf(currentEntity);
|
||||
|
||||
|
||||
Entrance = Array.IndexOf(galaxy.Zones, galaxy.Entrance);
|
||||
Exit = Array.IndexOf(galaxy.Zones, galaxy.Exit);
|
||||
}
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
[CultDocument("aetheria.savedzone", "1"), MessagePackObject]
|
||||
public class SavedZone
|
||||
{
|
||||
[Key(0)]
|
||||
public string Name;
|
||||
|
||||
|
||||
[Key(1)]
|
||||
public float2 Position;
|
||||
|
||||
|
||||
[Key(2)]
|
||||
public int[] AdjacentZones;
|
||||
|
||||
|
||||
[Key(3)]
|
||||
public int[] Factions;
|
||||
|
||||
|
||||
[Key(4)]
|
||||
public int Owner;
|
||||
|
||||
|
||||
[Key(5)]
|
||||
public ZonePack Contents;
|
||||
}
|
||||
|
|
@ -115,7 +118,7 @@ public abstract class SavedActionBarBinding
|
|||
[MessagePackObject]
|
||||
public class SavedActionBarConsumableBinding : SavedActionBarBinding
|
||||
{
|
||||
[Key(0)] public DatabaseLink<ConsumableItemData> Target;
|
||||
[Key(0)] public CultRecordRef<ConsumableItemData> Target;
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
|
@ -129,4 +132,4 @@ public class SavedActionBarGearBinding : SavedActionBarBinding
|
|||
public class SavedActionBarWeaponGroupBinding : SavedActionBarBinding
|
||||
{
|
||||
[Key(0)] public int Group;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue