ModernUO/Distribution/Data/Spawns/shared/felucca/Destard.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

481 lines
13 KiB
JSON

[
{
"$type": "Spawner",
"guid": "0fbce341-ca59-4ec4-a718-cc8f7b3ed34e",
"name": "Spawner (206)",
"location": [5247, 956, -40],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "171e7677-5e0b-4da4-8599-9c3c16200e7a",
"name": "Spawner (206)",
"location": [5141, 968, 0],
"map": "Felucca",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 10,
"entries": [
{ "name": "FireElemental", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "326c64f4-34d3-414d-a79c-c7bb9d441e96",
"name": "Spawner (206)",
"location": [5149, 907, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 15,
"walkingRange": 20,
"entries": [
{ "name": "Wyvern", "maxCount": 1, "probability": 100 },
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "3e318f8e-aec0-4b16-b435-43dc4fde4372",
"name": "Spawner (206)",
"location": [5241, 945, -40],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 10,
"entries": [
{ "name": "TreasureChestLevel3", "maxCount": 1, "probability": 100 },
{ "name": "TreasureChestLevel4", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "48b37663-ddee-4f04-978d-35f4c085f785",
"name": "Spawner (206)",
"location": [5269, 811, 7],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 2, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "4f8eb77e-64cb-4846-8c0f-0816f16c94b3",
"name": "Spawner (206)",
"location": [5352, 934, -5],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 10,
"entries": [
{ "name": "WaterElemental", "maxCount": 4, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "506ce404-853e-4168-9b6b-1296d40c90e3",
"name": "Spawner (206)",
"location": [5183, 1007, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 10,
"entries": [
{ "name": "TreasureChestLevel3", "maxCount": 1, "probability": 100 },
{ "name": "TreasureChestLevel4", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "59c245e9-e59f-4f6c-b3cb-2add65aba939",
"name": "Spawner (206)",
"location": [5203, 787, 5],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 12,
"walkingRange": 25,
"entries": [
{ "name": "WaterElemental", "maxCount": 4, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "79707431-23e6-4347-a89e-7bc970162938",
"name": "Spawner (206)",
"location": [5280, 955, -40],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 2, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "7dfd256b-c903-4a4f-abf1-bdce7ff2217b",
"name": "Spawner (206)",
"location": [5284, 926, -40],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 2, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "831f9d08-398c-42b0-bc53-72e1c0685e34",
"name": "Spawner (206)",
"location": [5294, 842, 0],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "WaterElemental", "maxCount": 4, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "87114b5e-ac9d-4d7f-90c1-c6db7a570c2f",
"name": "Spawner (206)",
"location": [5226, 826, 0],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 2, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "889ccd57-8eda-4910-9790-2dc3bc80ca99",
"name": "Spawner (206)",
"location": [5214, 917, -40],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 2, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "8b681dd7-a815-4513-85e6-901967f4e6ed",
"name": "Spawner (206)",
"location": [5143, 986, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 10,
"entries": [
{ "name": "TreasureChestLevel3", "maxCount": 1, "probability": 100 },
{ "name": "TreasureChestLevel4", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "936bde4a-dce6-44bb-859c-81a3e1f0a87b",
"name": "Spawner (206)",
"location": [5307, 815, 0],
"map": "Felucca",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Drake", "maxCount": 1, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "9641ac5e-6eec-4f35-8536-226265c67ace",
"name": "Spawner (206)",
"location": [5205, 778, 0],
"map": "Felucca",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 7,
"walkingRange": 7,
"entries": [
{ "name": "TreasureChestLevel3", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "ad446354-3f49-4c9d-ab1d-dea29378794e",
"name": "Spawner (206)",
"location": [5157, 997, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 20,
"walkingRange": 50,
"entries": [
{ "name": "Wyvern", "maxCount": 3, "probability": 100 },
{ "name": "Wyvern", "maxCount": 3, "probability": 100 },
{ "name": "GiantSerpent", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "b6125064-8514-4c32-953d-c28eca82fa4e",
"name": "Spawner (206)",
"location": [5229, 841, 1],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 10,
"entries": [
{ "name": "TreasureChestLevel2", "maxCount": 1, "probability": 100 },
{ "name": "TreasureChestLevel3", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "be7b487d-c201-413a-94c8-8201dc3a1c4d",
"name": "Spawner (206)",
"location": [5141, 834, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Drake", "maxCount": 1, "probability": 100 },
{ "name": "ShadowWyrm", "maxCount": 1, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d045c909-34f1-46a6-8d61-7275dc6e45c9",
"name": "Spawner (206)",
"location": [5317, 980, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 7,
"walkingRange": 7,
"entries": [
{ "name": "TreasureChestLevel3", "maxCount": 1, "probability": 100 },
{ "name": "TreasureChestLevel4", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d8aceeb2-7644-4b3d-96de-4e172f41abd6",
"name": "Spawner (206)",
"location": [5153, 842, 0],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 40,
"walkingRange": 40,
"entries": [
{ "name": "TreasureChestLevel4", "maxCount": 4, "probability": 100 },
{ "name": "TreasureChestLevel3", "maxCount": 4, "probability": 100 },
{ "name": "TreasureChestLevel2", "maxCount": 4, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "e2bea874-3646-4dec-8fc9-cbc0c67f2a0a",
"name": "Spawner (206)",
"location": [5250, 869, 0],
"map": "Felucca",
"count": 6,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "GiantSerpent", "maxCount": 6, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "e6703676-d851-4394-b09f-51286d5d85f2",
"name": "Spawner (206)",
"location": [5185, 1006, 0],
"map": "Felucca",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 20,
"walkingRange": 50,
"entries": [
{ "name": "AncientWyrm", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "e8017d92-b455-4ab2-b484-f95b2957b3be",
"name": "Spawner (206)",
"location": [5209, 965, -40],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Dragon", "maxCount": 1, "probability": 100 },
{ "name": "Drake", "maxCount": 2, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "edd4aa65-92a9-491c-97e8-d9906e31fbea",
"name": "Spawner (206)",
"location": [5169, 836, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 30,
"walkingRange": 50,
"entries": [
{ "name": "Daemon", "maxCount": 2, "probability": 100 },
{ "name": "EvilMage", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "ef6d6675-0683-47e4-b236-bfc890a12227",
"name": "Spawner (206)",
"location": [5141, 915, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 25,
"walkingRange": 25,
"entries": [
{ "name": "TreasureChestLevel2", "maxCount": 1, "probability": 100 },
{ "name": "TreasureChestLevel3", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "f2aa7cb3-ff27-4ea9-a2a4-fe62a0e78b76",
"name": "Spawner (206)",
"location": [5152, 869, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 25,
"walkingRange": 50,
"entries": [
{ "name": "Drake", "maxCount": 1, "probability": 100 },
{ "name": "ShadowWyrm", "maxCount": 1, "probability": 100 },
{ "name": "Wyvern", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "f5973fd2-89b7-405a-bdea-4b1f2fafa92d",
"name": "Spawner (206)",
"location": [5161, 940, 0],
"map": "Felucca",
"count": 6,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 20,
"walkingRange": 50,
"entries": [
{ "name": "GiantSerpent", "maxCount": 6, "probability": 100 }
]
}
]