Hide legacy catalog reader behind ItemManager
This commit is contained in:
parent
be1c8801ed
commit
fabbd088e2
8 changed files with 34 additions and 17 deletions
Binary file not shown.
|
|
@ -468,7 +468,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
args =>
|
||||
{
|
||||
var itemName = string.Join(" ", args);
|
||||
var item = ItemManager.ItemData.GetAll<EquippableItemData>()
|
||||
var item = ItemManager.GetCatalogEntries<EquippableItemData>()
|
||||
.FirstOrDefault(itemData => string.Equals(itemData.Name, itemName, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (item != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public static class EntitySerializer
|
|||
private static void Restore(ItemManager itemManager, Zone zone, EntityPack pack, Entity entity, bool instantiate = false)
|
||||
{
|
||||
entity.Name = pack.Name;
|
||||
entity.Faction = itemManager.ItemData.Get<Faction>(pack.Faction);
|
||||
entity.Faction = itemManager.GetCatalogEntry<Faction>(pack.Faction);
|
||||
entity.Children = pack.Children.Select(c =>
|
||||
{
|
||||
var child = Unpack(itemManager, zone, c, instantiate);
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ public class ItemManager
|
|||
|
||||
// private Guid _forceLoadZone;
|
||||
|
||||
// public GlobalData GlobalData => _globalData ?? (_globalData = ItemData.GetAll<GlobalData>().FirstOrDefault());
|
||||
public ILegacyCatalogReader ItemData { get; }
|
||||
// public GlobalData GlobalData => _globalData ?? (_globalData = GetCatalogEntries<GlobalData>().FirstOrDefault());
|
||||
private readonly ILegacyCatalogReader _itemData;
|
||||
public GameplaySettings GameplaySettings { get; }
|
||||
|
||||
// public double Time
|
||||
|
|
@ -49,11 +49,21 @@ public class ItemManager
|
|||
|
||||
public ItemManager(ILegacyCatalogReader itemData, GameplaySettings settings, Action<string> logger)
|
||||
{
|
||||
ItemData = itemData;
|
||||
_itemData = itemData;
|
||||
GameplaySettings = settings;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public T GetCatalogEntry<T>(Guid id) where T : DatabaseEntry
|
||||
{
|
||||
return _itemData.Get<T>(id);
|
||||
}
|
||||
|
||||
public IEnumerable<T> GetCatalogEntries<T>() where T : DatabaseEntry
|
||||
{
|
||||
return _itemData.GetAll<T>();
|
||||
}
|
||||
|
||||
public void Log(string s)
|
||||
{
|
||||
_logger(s);
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class LoadoutGenerator
|
|||
|
||||
public T[] RandomItems<T>(int count, float sizeExponent, Predicate<T> filter = null) where T : EquippableItemData
|
||||
{
|
||||
return ItemManager.ItemData.GetAll<T>()
|
||||
return ItemManager.GetCatalogEntries<T>()
|
||||
.Where(item =>
|
||||
item.Price > 0 &&
|
||||
item.Manufacturer != Guid.Empty &&
|
||||
|
|
@ -137,7 +137,7 @@ public class LoadoutGenerator
|
|||
.WeightedRandomElements(ref Random, item =>
|
||||
Faction == null ? 1 :
|
||||
(item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance.ContainsKey(item.Manufacturer) ? Faction.Allegiance[item.Manufacturer] : 0.0f / // Prioritize items from allied manufacturers
|
||||
(Galaxy?.ContainsFaction(item.Manufacturer) ?? false ? Zone?.Distance[Galaxy.HomeZones[ItemManager.ItemData.Get<Faction>(item.Manufacturer)]] ?? 1 : 1)) * // Penalize distance to manufacturer headquarters
|
||||
(Galaxy?.ContainsFaction(item.Manufacturer) ?? false ? Zone?.Distance[Galaxy.HomeZones[ItemManager.GetCatalogEntry<Faction>(item.Manufacturer)]] ?? 1 : 1)) * // Penalize distance to manufacturer headquarters
|
||||
pow(item.Shape.Coordinates.Length, sizeExponent) / // Prioritize larger items
|
||||
pow(item.Price, PriceExponent), // Penalize item price to a controllable degree
|
||||
count
|
||||
|
|
@ -243,4 +243,4 @@ public class InvalidLoadoutException : Exception
|
|||
: base(message, inner)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ public class TradeMenuDebug : MonoBehaviour
|
|||
data => () => $"{data.Shape.Width}x{data.Shape.Height}",
|
||||
data => data.Shape.Width*data.Shape.Height));
|
||||
|
||||
var items = GameManager.ItemManager.ItemData.GetAll<ItemData>().Where(i=>i.Price!=0);
|
||||
var items = GameManager.ItemManager.GetCatalogEntries<ItemData>().Where(i=>i.Price!=0);
|
||||
|
||||
if (MinimumSizeFilter.gameObject.activeSelf)
|
||||
items = items.Where(i =>
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ public class PropertiesPanel : MonoBehaviour
|
|||
AddProperty("Quantity", () => simpleCommodity.Quantity.ToString());
|
||||
|
||||
var sheet = AddStatSheet();
|
||||
var manufacturer = GameManager.ItemManager.ItemData.Get<Faction>(data.Manufacturer);
|
||||
var manufacturer = GameManager.ItemManager.GetCatalogEntry<Faction>(data.Manufacturer);
|
||||
sheet.AddStat("Manufacturer", () => manufacturer?.Name ?? "GameCult");
|
||||
sheet.AddStat("Mass", () => ActionGameManager.PlayerSettings.Format(GameManager.ItemManager.GetMass(item)));
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
methods are also deleted, so the legacy cache implementation exposes
|
||||
deserialization only. UI code no longer reaches into
|
||||
`LegacyCatalogBoundary.GetCatalog` directly.
|
||||
- `ItemManager` no longer exposes the raw `ILegacyCatalogReader` as public
|
||||
gameplay/UI API. Item, faction, loadout, trade, and entity restore consumers
|
||||
now go through narrow `ItemManager.GetCatalogEntry<T>` and
|
||||
`GetCatalogEntries<T>` methods. This does not remove the legacy reader under
|
||||
the hood; it prevents old catalog authority from leaking into every caller
|
||||
that only needs a domain lookup.
|
||||
- `DatabaseLink<T>.Value` can resolve legacy links only after
|
||||
`LegacyCatalogBoundary` binds the pull-only catalog cache. Legacy catalog
|
||||
construction no longer grabs global `DatabaseLinkBase` authority.
|
||||
|
|
@ -176,11 +182,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
`ActionGameManager.LegacyCatalog` is the only Unity runtime access point for
|
||||
old MessagePack catalog reads, and `LegacyCatalogBoundary` is the only named
|
||||
owner for opening the old catalog and binding legacy `DatabaseLink<T>`
|
||||
resolution until catalog migration lands. Runtime code receives
|
||||
`ILegacyCatalogReader`, not the concrete cache. `Aetheria.State.Unity` owns a
|
||||
read-only typed catalog facade for future Unity consumers; it does not write
|
||||
state or own simulation. The legacy cache no longer has a public mutation
|
||||
surface.
|
||||
resolution until catalog migration lands. Runtime code receives narrow
|
||||
`ItemManager` catalog methods where gameplay only needs lookups; `ItemManager`
|
||||
and `Galaxy` still receive `ILegacyCatalogReader` until typed runtime catalog
|
||||
boot replaces them. `Aetheria.State.Unity` owns a read-only typed catalog
|
||||
facade for future Unity consumers; it does not write state or own simulation.
|
||||
The legacy cache no longer has a public mutation surface.
|
||||
- Inputs: Unity gameplay code, legacy catalog files, typed state documents, and
|
||||
CultMesh server state.
|
||||
- Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy
|
||||
|
|
@ -221,8 +228,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
- Shared paths: gameplay input, editor edits, import/deep-load, replication,
|
||||
simulation ticks, and tests all call the same typed state service.
|
||||
- Deletion line: after catalog migration smokes pass, replace
|
||||
`ActionGameManager.LegacyCatalog`/`ItemManager` boot with the typed runtime
|
||||
catalog package, then delete or quarantine the remaining
|
||||
`ActionGameManager.LegacyCatalog`/`ItemManager`/`Galaxy` boot with the typed
|
||||
runtime catalog package, then delete or quarantine the remaining
|
||||
`LegacyCatalogCache`/`DatabaseEntry` runtime catalog dependency and remove old
|
||||
MessagePack backing store classes from live Unity source.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue