ModernUO/Distribution/Data/Spawns/shared/trammel/PrismOfLight.json
Kamron Batman d8a64f3316
refactor(spawners): replace DynamicJson with typed SpawnerDto records (#2505)
## Summary

Removes the dated `DynamicJson` JSON helper and migrates spawner JSON (de)serialization to a polymorphic `record SpawnerDto` hierarchy. `DynamicJson` was the last remaining consumer (regions moved off it in #1400).

The key correctness improvement: **System.Text.Json deserializes plain DTO records, never a live `Item`.** Previously, deserializing directly into an `Item` meant STJ constructed world-registered objects *before* the data was validated — a malformed/hand-edited spawn file could leave orphaned spawner Items in the world save. Now a parse failure is GC-only; `dto.ToSpawner()` constructs the spawner only from a fully-validated DTO and self-cleans on failure.

## What changed

- **New:** `SpawnerDto` (abstract) + `SpawnerDataDto` / `RegionSpawnerDto` / `ProximitySpawnerDto`, each marked with a reusable `[JsonDiscoverableType]` opt-in attribute. Auto-discovered at the `Configure` phase — no manual registration list (avoids the regions `Register<T>()` footgun), open to custom spawner subtypes.
- **Symmetric mapping:** `BaseSpawner.ToDto()` (export) ⇄ `SpawnerDto.ToSpawner()` (import). `ToSpawner()` deletes-and-rethrows on any failure, so the importer can never orphan an Item.
- **`SpawnerJsonSerializer`** wires `$type` polymorphism on the `SpawnerDto` root with loud collision/constructibility validation.
- **Import/export commands** rewired to the typed DTO path (reflection `FindTypeByName`/`CreateInstance` removed).
- **Data migration:** the 109 `Distribution/Data/Spawns/**` files moved from `"type"`→`"$type"` and legacy `homeRange`→`spawnBounds`. The runtime still *reads* legacy `homeRange` for external files. The `homeRange→spawnBounds` formula is proven equivalent to the runtime conversion (`BoundsEquivalenceTests`, hr=0/1/3/7).
- **Deleted:** `Projects/Server/Json/DynamicJson.cs`.

Sparse export output matches the legacy `ToJson` (nullable DTO properties + `WhenWritingNull`). Binary world-save serialization is untouched.

## Tests

- DTO round-trip per spawner type; sparse-default omission; legacy `homeRange` read; export/import file round-trip.
- `Import_MalformedFile_LeaksNoWorldItems` — proves a mid-array parse failure constructs zero world Items.
- `AllSpawnFilesLoadTests` — every migrated spawn file deserializes and builds.
- Duplicate-discriminator validation.
- UOContent.Tests 485/485, Server.Tests 710/710, build clean.

## Follow-up (not in this PR)

`Rectangle3DConverter.Write` (in `Projects/Server/`) omits `z1/z2` when `Start.Z == -128`, so a future server-side export of a `homeRange`-style spawner round-trips depth 256→255. Pre-existing and out of scope here (Server change); the migrated data reads correctly. Worth a separate small converter PR.
2026-06-25 23:24:45 -07:00

347 lines
8.6 KiB
JSON

[
{
"$type": "Spawner",
"guid": "19d77ed8-3a64-4317-9570-c8a19dc885ed",
"name": "Spawner (116)",
"location": [6536, 79, -10],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "CrystalDaemon", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "2b5f366f-9197-4fb0-842c-d7e50f9d3395",
"name": "Spawner (116)",
"location": [6478, 174, 4],
"map": "Trammel",
"count": 6,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 10,
"entries": [
{ "name": "Wisp", "maxCount": 6, "probability": 100 },
{ "name": "CrystalWisp", "maxCount": 6, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "2bdadfea-e542-43dd-8391-a0a55761bd09",
"name": "Spawner (116)",
"location": [6509, 176, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "UnfrozenMummy", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "3ad2e27a-0fe6-44eb-9a7e-1840e2333414",
"name": "Spawner (116)",
"location": [6572, 89, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "CrystalHydra", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "3ce801dd-1e54-4eb6-b908-d095fc3ac3d6",
"name": "Spawner (116)",
"location": [6521, 139, -20],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "Wisp", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "44ede0db-e4a9-4fc2-bbd4-41741dc3a138",
"name": "Spawner (116)",
"location": [6552, 155, 0],
"map": "Trammel",
"count": 6,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 15,
"walkingRange": 15,
"entries": [
{ "name": "Wisp", "maxCount": 5, "probability": 100 },
{ "name": "CrystalWisp", "maxCount": 5, "probability": 100 },
{ "name": "TreasureChestLevel2", "maxCount": 5, "probability": 100 },
{ "name": "TreasureChestLevel2", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "4664466b-b753-46bf-8d9a-4c66246ed060",
"name": "Spawner (116)",
"location": [6553, 157, 0],
"map": "Trammel",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "CrystalLatticeSeeker", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "500789a1-6c13-4c8c-94c4-d7290a6d9238",
"name": "Spawner (116)",
"location": [6576, 91, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "CrystalSeaSerpent", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "57899529-d774-4c8f-a5b3-263237a5cb74",
"name": "Spawner (116)",
"location": [6507, 151, 0],
"map": "Trammel",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 5,
"walkingRange": 5,
"entries": [
{ "name": "Protector", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "5a151ef4-7184-49a1-b516-e2e5ba7973f4",
"name": "Spawner (116)",
"location": [6566, 120, 0],
"map": "Trammel",
"count": 7,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 15,
"walkingRange": 15,
"entries": [
{ "name": "CrystalVortex", "maxCount": 7, "probability": 100 },
{ "name": "IceElemental", "maxCount": 7, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "5e2e128a-5312-4afc-858f-4ee70783f6c8",
"name": "Spawner (116)",
"location": [6534, 178, 0],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "CrystalWisp", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "68fe4e5a-136b-4f9d-8b23-1289f26cbfb3",
"name": "Spawner (116)",
"location": [6547, 91, -10],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "CrystalDaemon", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "6c1abed9-6d57-4f20-a0e6-1598ab7b0602",
"name": "Spawner (116)",
"location": [6504, 181, 0],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 1,
"walkingRange": 1,
"entries": [
{ "name": "TreasureChestLevel4", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "6d47bfa4-0820-4805-865d-7a7f3e54e159",
"name": "Spawner (116)",
"location": [6510, 171, 0],
"map": "Trammel",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "Protector", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "70250ff2-f75d-4f6a-adcd-e32d3f8c05e4",
"name": "Spawner (116)",
"location": [6474, 74, -34],
"map": "Trammel",
"count": 9,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "Rat", "maxCount": 9, "probability": 100 },
{ "name": "IceSnake", "maxCount": 9, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "9e39061c-b9fa-4988-abef-2eac1f2344f3",
"name": "Spawner (116)",
"location": [6578, 183, 31],
"map": "Trammel",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 5,
"walkingRange": 5,
"entries": [
{ "name": "Ferret", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "cb0719bf-0812-4551-a287-3fe92e6dd66b",
"name": "Spawner (116)",
"location": [6475, 101, -44],
"map": "Trammel",
"count": 5,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 5,
"walkingRange": 5,
"entries": [
{ "name": "ShadowWisp", "maxCount": 5, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d4e26c54-212c-4dc9-bbb8-a6e2ecd02d55",
"name": "Spawner (116)",
"location": [6530, 139, -20],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "Wisp", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d8d2b685-7458-494d-a596-90baea5763c8",
"name": "Spawner (116)",
"location": [6535, 179, 0],
"map": "Trammel",
"count": 6,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 15,
"walkingRange": 15,
"entries": [
{ "name": "CrystalWisp", "maxCount": 5, "probability": 100 },
{ "name": "CrystalLatticeSeeker", "maxCount": 5, "probability": 100 },
{ "name": "TreasureChestLevel2", "maxCount": 5, "probability": 100 },
{ "name": "TreasureChestLevel2", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "dbdcaa33-dad3-447b-be16-737b98732315",
"name": "Spawner (116)",
"location": [6532, 79, -10],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 4,
"walkingRange": 4,
"entries": [
{ "name": "CrystalDaemon", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "ed761287-3375-4732-be78-2277dec45e2e",
"name": "Spawner (116)",
"location": [6502, 120, -10],
"map": "Trammel",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 0,
"walkingRange": 0,
"entries": [
{ "name": "TreasureChestLevel3", "maxCount": 1, "probability": 100 }
]
}
]