Use typed catalog for loadout item candidates
This commit is contained in:
parent
c91ade1dad
commit
8e77e67dba
5 changed files with 62 additions and 7 deletions
Binary file not shown.
|
|
@ -515,12 +515,14 @@ public class ActionGameManager : MonoBehaviour
|
|||
var loadoutGenerator = IsTutorial ? new LoadoutGenerator(
|
||||
ref ItemManager.Random,
|
||||
ItemManager,
|
||||
RuntimeCatalog,
|
||||
CurrentGalaxy,
|
||||
Zone.GalaxyZone,
|
||||
nearestFaction,
|
||||
.5f) : new LoadoutGenerator(
|
||||
ref ItemManager.Random,
|
||||
ItemManager,
|
||||
RuntimeCatalog,
|
||||
CurrentGalaxy,
|
||||
Zone.GalaxyZone,
|
||||
nearestFaction,
|
||||
|
|
@ -647,6 +649,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
galaxyZone.PackedContents ??= ZoneGenerator.GenerateZone(
|
||||
ItemManager,
|
||||
RuntimeCatalog,
|
||||
Settings.ZoneSettings,
|
||||
CurrentGalaxy,
|
||||
galaxyZone,
|
||||
|
|
@ -731,7 +734,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
{
|
||||
SectorMap.QueueZoneReveal(CurrentGalaxy.Entrance.AdjacentZones.Prepend(CurrentGalaxy.Entrance));
|
||||
PopulateLevel(CurrentGalaxy.Entrance);
|
||||
var loadoutGenerator = new LoadoutGenerator(ref ItemManager.Random, ItemManager, CurrentGalaxy, Zone.GalaxyZone, IsTutorial ? CurrentGalaxy.ResolveFaction(Settings.TutorialGenerationSettings.ProtagonistFaction) : null, 2);
|
||||
var loadoutGenerator = new LoadoutGenerator(ref ItemManager.Random, ItemManager, RuntimeCatalog, CurrentGalaxy, Zone.GalaxyZone, IsTutorial ? CurrentGalaxy.ResolveFaction(Settings.TutorialGenerationSettings.ProtagonistFaction) : null, 2);
|
||||
var ship = EntitySerializer.Unpack(
|
||||
ItemManager,
|
||||
Zone,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Unity;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
using Random = Unity.Mathematics.Random;
|
||||
|
|
@ -10,6 +11,7 @@ public class LoadoutGenerator
|
|||
{
|
||||
public Random Random;
|
||||
public ItemManager ItemManager { get; }
|
||||
public AetheriaRuntimeCatalogSnapshot RuntimeCatalog { get; }
|
||||
public Galaxy Galaxy { get; }
|
||||
public GalaxyZone Zone { get; }
|
||||
public Faction Faction { get; }
|
||||
|
|
@ -18,6 +20,7 @@ public class LoadoutGenerator
|
|||
public LoadoutGenerator(
|
||||
ref Random random,
|
||||
ItemManager itemManager,
|
||||
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
|
||||
Galaxy galaxy,
|
||||
GalaxyZone zone,
|
||||
Faction faction,
|
||||
|
|
@ -25,6 +28,7 @@ public class LoadoutGenerator
|
|||
{
|
||||
Random = random;
|
||||
ItemManager = itemManager;
|
||||
RuntimeCatalog = runtimeCatalog ?? throw new InvalidOperationException("Loadout generation requires the typed Aetheria runtime catalog.");
|
||||
Galaxy = galaxy;
|
||||
Zone = zone;
|
||||
Faction = faction;
|
||||
|
|
@ -127,7 +131,16 @@ public class LoadoutGenerator
|
|||
|
||||
public T[] RandomItems<T>(int count, float sizeExponent, Predicate<T> filter = null) where T : EquippableItemData
|
||||
{
|
||||
return ItemManager.GetCatalogEntries<T>()
|
||||
return RuntimeCatalog.EquipmentItems
|
||||
.Where(IsTypedCandidate<T>)
|
||||
.Where(item =>
|
||||
item.Price > 0 &&
|
||||
Guid.TryParse(item.ManufacturerLegacyId, out var manufacturer) &&
|
||||
manufacturer != Guid.Empty &&
|
||||
(Galaxy.IsPrelude || Galaxy.ContainsFaction(manufacturer) &&
|
||||
(Faction == null || Faction.Allegiance.ContainsKey(manufacturer))))
|
||||
.Select(HydrateLegacyItem<T>)
|
||||
.Where(item => item != null)
|
||||
.Where(item =>
|
||||
item.Price > 0 &&
|
||||
item.Manufacturer != Guid.Empty &&
|
||||
|
|
@ -144,6 +157,34 @@ public class LoadoutGenerator
|
|||
);
|
||||
}
|
||||
|
||||
private static bool IsTypedCandidate<T>(AetheriaRuntimeCatalogItem item) where T : EquippableItemData
|
||||
{
|
||||
var requestedType = typeof(T);
|
||||
if (requestedType == typeof(EquippableItemData))
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(item.HardpointType);
|
||||
}
|
||||
|
||||
if (requestedType == typeof(GearData))
|
||||
{
|
||||
return item.Category is "GearData" or "WeaponItemData";
|
||||
}
|
||||
|
||||
if (requestedType == typeof(CargoBayData))
|
||||
{
|
||||
return item.Category is "CargoBayData" or "DockingBayData";
|
||||
}
|
||||
|
||||
return string.Equals(item.Category, requestedType.Name, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private T HydrateLegacyItem<T>(AetheriaRuntimeCatalogItem item) where T : EquippableItemData
|
||||
{
|
||||
return Guid.TryParse(item.LegacyId, out var legacyId)
|
||||
? ItemManager.GetCatalogEntry<T>(legacyId)
|
||||
: null;
|
||||
}
|
||||
|
||||
private float ManufacturerDistancePenalty(Guid manufacturer)
|
||||
{
|
||||
if (Galaxy == null || Zone == null || !Galaxy.ContainsFaction(manufacturer))
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Unity;
|
||||
using MessagePack;
|
||||
using UniRx;
|
||||
using Unity.Mathematics;
|
||||
|
|
@ -37,6 +38,7 @@ public static class ZoneGenerator
|
|||
|
||||
public static ZonePack GenerateZone(
|
||||
ItemManager itemManager,
|
||||
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
|
||||
ZoneGenerationSettings zoneSettings,
|
||||
Galaxy galaxy,
|
||||
GalaxyZone galaxyZone,
|
||||
|
|
@ -245,7 +247,7 @@ public static class ZoneGenerator
|
|||
LoadoutGenerator GetLoadoutGenerator(Faction faction)
|
||||
{
|
||||
if (!loadoutGenerators.ContainsKey(faction))
|
||||
loadoutGenerators[faction] = new LoadoutGenerator(ref random, itemManager, galaxy, galaxyZone, faction, .5f);
|
||||
loadoutGenerators[faction] = new LoadoutGenerator(ref random, itemManager, runtimeCatalog, galaxy, galaxyZone, faction, .5f);
|
||||
return loadoutGenerators[faction];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
deserialization only. UI code no longer reaches into
|
||||
`LegacyCatalogBoundary.GetCatalog` directly.
|
||||
- `ItemManager` no longer exposes the raw `ILegacyCatalogReader` as public
|
||||
gameplay/UI API. Item instantiation, loadout item selection, and trade consumers
|
||||
gameplay/UI API. Item instantiation and trade 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
|
||||
|
|
@ -97,6 +97,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
corporation projection. The `give` command selects matching items from the
|
||||
typed runtime catalog, then temporarily hydrates the selected legacy
|
||||
`EquippableItemData` by ID only for `ItemManager.CreateInstance`.
|
||||
`LoadoutGenerator` also receives the typed runtime catalog and uses it to own
|
||||
item candidate selection before hydrating selected legacy item DTOs by ID for
|
||||
exact fitting checks and behavior construction.
|
||||
- `Galaxy` generation no longer accepts `ILegacyCatalogReader` or `ItemManager`.
|
||||
Sector and tutorial generation receive the package-owned typed runtime
|
||||
catalog. `Galaxy` projects typed corporation v2 records into temporary legacy
|
||||
|
|
@ -197,6 +200,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
- The `give` command no longer enumerates legacy item catalog entries; typed
|
||||
catalog selection owns the command match, with legacy item hydration kept as
|
||||
an instantiation-only bridge.
|
||||
- `LoadoutGenerator` no longer enumerates legacy item catalog entries for its
|
||||
candidate pool; typed catalog filtering owns the first item selection pass,
|
||||
with legacy DTO hydration kept as a fitting/instantiation bridge.
|
||||
- MessagePack is no longer used as a runtime object-cloning shortcut for
|
||||
`EntitySettings`, and UI/player-settings startup no longer registers the old
|
||||
MessagePack resolver. Resolver registration is confined to legacy catalog
|
||||
|
|
@ -255,9 +261,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
|
|||
contract for full .NET smokes and Eve surface reads. Neither writes state or
|
||||
owns simulation. The legacy cache no longer has a public mutation surface, but
|
||||
it still materializes `ItemManager`. Item properties manufacturer display is
|
||||
a typed snapshot consumer; the give console command is a typed-selection
|
||||
consumer with temporary legacy item instantiation; trade debug and loadout
|
||||
item selection still use `ItemManager` legacy item-domain materialization.
|
||||
a typed snapshot consumer; the give console command and loadout generation
|
||||
are typed-selection consumers with temporary legacy item instantiation; trade
|
||||
debug still uses `ItemManager` legacy item-domain materialization.
|
||||
- Inputs: Unity gameplay code, legacy catalog files, typed state documents, and
|
||||
CultMesh server state.
|
||||
- Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy
|
||||
|
|
@ -412,6 +418,9 @@ First Aetheria surfaces to publish:
|
|||
- Done: move entity faction restore and loadout manufacturer-distance
|
||||
weighting to `Galaxy.ResolveFaction`, so legacy `Faction` catalog entries
|
||||
no longer decide runtime faction references after generation.
|
||||
- Done: move `LoadoutGenerator` item candidate selection to the typed
|
||||
runtime catalog; legacy item DTO hydration remains only for exact fitting
|
||||
checks and behavior construction.
|
||||
- Replace `ActionGameManager` cache bootstrap with the new state runtime.
|
||||
- Convert domain references from GUID/base-class patterns to typed record
|
||||
refs.
|
||||
|
|
|
|||
Loading…
Reference in a new issue