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

322 lines
8.2 KiB
JSON

[
{
"$type": "Spawner",
"guid": "01ae830b-c7f9-4857-8a6b-4bacca6758ad",
"name": "Spawner (212)",
"location": [5356, 1304, 0],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 10,
"entries": [
{ "name": "OrcBomber", "maxCount": 1, "probability": 100 },
{ "name": "OrcCaptain", "maxCount": 1, "probability": 100 },
{ "name": "Orc", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "03b59250-db54-481c-85f4-1d0b8b433252",
"name": "Spawner (212)",
"location": [5153, 1971, 0],
"map": "Felucca",
"count": 5,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "Orc", "maxCount": 5, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "0e858157-adc4-4963-a34b-101fefb109d1",
"name": "Spawner (212)",
"location": [5308, 1372, 0],
"map": "Felucca",
"count": 1,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "Noble", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "1a6833ee-9e32-4900-ad6e-87926e8fb427",
"name": "Spawner (212)",
"location": [5316, 1332, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "GiantRat", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "1bff583d-3643-4e60-9a44-e3dea6882a02",
"name": "Spawner (212)",
"location": [5308, 2005, 0],
"map": "Felucca",
"count": 5,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 12,
"walkingRange": 12,
"entries": [
{ "name": "OrcBrute", "maxCount": 1, "probability": 100 },
{ "name": "Orc", "maxCount": 4, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "2d24f1f9-20ff-4ee1-8f31-8304e2e4822d",
"name": "Spawner (212)",
"location": [5310, 1969, 0],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 12,
"walkingRange": 12,
"entries": [
{ "name": "OrcBomber", "maxCount": 2, "probability": 100 },
{ "name": "Orc", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "40c5eacc-9b5d-49f4-b13d-c605a32f6816",
"name": "Spawner (212)",
"location": [5354, 1332, 0],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "OrcCaptain", "maxCount": 1, "probability": 100 },
{ "name": "OrcishLord", "maxCount": 1, "probability": 100 },
{ "name": "OrcishMage", "maxCount": 1, "probability": 100 },
{ "name": "OrcBomber", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "471bb8b3-f768-4654-a3ae-9517ecc8dd45",
"name": "Spawner (212)",
"location": [5317, 1309, 0],
"map": "Felucca",
"count": 6,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "OrcishLord", "maxCount": 1, "probability": 100 },
{ "name": "OrcishMage", "maxCount": 2, "probability": 100 },
{ "name": "OrcBomber", "maxCount": 1, "probability": 100 },
{ "name": "Orc", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "5145b262-72b3-4bf2-8a73-91efe509ce18",
"name": "Spawner (212)",
"location": [5144, 1960, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "OrcishLord", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "572a2fac-11c7-4583-837a-1b03eae15f85",
"name": "Spawner (212)",
"location": [5146, 1995, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "Orc", "maxCount": 1, "probability": 100 },
{ "name": "OrcCaptain", "maxCount": 1, "probability": 100 },
{ "name": "OrcishLord", "maxCount": 1, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "593ee3b4-df42-426d-8976-faced7cd2435",
"name": "Spawner (212)",
"location": [5302, 1355, 0],
"map": "Felucca",
"count": 4,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 12,
"entries": [
{ "name": "OrcishLord", "maxCount": 1, "probability": 100 },
{ "name": "Orc", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "70960aad-63ab-4bc2-9784-0ae5db883fe1",
"name": "Spawner (212)",
"location": [5331, 1346, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "DireWolf", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "81a40400-c93d-42f3-8f19-0e9492198a82",
"name": "Spawner (212)",
"location": [5292, 1316, 0],
"map": "Felucca",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "Corpser", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "a1dbbaf6-03e3-42f2-ba42-35d88349fd0c",
"name": "Spawner (212)",
"location": [5153, 1961, 0],
"map": "Felucca",
"count": 2,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "DireWolf", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "a70f186a-94a1-4f54-963f-5c039c7d4006",
"name": "Spawner (212)",
"location": [5348, 2011, 0],
"map": "Felucca",
"count": 5,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 10,
"walkingRange": 15,
"entries": [
{ "name": "OrcBomber", "maxCount": 1, "probability": 100 },
{ "name": "EarthElemental", "maxCount": 4, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d01dca90-9fac-438e-9660-a93e9df7fc58",
"name": "Spawner (212)",
"location": [5281, 2029, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "Orc", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "d313d866-1199-45fc-a72c-018d146bbe8c",
"name": "Spawner (212)",
"location": [5300, 1314, 0],
"map": "Felucca",
"count": 6,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 10,
"entries": [
{ "name": "Orc", "maxCount": 3, "probability": 100 },
{ "name": "OrcishMage", "maxCount": 1, "probability": 100 },
{ "name": "OrcishLord", "maxCount": 2, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "ee800978-f2bf-47e0-8e19-c7f5fe0b33bc",
"name": "Spawner (212)",
"location": [5332, 1365, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "Orc", "maxCount": 3, "probability": 100 }
]
},
{
"$type": "Spawner",
"guid": "fe0be93b-5f45-40b0-9169-16df378c0e6e",
"name": "Spawner (212)",
"location": [5141, 1968, 0],
"map": "Felucca",
"count": 3,
"minDelay": "00:05:00",
"maxDelay": "00:10:00",
"team": 0,
"homeRange": 8,
"walkingRange": 8,
"entries": [
{ "name": "OrcCaptain", "maxCount": 3, "probability": 100 }
]
}
]