Files

43 lines
1.7 KiB
C#
Raw Permalink Normal View History

namespace Theriapolis.Core.Data;
/// <summary>
/// Phase 6 M0 — bundle of all settlement-stamp content needed to drive
/// <see cref="World.Settlements.SettlementStamper"/>. Held by
/// <see cref="ContentResolver"/>; passed into <see cref="Tactical.TacticalChunkGen"/>
/// as an optional argument so headless tools that don't need full content
/// (e.g. worldgen-dump) can run without it.
/// </summary>
public sealed class SettlementContent
{
public IReadOnlyDictionary<string, BuildingTemplateDef> Buildings { get; }
public IReadOnlyDictionary<string, SettlementLayoutDef> PresetByAnchor { get; }
/// <summary>Tier 1..5 → procedural layout (or null if no procedural layout for that tier).</summary>
public IReadOnlyDictionary<int, SettlementLayoutDef> ProceduralByTier { get; }
public SettlementContent(
IReadOnlyDictionary<string, BuildingTemplateDef> buildings,
IReadOnlyDictionary<string, SettlementLayoutDef> presetByAnchor,
IReadOnlyDictionary<int, SettlementLayoutDef> proceduralByTier)
{
Buildings = buildings;
PresetByAnchor = presetByAnchor;
ProceduralByTier = proceduralByTier;
}
/// <summary>
/// Look up the layout to use for a given settlement, preferring the
/// hand-authored preset for its anchor (if any) and falling back to the
/// procedural layout for its tier.
/// </summary>
public SettlementLayoutDef? ResolveFor(World.Settlement settlement)
{
if (settlement.Anchor is { } anchor &&
PresetByAnchor.TryGetValue(anchor.ToString(), out var preset))
return preset;
if (ProceduralByTier.TryGetValue(settlement.Tier, out var proc))
return proc;
return null;
}
}