using Theriapolis.Core.Data; using Theriapolis.Core.Tactical; namespace Theriapolis.Core.Rules.Combat; /// /// Maps a + chunk's /// to the actual that should spawn there. /// Lookup table lives in npc_templates.json's /// spawn_kind_to_template_by_zone map (loaded into /// ). /// /// Returns null when no template is configured for the spawn kind/zone (the /// caller should skip that spawn — chunk is silently denser, that's OK). /// public static class NpcInstantiator { public static NpcTemplateDef? PickTemplate( SpawnKind kind, int dangerZone, NpcTemplateContent content) { if (kind == SpawnKind.None) return null; string kindKey = kind.ToString(); if (!content.SpawnKindToTemplateByZone.TryGetValue(kindKey, out var byZone)) return null; if (byZone.Length == 0) return null; // Clamp the zone index to the table's length. int zoneIdx = System.Math.Clamp(dangerZone, 0, byZone.Length - 1); string templateId = byZone[zoneIdx]; foreach (var t in content.Templates) if (string.Equals(t.Id, templateId, System.StringComparison.OrdinalIgnoreCase)) return t; return null; } }