fix: Drastically simplifies regions (#1400)

### Summary
- [X] Gets rid of the Dtos
- [X] Simplifies the json serializer registration
- [X] Adds a custom `RegionByName` JsonConverter that can look up other regions that have already been registered.


### BREAKING CHANGE
1. **Child regions must appear after their parents in the JSON file**
2. In the regions json file, _"Parent"_ can no longer be just a string. It must be an object that includes the map.
      - ```json
        "Parent": { "Name": "Britain", "Map": "Felucca" }
        ```
This commit is contained in:
Kamron Batman 2023-05-19 16:39:40 -07:00 committed by GitHub
parent 734d20cbaf
commit 0a9bfb0558
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
47 changed files with 542 additions and 470 deletions

View file

@ -134,7 +134,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 1492, "y1": 1602, "z1": 0, "x2": 1500, "y2": 1621, "z2": 128},
@ -155,7 +155,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Wheatfield in Britain 1",
"Priority": 50,
"Area": [{"x1": 1120, "y1": 1776, "x2": 1152, "y2": 1808}],
@ -164,7 +164,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Wheatfield in Britain 2",
"Priority": 50,
"Area": [{"x1": 1184, "y1": 1808, "x2": 1216, "y2": 1840}],
@ -173,7 +173,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Wheatfield in Britain 3",
"Priority": 50,
"Area": [{"x1": 1216, "y1": 1872, "x2": 1248, "y2": 1904}],
@ -182,7 +182,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Carrot Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1208, "y1": 1712, "x2": 1224, "y2": 1736}],
@ -191,7 +191,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "An Onion Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1224, "y1": 1712, "x2": 1240, "y2": 1736}],
@ -200,7 +200,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Cabbage Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1176, "y1": 1672, "x2": 1192, "y2": 1695}],
@ -209,7 +209,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Turnip Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1192, "y1": 1672, "x2": 1208, "y2": 1696}],
@ -218,7 +218,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Wheatfield in Britain 4",
"Priority": 50,
"Area": [{"x1": 1104, "y1": 1608, "x2": 1136, "y2": 1640}],
@ -227,7 +227,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Wheatfield in Britain 5",
"Priority": 50,
"Area": [{"x1": 1136, "y1": 1560, "x2": 1168, "y2": 1592}],
@ -236,7 +236,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Turnip Field in Britain 2",
"Priority": 50,
"Area": [{"x1": 1208, "y1": 1592, "x2": 1224, "y2": 1616}],
@ -245,7 +245,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Felucca" },
"Name": "A Carrot Field in Britain 2",
"Priority": 50,
"Area": [{"x1": 1224, "y1": 1592, "x2": 1240, "y2": 1616}],
@ -275,7 +275,7 @@
{
"$type": "TownRegion",
"Map": "Felucca",
"Parent": "Jhelom Islands",
"Parent": { "Name": "Jhelom Islands", "Map": "Felucca" },
"Name": "Jhelom",
"Priority": 50,
"Area": [
@ -289,7 +289,7 @@
"$type": "NoHousingRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Jhelom",
"Parent": { "Name": "Jhelom", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 1352, "y1": 3800, "z1": -20, "x2": 1368, "y2": 3832, "z2": 128},
@ -317,7 +317,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Minoc",
"Parent": { "Name": "Minoc", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 2457, "y1": 397, "x2": 2497, "y2": 405},
@ -347,7 +347,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Ocllo",
"Parent": { "Name": "Ocllo", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 3664, "y1": 2608, "x2": 3680, "y2": 2624},
@ -375,7 +375,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Trinsic",
"Parent": { "Name": "Trinsic", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 1834, "y1": 2728, "x2": 1856, "y2": 2744},
@ -404,7 +404,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Vesper",
"Parent": { "Name": "Vesper", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 2952, "y1": 864, "x2": 2968, "y2": 896},
@ -435,7 +435,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Felucca" },
"Priority": 50,
"Area": [{"x1": 600, "y1": 808, "z1": 0, "x2": 624, "y2": 832, "z2": 39}]
},
@ -443,7 +443,7 @@
"$type": "TownRegion",
"RuneName": "A Field of Sheep in Yew",
"Map": "Felucca",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Felucca" },
"Name": "A Field of Sheep in Yew 1",
"Priority": 50,
"Area": [{"x1": 664, "y1": 928, "x2": 686, "y2": 950}],
@ -453,7 +453,7 @@
"$type": "TownRegion",
"RuneName": "A Field of Sheep in Yew",
"Map": "Felucca",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Felucca" },
"Name": "A Field of Sheep in Yew 2",
"Priority": 50,
"Area": [{"x1": 664, "y1": 1168, "x2": 686, "y2": 1190}],
@ -463,7 +463,7 @@
"$type": "TownRegion",
"RuneName": "A Farm in Yew",
"Map": "Felucca",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Felucca" },
"Name": "A Farm in Yew",
"Priority": 50,
"Area": [{"x1": 560, "y1": 1088, "x2": 582, "y2": 1110}],
@ -473,7 +473,7 @@
"$type": "TownRegion",
"RuneName": "A Wheatfield in Yew",
"Map": "Felucca",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Felucca" },
"Name": "A Wheatfield in Yew 1",
"Priority": 50,
"Area": [{"x1": 560, "y1": 1232, "x2": 576, "y2": 1248}],
@ -483,7 +483,7 @@
"$type": "TownRegion",
"RuneName": "A Wheatfield in Yew",
"Map": "Felucca",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Felucca" },
"Name": "A Wheatfield in Yew 2",
"Priority": 50,
"Area": [{"x1": 368, "y1": 1176, "x2": 382, "y2": 1208}],
@ -514,7 +514,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Wind",
"Parent": { "Name": "Wind", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 5159, "y1": 15, "x2": 5184, "y2": 24},
@ -541,7 +541,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Serpent's Hold",
"Parent": { "Name": "Serpent's Hold", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 2960, "y1": 3400, "z1": 0, "x2": 2976, "y2": 3416, "z2": 128},
@ -562,7 +562,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Skara Brae",
"Parent": { "Name": "Skara Brae", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 600, "y1": 2232, "x2": 616, "y2": 2256},
@ -587,7 +587,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Nujel'm",
"Parent": { "Name": "Nujel'm", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 3736, "y1": 1184, "z1": 0, "x2": 3752, "y2": 1207, "z2": 128},
@ -643,7 +643,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Moonglow",
"Parent": { "Name": "Moonglow", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 4384, "y1": 1152, "z1": 0, "x2": 4392, "y2": 1176, "z2": 128},
@ -673,7 +673,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Magincia",
"Parent": { "Name": "Magincia", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 3680, "y1": 2152, "x2": 3704, "y2": 2160},
@ -696,7 +696,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Buccaneer's Den",
"Parent": { "Name": "Buccaneer's Den", "Map": "Felucca" },
"Priority": 50,
"Area": [
{"x1": 2712, "y1": 2080, "x2": 2728, "y2": 2096},
@ -1031,7 +1031,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Delucia",
"Parent": { "Name": "Delucia", "Map": "Felucca" },
"Priority": 50,
"Area": [{"x1": 5194, "y1": 4053, "x2": 5204, "y2": 4073}]
},
@ -1050,7 +1050,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Felucca",
"Parent": "Papua",
"Parent": { "Name": "Papua", "Map": "Felucca" },
"Priority": 50,
"Area": [{"x1": 5757, "y1": 3150, "x2": 5781, "y2": 3174}]
},
@ -1304,7 +1304,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 1492, "y1": 1602, "z1": 0, "x2": 1500, "y2": 1621, "z2": 128},
@ -1325,7 +1325,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Wheatfield in Britain 1",
"Priority": 50,
"Area": [{"x1": 1120, "y1": 1776, "x2": 1152, "y2": 1808}],
@ -1334,7 +1334,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Wheatfield in Britain 2",
"Priority": 50,
"Area": [{"x1": 1184, "y1": 1808, "x2": 1216, "y2": 1840}],
@ -1343,7 +1343,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Wheatfield in Britain 3",
"Priority": 50,
"Area": [{"x1": 1216, "y1": 1872, "x2": 1248, "y2": 1904}],
@ -1352,7 +1352,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Carrot Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1208, "y1": 1712, "x2": 1224, "y2": 1736}],
@ -1361,7 +1361,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "An Onion Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1224, "y1": 1712, "x2": 1240, "y2": 1736}],
@ -1370,7 +1370,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Cabbage Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1176, "y1": 1672, "x2": 1192, "y2": 1695}],
@ -1379,7 +1379,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Turnip Field in Britain 1",
"Priority": 50,
"Area": [{"x1": 1192, "y1": 1672, "x2": 1208, "y2": 1696}],
@ -1388,7 +1388,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Wheatfield in Britain 4",
"Priority": 50,
"Area": [{"x1": 1104, "y1": 1608, "x2": 1136, "y2": 1640}],
@ -1397,7 +1397,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Wheatfield in Britain 5",
"Priority": 50,
"Area": [{"x1": 1136, "y1": 1560, "x2": 1168, "y2": 1592}],
@ -1406,7 +1406,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Turnip Field in Britain 2",
"Priority": 50,
"Area": [{"x1": 1208, "y1": 1592, "x2": 1224, "y2": 1616}],
@ -1415,7 +1415,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Britain",
"Parent": { "Name": "Britain", "Map": "Trammel" },
"Name": "A Carrot Field in Britain 2",
"Priority": 50,
"Area": [{"x1": 1224, "y1": 1592, "x2": 1240, "y2": 1616}],
@ -1445,7 +1445,7 @@
{
"$type": "TownRegion",
"Map": "Trammel",
"Parent": "Jhelom Islands",
"Parent": { "Name": "Jhelom Islands", "Map": "Trammel" },
"Name": "Jhelom",
"Priority": 50,
"Area": [
@ -1459,7 +1459,7 @@
"$type": "NoHousingRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Jhelom",
"Parent": { "Name": "Jhelom", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 1352, "y1": 3800, "z1": -20, "x2": 1368, "y2": 3832, "z2": 128},
@ -1487,7 +1487,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Minoc",
"Parent": { "Name": "Minoc", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 2457, "y1": 397, "x2": 2497, "y2": 405},
@ -1506,7 +1506,7 @@
{
"$type": "GuardedRegion",
"Map": "Trammel",
"Parent": "Haven Island",
"Parent": { "Name": "Haven Island", "Map": "Trammel" },
"Name": "New Haven Moongate",
"Priority": 50,
"Area": [{"x1": 3446, "y1": 2674, "x2": 3456, "y2": 2684}]
@ -1516,7 +1516,7 @@
"RuneName": "New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "Haven Island",
"Parent": { "Name": "Haven Island", "Map": "Trammel" },
"Name": "New Haven",
"Priority": 50,
"Area": [{"x1": 3416, "y1": 2480, "x2": 3545, "y2": 2648}],
@ -1528,7 +1528,7 @@
"RuneName": "The Little Shop of Alchemy in New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Alchemist",
"Priority": 50,
"Area": [{"x1": 3457, "y1": 2563, "x2": 3466, "y2": 2572}]
@ -1538,7 +1538,7 @@
"RuneName": "the Bardic Guild in New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Bard",
"Priority": 50,
"Area": [
@ -1552,7 +1552,7 @@
"RuneName": "the Warrior Guild Hall in New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "Warrior's Guild Hall",
"Priority": 50,
"Area": [
@ -1564,7 +1564,7 @@
"$type": "NoHousingRegion",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "Warrior's Guild Hall",
"Parent": { "Name": "Warrior's Guild Hall", "Map": "Trammel" },
"Name": "the New Haven Warrior",
"Priority": 50,
"Area": [
@ -1576,7 +1576,7 @@
"$type": "NoHousingRegion",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "Warrior's Guild Hall",
"Parent": { "Name": "Warrior's Guild Hall", "Map": "Trammel" },
"Name": "the New Haven Bowyer",
"Priority": 50,
"Area": [{"x1": 3529, "y1": 2531, "x2": 3541, "y2": 2550}]
@ -1586,7 +1586,7 @@
"RuneName": "A Stitch In Time in New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Tailor",
"Priority": 50,
"Area": [
@ -1599,7 +1599,7 @@
"RuneName": "Carpenters of New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Carpenter",
"Priority": 50,
"Area": [
@ -1612,7 +1612,7 @@
"RuneName": "Mapmakers of New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Mapmaker",
"Priority": 50,
"Area": [{"x1": 3490, "y1": 2588, "x2": 3497, "y2": 2595}]
@ -1622,7 +1622,7 @@
"RuneName": "New Haven Magery School",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Mage",
"Priority": 50,
"Area": [{"x1": 3464, "y1": 2488, "x2": 3491, "y2": 2504}]
@ -1633,7 +1633,7 @@
"NoLogoutDelay": true,
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Inn",
"Priority": 50,
"Area": [
@ -1646,7 +1646,7 @@
"RuneName": "the docks in New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Docks",
"Priority": 50,
"Area": [
@ -1660,7 +1660,7 @@
"RuneName": "the First Bank of New Haven",
"MinExpansion": "ML",
"Map": "Trammel",
"Parent": "New Haven",
"Parent": { "Name": "New Haven", "Map": "Trammel" },
"Name": "the New Haven Bank",
"Priority": 50,
"Area": [{"x1": 3479, "y1": 2565, "x2": 3492, "y2": 2580}]
@ -1670,7 +1670,7 @@
"RuneName": "Haven City",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven Island",
"Parent": { "Name": "Haven Island", "Map": "Trammel" },
"Name": "Haven",
"Priority": 50,
"Area": [
@ -1687,7 +1687,7 @@
"RuneName": "the Woodsman in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Woodsman in Haven",
"Priority": 50,
"Area": [
@ -1700,7 +1700,7 @@
"RuneName": "the Prime Cut Butcher Shop in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Prime Cut Butcher Shop in Haven",
"Priority": 50,
"Area": [{"x1": 3704, "y1": 2648, "x2": 3720, "y2": 2656}]
@ -1710,7 +1710,7 @@
"RuneName": "a farm in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Priority": 50,
"Area": [{"x1": 3728, "y1": 2632, "x2": 3736, "y2": 2640}]
},
@ -1719,7 +1719,7 @@
"RuneName": "a farm in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Priority": 50,
"Area": [{"x1": 3704, "y1": 2584, "x2": 3712, "y2": 2592}]
},
@ -1728,7 +1728,7 @@
"RuneName": "a farm in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Priority": 50,
"Area": [{"x1": 3736, "y1": 2561, "x2": 3744, "y2": 2568}]
},
@ -1737,7 +1737,7 @@
"RuneName": "Mapmakers of Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "Mapmakers of Haven",
"Priority": 50,
"Area": [{"x1": 3624, "y1": 2632, "x2": 3640, "y2": 2640}]
@ -1747,7 +1747,7 @@
"RuneName": "The Haven Blacksmith",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "The Haven Blacksmith",
"Priority": 50,
"Area": [{"x1": 3641, "y1": 2613, "x2": 3646, "y2": 2624}]
@ -1757,7 +1757,7 @@
"RuneName": "the Second Bank of Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Second Bank of Haven",
"Priority": 50,
"Area": [
@ -1770,7 +1770,7 @@
"RuneName": "Uzeraan's Mansion",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "Uzeraan's Mansion",
"Priority": 50,
"Area": [
@ -1784,7 +1784,7 @@
"$type": "NoHousingRegion",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Uzeraan's Mansion",
"Parent": { "Name": "Uzeraan's Mansion", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 3592, "y1": 2595, "x2": 3612, "y2": 2599},
@ -1797,7 +1797,7 @@
"RuneName": "Last Chance Provisioners in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "Last Chance Provisioners in Haven",
"Priority": 50,
"Area": [
@ -1810,7 +1810,7 @@
"RuneName": "the Healers of Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Healers of Haven",
"Priority": 50,
"Area": [
@ -1826,7 +1826,7 @@
"RuneName": "The Little Shop of Magic in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "The Little Shop of Magic in Haven",
"Priority": 50,
"Area": [
@ -1840,7 +1840,7 @@
"RuneName": "The Shakin' Bakery in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "The Shakin' Bakery in Haven",
"Priority": 50,
"Area": [
@ -1854,7 +1854,7 @@
"RuneName": "the Bardic Guild in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Bardic Guild in Haven",
"Priority": 50,
"Area": [
@ -1867,7 +1867,7 @@
"RuneName": "Carpenters of Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "Carpenters of Haven",
"Priority": 50,
"Area": [
@ -1880,7 +1880,7 @@
"RuneName": "Haven Clockworks and Tinker Shop",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "Haven Clockworks and Tinker Shop",
"Priority": 50,
"Area": [
@ -1893,7 +1893,7 @@
"RuneName": "The Haven Thieves' Guild",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "The Haven Thieves' Guild",
"Priority": 50,
"Area": [
@ -1906,7 +1906,7 @@
"RuneName": "A Stitch in Time in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "A Stitch in Time in Haven",
"Priority": 50,
"Area": [
@ -1919,7 +1919,7 @@
"RuneName": "the Haven Public Library",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Haven Public Library",
"Priority": 50,
"Area": [
@ -1933,7 +1933,7 @@
"NoLogoutDelay": true,
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "The Gentle Rest Inn in New Haven",
"Priority": 50,
"Area": [
@ -1947,7 +1947,7 @@
"NoLogoutDelay": true,
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "The Albatross Bar and Grill in Haven",
"Priority": 50,
"Area": [
@ -1961,7 +1961,7 @@
"RuneName": "the Proving Grounds in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Proving Grounds in Haven",
"Priority": 50,
"Area": [
@ -1974,7 +1974,7 @@
"RuneName": "the Bullseye Marksmen in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Bullseye Marksmen in Haven",
"Priority": 50,
"Area": [{"x1": 3742, "y1": 2575, "x2": 3750, "y2": 2586}]
@ -1984,7 +1984,7 @@
"RuneName": "the docks in Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the docks in Haven",
"Priority": 50,
"Area": [
@ -1998,7 +1998,7 @@
"RuneName": "the Mystic Mines of Haven",
"MaxExpansion": "SE",
"Map": "Trammel",
"Parent": "Haven",
"Parent": { "Name": "Haven", "Map": "Trammel" },
"Name": "the Mystic Mines of Haven",
"Priority": 50,
"Area": [{"x1": 3752, "y1": 2698, "x2": 3757, "y2": 2707}]
@ -2023,7 +2023,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Trinsic",
"Parent": { "Name": "Trinsic", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 1834, "y1": 2728, "x2": 1856, "y2": 2744},
@ -2052,7 +2052,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Vesper",
"Parent": { "Name": "Vesper", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 2952, "y1": 864, "x2": 2968, "y2": 896},
@ -2083,7 +2083,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Trammel" },
"Priority": 50,
"Area": [{"x1": 600, "y1": 808, "z1": 0, "x2": 624, "y2": 832, "z2": 39}]
},
@ -2091,7 +2091,7 @@
"$type": "TownRegion",
"RuneName": "A Field of Sheep in Yew",
"Map": "Trammel",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Trammel" },
"Name": "A Field of Sheep in Yew 1",
"Priority": 50,
"Area": [{"x1": 664, "y1": 928, "x2": 686, "y2": 950}],
@ -2101,7 +2101,7 @@
"$type": "TownRegion",
"RuneName": "A Field of Sheep in Yew",
"Map": "Trammel",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Trammel" },
"Name": "A Field of Sheep in Yew 2",
"Priority": 50,
"Area": [{"x1": 664, "y1": 1168, "x2": 686, "y2": 1190}],
@ -2111,7 +2111,7 @@
"$type": "TownRegion",
"RuneName": "A Farm in Yew",
"Map": "Trammel",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Trammel" },
"Name": "A Farm in Yew",
"Priority": 50,
"Area": [{"x1": 560, "y1": 1088, "x2": 582, "y2": 1110}],
@ -2121,7 +2121,7 @@
"$type": "TownRegion",
"RuneName": "A Wheatfield in Yew",
"Map": "Trammel",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Trammel" },
"Name": "A Wheatfield in Yew 1",
"Priority": 50,
"Area": [{"x1": 560, "y1": 1232, "x2": 576, "y2": 1248}],
@ -2131,7 +2131,7 @@
"$type": "TownRegion",
"RuneName": "A Wheatfield in Yew",
"Map": "Trammel",
"Parent": "Yew",
"Parent": { "Name": "Yew", "Map": "Trammel" },
"Name": "A Wheatfield in Yew 2",
"Priority": 50,
"Area": [{"x1": 368, "y1": 1176, "x2": 382, "y2": 1208}],
@ -2162,7 +2162,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Wind",
"Parent": { "Name": "Wind", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 5159, "y1": 15, "x2": 5184, "y2": 24},
@ -2189,7 +2189,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Serpent's Hold",
"Parent": { "Name": "Serpent's Hold", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 2960, "y1": 3400, "z1": 0, "x2": 2976, "y2": 3416, "z2": 128},
@ -2210,7 +2210,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Skara Brae",
"Parent": { "Name": "Skara Brae", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 600, "y1": 2232, "x2": 616, "y2": 2256},
@ -2235,7 +2235,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Nujel'm",
"Parent": { "Name": "Nujel'm", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 3736, "y1": 1184, "z1": 0, "x2": 3752, "y2": 1207, "z2": 128},
@ -2291,7 +2291,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Moonglow",
"Parent": { "Name": "Moonglow", "Map": "Trammel" },
"Name": "The Scholar's Inn",
"Priority": 50,
"Area": [
@ -2322,7 +2322,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Magincia",
"Parent": { "Name": "Magincia", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 3680, "y1": 2152, "x2": 3704, "y2": 2160},
@ -2345,7 +2345,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Buccaneer's Den",
"Parent": { "Name": "Buccaneer's Den", "Map": "Trammel" },
"Priority": 50,
"Area": [
{"x1": 2712, "y1": 2080, "x2": 2728, "y2": 2096},
@ -2670,7 +2670,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Delucia",
"Parent": { "Name": "Delucia", "Map": "Trammel" },
"Priority": 50,
"Area": [{"x1": 5194, "y1": 4053, "x2": 5204, "y2": 4073}]
},
@ -2689,7 +2689,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Trammel",
"Parent": "Papua",
"Parent": { "Name": "Papua", "Map": "Trammel" },
"Priority": 50,
"Area": [{"x1": 5757, "y1": 3150, "x2": 5781, "y2": 3174}]
},
@ -2927,7 +2927,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Ilshenar",
"Parent": "Gargoyle City",
"Parent": { "Name": "Gargoyle City", "Map": "Ilshenar" },
"Priority": 50,
"Area": [{"x1": 827, "y1": 694, "x2": 853, "y2": 727}]
},
@ -3089,7 +3089,7 @@
"$type": "BaseRegion",
"NoLogoutDelay": true,
"Map": "Ilshenar",
"Parent": "Twin Oaks",
"Parent": { "Name": "Twin Oaks", "Map": "Ilshenar" },
"Priority": 48,
"Area": [{"x1": 1546, "y1": 1037, "x2": 1567, "y2": 1057}]
},
@ -3209,7 +3209,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Ilshenar",
"Parent": "Mistas",
"Parent": { "Name": "Mistas", "Map": "Ilshenar" },
"Priority": 48,
"Area": [{"x1": 752, "y1": 1131, "x2": 768, "y2": 1152}]
},
@ -3369,7 +3369,7 @@
"$type": "BaseRegion",
"NoLogoutDelay": true,
"Map": "Ilshenar",
"Parent": "Gypsy Camp 2",
"Parent": { "Name": "Gypsy Camp 2", "Map": "Ilshenar" },
"Priority": 48,
"Area": [{"x1": 1617, "y1": 546, "x2": 1629, "y2": 554}]
},
@ -3462,7 +3462,7 @@
"$type": "BaseRegion",
"NoLogoutDelay": true,
"Map": "Ilshenar",
"Parent": "Vinculum Inn",
"Parent": { "Name": "Vinculum Inn", "Map": "Ilshenar" },
"Priority": 50,
"Area": [{"x1": 658, "y1": 654, "x2": 671, "y2": 678}]
},
@ -3507,7 +3507,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Malas",
"Parent": "Luna",
"Parent": { "Name": "Luna", "Map": "Malas" },
"Priority": 50,
"Area": [{"x1": 986, "y1": 509, "x2": 1004, "y2": 530}]
},
@ -3527,7 +3527,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Malas",
"Parent": "Umbra",
"Parent": { "Name": "Umbra", "Map": "Malas" },
"Priority": 50,
"Area": [{"x1": 2031, "y1": 1311, "x2": 2046, "y2": 1325}]
},
@ -3680,7 +3680,7 @@
"$type": "TownRegion",
"NoLogoutDelay": true,
"Map": "Tokuno",
"Parent": "Zento",
"Parent": { "Name": "Zento", "Map": "Tokuno" },
"Priority": 50,
"Area": [{"x1": 674, "y1": 1203, "x2": 699, "y2": 1219}]
},

View file

@ -0,0 +1,85 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: RegionByNameConverter.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Server.Json;
public class RegionByNameConverter : JsonConverter<Region>
{
public override Region Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
string name = null;
Map map = null;
if (reader.TokenType != JsonTokenType.StartObject)
{
throw new JsonException("Invalid json for RegionByName");
}
while (true)
{
reader.Read();
if (reader.TokenType == JsonTokenType.EndObject)
{
break;
}
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException("Invalid json for RegionByName");
}
string property = reader.GetString()?.ToLower();
if (property != "name" && property != "map")
{
continue;
}
reader.Read();
if (reader.TokenType != JsonTokenType.String)
{
throw new JsonException($"Value for {property} must be a string");
}
if (property == "name")
{
name = reader.GetString();
}
else
{
map = Map.Parse(reader.GetString());
}
}
if (name == null || map == null)
{
throw new JsonException("Invalid json for RegionByName");
}
return Region.Find(name, map);
}
public override void Write(Utf8JsonWriter writer, Region value, JsonSerializerOptions options)
{
writer.WriteStartObject();
writer.WriteString("Name", value.Name);
writer.WriteString("Map", value.Map.Name);
writer.WriteEndObject();
}
}

View file

@ -0,0 +1,28 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: RegionByNameConverterFactory.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Server.Json;
public class RegionByNameConverterFactory : JsonConverterFactory
{
public override bool CanConvert(Type typeToConvert) => typeToConvert == typeof(Region);
public override JsonConverter CreateConverter(Type typeToConvert, JsonSerializerOptions options) =>
new RegionByNameConverter();
}

View file

@ -1,5 +1,8 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using Server.Json;
using Server.Logging;
using Server.Network;
using Server.Targeting;
@ -136,6 +139,7 @@ public class Region : IComparable<Region>
{
}
[JsonConstructor] // Don't include parent, since it is special
public Region(string name, Map map, int priority, params Rectangle3D[] area) : this(name, map, null, area) =>
Priority = priority;
@ -173,10 +177,10 @@ public class Region : IComparable<Region>
}
// Used during deserialization only
public Expansion MinExpansion { get; set; }
public Expansion MinExpansion { get; set; } = Expansion.None;
// Used during deserialization only
public Expansion MaxExpansion { get; set; }
public Expansion MaxExpansion { get; set; } = Expansion.EJ;
public static List<Region> Regions { get; } = new();
@ -188,7 +192,9 @@ public class Region : IComparable<Region>
public Map Map { get; }
public Region Parent { get; }
[JsonInclude]
[JsonConverter(typeof(RegionByNameConverter))]
public Region Parent { get; private set; }
public List<Region> Children { get; } = new();

View file

@ -1,67 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2022 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: RegionJsonDto.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Text.Json.Serialization;
using Server.Utilities;
namespace Server;
public class RegionJsonDto
{
public Expansion MinExpansion { get; set; } = Expansion.None;
public Expansion? MaxExpansion { get; set; } = Expansion.EJ;
[JsonIgnore]
public virtual Type RegionType => typeof(Region);
public Map Map { get; set; }
public string? Parent { get; set; }
public string Name { get; set; }
public int? Priority { get; set; }
public Rectangle3D[] Area { get; set; }
public Point3D GoLocation { get; set; }
public MusicName? Music { get; set; }
public virtual void FromRegion(Region region)
{
Map = region.Map;
Parent = region.Parent?.Name;
Name = region.Name;
Priority = region.Priority;
Area = region.Area;
GoLocation = region.GoLocation;
Music = region.Music != MusicName.Invalid && region.Music != region.DefaultMusic ? region.Music : null;
MaxExpansion = region.MaxExpansion == Expansion.EJ ? null : region.MaxExpansion;
MinExpansion = region.MinExpansion;
}
public Region ToRegion()
{
var region = Priority != null
? RegionType.CreateInstance<Region>(Name, Map, Region.Find(Parent, Map), Priority, Area)
: RegionType.CreateInstance<Region>(Name, Map, Region.Find(Parent, Map), Area);
HydrateRegion(region);
return region;
}
protected virtual void HydrateRegion(Region region)
{
region.GoLocation = GoLocation;
region.Music = Music ?? region.DefaultMusic;
}
}

View file

@ -22,7 +22,6 @@ using System.Text.Json.Serialization;
using System.Text.Json.Serialization.Metadata;
using Server.Json;
using Server.Logging;
using Server.Utilities;
namespace Server;
@ -30,10 +29,7 @@ public static class RegionJsonSerializer
{
private static readonly ILogger logger = LogFactory.GetLogger(typeof(RegionJsonSerializer));
// Note: This is filled during the `Configure` phase by RegisterRegionForSerialization,
// so it is not available to a JsonConverter which might be used during earlier phases.
private static Dictionary<Type, Type> _regionToDtoLookup = new() { { typeof(Region), typeof(RegionJsonDto) } };
private static JsonDerivedType[] _derivedTypes = { new(typeof(RegionJsonDto), nameof(Region)) };
private static JsonDerivedType[] _derivedTypes = { new(typeof(Region), nameof(Region)) };
private static JsonSerializerOptions _options = new(JsonConfig.DefaultOptions)
{
@ -44,7 +40,7 @@ public static class RegionJsonSerializer
{
static typeInfo =>
{
if (typeInfo.Type != typeof(RegionJsonDto))
if (typeInfo.Type != typeof(Region))
{
return;
}
@ -55,26 +51,39 @@ public static class RegionJsonSerializer
typeInfo.PolymorphismOptions.DerivedTypes.Add(_derivedTypes[i]);
}
},
static typeInfo =>
{
if (!typeInfo.Type.IsAssignableTo(typeof(Region)))
{
return;
}
typeInfo.OnDeserialized = o =>
{
if (o is Region region && Core.Expansion >= region.MinExpansion && Core.Expansion <= region.MaxExpansion)
{
region.Register();
}
};
}
}
}
};
public static void Register<TDto, TRegion>()
where TDto : RegionJsonDto, new() where TRegion : Region
public static void Register<TRegion>() where TRegion : Region
{
for (var i = 0; i < _derivedTypes.Length; i++)
{
if (_derivedTypes[i].DerivedType == typeof(TDto))
if (_derivedTypes[i].DerivedType == typeof(TRegion))
{
throw new Exception(
$"Type '{typeof(TDto)}' has already been registered for serialization with the region loader."
$"Type '{typeof(TRegion)}' has already been registered for serialization with the region loader."
);
}
}
Array.Resize(ref _derivedTypes, _derivedTypes.Length + 1);
_derivedTypes[^1] = new JsonDerivedType(typeof(TDto), typeof(TRegion).Name);
_regionToDtoLookup[typeof(TRegion)] = typeof(TDto);
_derivedTypes[^1] = new JsonDerivedType(typeof(TRegion), typeof(TRegion).Name);
}
internal static void LoadRegions()
@ -85,19 +94,17 @@ public static class RegionJsonSerializer
var stopwatch = Stopwatch.StartNew();
var regions = JsonConfig.Deserialize<List<RegionJsonDto>>(path, _options);
var regions = JsonConfig.Deserialize<List<Region>>(path, _options);
if (regions == null)
{
throw new JsonException($"Failed to deserialize {path}.");
}
var count = 0;
foreach (var dto in regions)
foreach (var region in regions)
{
if (Core.Expansion >= dto.MinExpansion && Core.Expansion <= dto.MaxExpansion)
if (Core.Expansion >= region.MinExpansion && Core.Expansion <= region.MaxExpansion)
{
var region = dto.ToRegion();
region.Register();
count++;
}
}
@ -111,43 +118,4 @@ public static class RegionJsonSerializer
stopwatch.Elapsed.TotalSeconds
);
}
// Note: This is not thread safe. To make `SerializeRegions` threadsafe, use `[ThreadStatic]` or just create the lists
// in the function and take the GC hit.
private static List<RegionJsonDto> _regionJsonDtos;
public static void SerializeRegions(string path, IEnumerable<Region> regions)
{
_regionJsonDtos ??= new List<RegionJsonDto>();
foreach (var region in regions)
{
if (_regionToDtoLookup.TryGetValue(region.GetType(), out var dtoType))
{
var dto = dtoType.CreateInstance<RegionJsonDto>();
dto.FromRegion(region);
_regionJsonDtos.Add(dto);
}
}
JsonConfig.Serialize(path, _regionJsonDtos, _options);
_regionJsonDtos.Clear();
}
public static string SerializeRegions(IEnumerable<Region> regions)
{
_regionJsonDtos ??= new List<RegionJsonDto>();
foreach (var region in regions)
{
if (_regionToDtoLookup.TryGetValue(region.GetType(), out var dtoType))
{
var dto = dtoType.CreateInstance<RegionJsonDto>();
dto.FromRegion(region);
_regionJsonDtos.Add(dto);
}
}
var output = JsonConfig.Serialize(_regionJsonDtos, _options);
_regionJsonDtos.Clear();
return output;
}
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement damage boost regions
public class AcidRiverRegion : MondainRegion
{
[JsonConstructor] // Don't include parent, since it is special
public AcidRiverRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public AcidRiverRegion(string name, Map map, Region parent, params Rectangle3D[] area): base(name, map, parent, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class ApprenticeRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public ApprenticeRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public ApprenticeRegion(string name, Map map, Region parent, int priority, params Rectangle3D[] area) : base(name, map, parent, priority, area)
{
}

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Server.Gumps;
using Server.Mobiles;
using Server.Spells;
@ -15,6 +16,7 @@ public class BaseRegion : Region
{
}
[JsonConstructor] // Don't include parent, since it is special
public BaseRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}

View file

@ -1,7 +1,14 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
public class BattleRegion : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public BattleRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public BattleRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,8 +1,11 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class BlackthornCastleRegion : GuardedRegion
{
[JsonConstructor] // Don't include parent, since it is special
public BlackthornCastleRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class BlackthornDungeonRegion : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public BlackthornDungeonRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public BlackthornDungeonRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,9 +1,11 @@
using System;
using System.Text.Json.Serialization;
namespace Server.Regions;
public class CousteauPerronHouseRegion : GuardedRegion
{
[JsonConstructor] // Don't include parent, since it is special
public CousteauPerronHouseRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement damage boost regions
public class CrystalFieldRegion : MondainRegion
{
[JsonConstructor] // Don't include parent, since it is special
public CrystalFieldRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public CrystalFieldRegion(string name, Map map, Region parent, params Rectangle3D[] area): base(name, map, parent, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class DoomGuardianRegion : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public DoomGuardianRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public DoomGuardianRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,7 +1,14 @@
using System.Text.Json.Serialization;
namespace Server.Regions;
public class DungeonRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public DungeonRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public DungeonRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class ExodusDungeonRegion : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public ExodusDungeonRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public ExodusDungeonRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class ExploringDeepCreaturesRegion : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public ExploringDeepCreaturesRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public ExploringDeepCreaturesRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,3 +1,4 @@
using System.Text.Json.Serialization;
using Server.Spells;
using Server.Spells.Sixth;
@ -5,6 +6,11 @@ namespace Server.Regions;
public class GreenAcresRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public GreenAcresRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public GreenAcresRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using Server.Mobiles;
using Server.Utilities;
@ -12,6 +13,7 @@ public class GuardedRegion : BaseRegion
private readonly Dictionary<Mobile, GuardTimer> m_GuardCandidates = new();
[JsonConstructor] // Don't include parent, since it is special
public GuardedRegion(string name, Map map, int priority, params Rectangle3D[] area) :
base(name, map, priority, area) => GuardType = DefaultGuardType;

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement damage boost regions
public class IcyRiverRegion : MondainRegion
{
[JsonConstructor] // Don't include parent, since it is special
public IcyRiverRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public IcyRiverRegion(string name, Map map, Region parent, params Rectangle3D[] area): base(name, map, parent, area)
{
}

View file

@ -1,9 +1,15 @@
using System.Text.Json.Serialization;
using Server.Spells;
namespace Server.Regions;
public class JailRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public JailRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public JailRegion(string name, Map map, Region parent, params Rectangle3D[] area)
: base(name, map, parent, area)
{

View file

@ -1,29 +0,0 @@
namespace Server.Regions;
public class BaseRegionJsonDto<TRegion> : GenericRegionJsonDto<TRegion> where TRegion : BaseRegion
{
public string RuneName { get; set; }
public bool NoLogoutDelay { get; set; }
public override void FromRegion(Region region)
{
base.FromRegion(region);
if (region is BaseRegion baseRegion)
{
RuneName = baseRegion.RuneName;
NoLogoutDelay = baseRegion.NoLogoutDelay;
}
}
protected override void HydrateRegion(Region region)
{
base.HydrateRegion(region);
if (region is BaseRegion baseRegion)
{
baseRegion.RuneName = RuneName;
baseRegion.NoLogoutDelay = NoLogoutDelay;
}
}
}

View file

@ -1,26 +0,0 @@
namespace Server.Regions;
public class DungeonRegionJsonDto<TRegion> : BaseRegionJsonDto<TRegion> where TRegion : DungeonRegion
{
public Point3D Entrance { get; set; }
public override void FromRegion(Region region)
{
base.FromRegion(region);
if (region is DungeonRegion dungeonRegion)
{
Entrance = dungeonRegion.Entrance;
}
}
protected override void HydrateRegion(Region region)
{
base.HydrateRegion(region);
if (region is DungeonRegion dungeonRegion)
{
dungeonRegion.Entrance = Entrance;
}
}
}

View file

@ -1,34 +0,0 @@
using System;
using System.Text.Json.Serialization;
namespace Server.Regions;
public class GenericRegionJsonDto<TRegion> : RegionJsonDto where TRegion : BaseRegion
{
[JsonIgnore]
public override Type RegionType => typeof(TRegion);
public string RuneName { get; set; }
public bool NoLogoutDelay { get; set; }
public override void FromRegion(Region region)
{
base.FromRegion(region);
if (region is BaseRegion baseRegion)
{
RuneName = baseRegion.RuneName;
NoLogoutDelay = baseRegion.NoLogoutDelay;
}
}
protected override void HydrateRegion(Region region)
{
base.HydrateRegion(region);
if (region is BaseRegion baseRegion)
{
baseRegion.RuneName = RuneName;
baseRegion.NoLogoutDelay = NoLogoutDelay;
}
}
}

View file

@ -1,30 +0,0 @@
using System;
namespace Server.Regions;
public class GuardedRegionJsonDto<TRegion> : BaseRegionJsonDto<TRegion> where TRegion : GuardedRegion
{
public bool GuardsDisabled { get; set; }
public Type? GuardType { get; set; }
public override void FromRegion(Region region)
{
base.FromRegion(region);
if (region is GuardedRegion guardedRegion)
{
GuardsDisabled = guardedRegion.GuardsDisabled;
GuardType = guardedRegion.GuardType == guardedRegion.DefaultGuardType ? null : guardedRegion.GuardType;
}
}
protected override void HydrateRegion(Region region)
{
base.HydrateRegion(region);
if (region is GuardedRegion guardedRegion)
{
guardedRegion.GuardsDisabled = GuardsDisabled;
guardedRegion.GuardType = GuardType ?? guardedRegion.DefaultGuardType;
}
}
}

View file

@ -1,63 +0,0 @@
namespace Server.Regions;
public static class RegionJsonDtoExt
{
public static void Configure()
{
RegionJsonSerializer.Register<BaseRegionJsonDto<BaseRegion>, BaseRegion>();
RegionJsonSerializer.Register<DungeonRegionJsonDto<DungeonRegion>, DungeonRegion>();
RegionJsonSerializer.Register<GuardedRegionJsonDto<GuardedRegion>, GuardedRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<GreenAcresRegion>, GreenAcresRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<JailRegion>, JailRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<MondainRegion>, MondainRegion>();
RegionJsonSerializer.Register<TownRegionJsonDto<NewMaginciaRegion>, NewMaginciaRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<NoHousingRegion>, NoHousingRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<NoHousingGuardedRegion>, NoHousingGuardedRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<NoTravelSpellsAllowedRegion>, NoTravelSpellsAllowedRegion>();
RegionJsonSerializer.Register<TownRegionJsonDto<TownRegion>, TownRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<TwistedWealdDesertRegion>, TwistedWealdDesertRegion>();
// Damage boost regions
RegionJsonSerializer.Register<DungeonRegionJsonDto<CrystalFieldRegion>, CrystalFieldRegion>();
RegionJsonSerializer.Register<DungeonRegionJsonDto<IcyRiverRegion>, IcyRiverRegion>();
RegionJsonSerializer.Register<DungeonRegionJsonDto<AcidRiverRegion>, AcidRiverRegion>();
RegionJsonSerializer.Register<DungeonRegionJsonDto<PoisonedTreeRegion>, PoisonedTreeRegion>();
RegionJsonSerializer.Register<DungeonRegionJsonDto<LostCityEntranceRegion>, LostCityEntranceRegion>();
RegionJsonSerializer.Register<DungeonRegionJsonDto<PoisonedCemeteryRegion>, PoisonedCemeteryRegion>();
// Wrong Jail
RegionJsonSerializer.Register<DungeonRegionJsonDto<WrongLevel3Region>, WrongLevel3Region>();
RegionJsonSerializer.Register<DungeonRegionJsonDto<WrongJailRegion>, WrongJailRegion>();
// Blackthorn Dungeon
RegionJsonSerializer.Register<DungeonRegionJsonDto<BlackthornDungeonRegion>, BlackthornDungeonRegion>();
RegionJsonSerializer.Register<GuardedRegionJsonDto<CousteauPerronHouseRegion>, CousteauPerronHouseRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<ApprenticeRegion>, ApprenticeRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<SeaMarketRegion>, SeaMarketRegion>();
// Exploring the Deep
RegionJsonSerializer.Register<DungeonRegionJsonDto<ExploringDeepCreaturesRegion>, ExploringDeepCreaturesRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<UnderwaterRegion>, UnderwaterRegion>();
// Exodus Dungeon
RegionJsonSerializer.Register<DungeonRegionJsonDto<ExodusDungeonRegion>, ExodusDungeonRegion>();
// Doom
RegionJsonSerializer.Register<DungeonRegionJsonDto<DoomGuardianRegion>, DoomGuardianRegion>();
// Tokuno
RegionJsonSerializer.Register<GuardedRegionJsonDto<TokunoDocksRegion>, TokunoDocksRegion>();
// Tomb of Kings
RegionJsonSerializer.Register<BaseRegionJsonDto<TombOfKingsRegion>, TombOfKingsRegion>();
RegionJsonSerializer.Register<BaseRegionJsonDto<ToKBridgeRegion>, ToKBridgeRegion>();
// Myrmidex
RegionJsonSerializer.Register<DungeonRegionJsonDto<BattleRegion>, BattleRegion>();
}
}

View file

@ -1,26 +0,0 @@
namespace Server.Regions;
public class TownRegionJsonDto<TRegion> : BaseRegionJsonDto<TRegion> where TRegion : TownRegion
{
public Point3D Entrance { get; set; }
public override void FromRegion(Region region)
{
base.FromRegion(region);
if (region is TownRegion townRegion)
{
Entrance = townRegion.Entrance;
}
}
protected override void HydrateRegion(Region region)
{
base.HydrateRegion(region);
if (region is TownRegion townRegion)
{
townRegion.Entrance = Entrance;
}
}
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement damage boost regions
public class LostCityEntranceRegion : MondainRegion
{
[JsonConstructor] // Don't include parent, since it is special
public LostCityEntranceRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public LostCityEntranceRegion(string name, Map map, Region parent, params Rectangle3D[] area): base(name, map, parent, area)
{
}

View file

@ -1,7 +1,14 @@
using System.Text.Json.Serialization;
namespace Server.Regions;
public class MondainRegion : NoTravelSpellsAllowedRegion
{
[JsonConstructor] // Don't include parent, since it is special
public MondainRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public MondainRegion(string name, Map map, Region parent, params Rectangle3D[] area)
: base(name, map, parent, area)
{

View file

@ -1,7 +1,14 @@
using System.Text.Json.Serialization;
namespace Server.Regions;
public class NewMaginciaRegion : TownRegion
{
[JsonConstructor] // Don't include parent, since it is special
public NewMaginciaRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public NewMaginciaRegion(string name, Map map, Region parent, params Rectangle3D[] area)
: base(name, map, parent, area)
{

View file

@ -1,9 +1,11 @@
using System;
using System.Text.Json.Serialization;
namespace Server.Regions;
public class NoHousingGuardedRegion : GuardedRegion
{
[JsonConstructor] // Don't include parent, since it is special
public NoHousingGuardedRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}

View file

@ -1,8 +1,13 @@
using System.Text.Json.Serialization;
namespace Server.Regions;
public class NoHousingRegion : BaseRegion
{
// We don't set AllowHousing to false because it is manually checked so that a part of a house cannot overlap
[JsonConstructor] // Don't include parent, since it is special
public NoHousingRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public NoHousingRegion(string name, Map map, Region parent, params Rectangle3D[] area)
: base(name, map, parent, area)
@ -14,5 +19,6 @@ public class NoHousingRegion : BaseRegion
{
}
// We don't set AllowHousing to false because it is manually checked so that a part of a house cannot overlap
public override bool AllowHousing(Mobile from, Point3D p) => true;
}

View file

@ -1,9 +1,15 @@
using System.Text.Json.Serialization;
using Server;
using Server.Regions;
using Server.Spells;
public class NoTravelSpellsAllowedRegion : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public NoTravelSpellsAllowedRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public NoTravelSpellsAllowedRegion(string name, Map map, Region parent, params Rectangle3D[] area)
: base(name, map, parent, area)
{

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement damage boost regions
public class PoisonedTreeRegion : MondainRegion
{
[JsonConstructor] // Don't include parent, since it is special
public PoisonedTreeRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public PoisonedTreeRegion(string name, Map map, Region parent, params Rectangle3D[] area): base(name, map, parent, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement damage boost regions
public class PoisonedCemeteryRegion : MondainRegion
{
[JsonConstructor] // Don't include parent, since it is special
public PoisonedCemeteryRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public PoisonedCemeteryRegion(string name, Map map, Region parent, params Rectangle3D[] area): base(name, map, parent, area)
{
}

View file

@ -0,0 +1,63 @@
namespace Server.Regions;
public static class RegionJsonRegistration
{
public static void Configure()
{
RegionJsonSerializer.Register<BaseRegion>();
RegionJsonSerializer.Register<TownRegion>();
RegionJsonSerializer.Register<DungeonRegion>();
RegionJsonSerializer.Register<GuardedRegion>();
// Travel registricted regions
RegionJsonSerializer.Register<GreenAcresRegion>();
RegionJsonSerializer.Register<JailRegion>();
RegionJsonSerializer.Register<MondainRegion>();
RegionJsonSerializer.Register<NewMaginciaRegion>();
RegionJsonSerializer.Register<NoHousingRegion>();
RegionJsonSerializer.Register<NoHousingGuardedRegion>();
RegionJsonSerializer.Register<NoTravelSpellsAllowedRegion>();
RegionJsonSerializer.Register<TwistedWealdDesertRegion>();
// Damage boost regions
RegionJsonSerializer.Register<CrystalFieldRegion>();
RegionJsonSerializer.Register<IcyRiverRegion>();
RegionJsonSerializer.Register<AcidRiverRegion>();
RegionJsonSerializer.Register<PoisonedTreeRegion>();
RegionJsonSerializer.Register<LostCityEntranceRegion>();
RegionJsonSerializer.Register<PoisonedCemeteryRegion>();
// Wrong Jail
RegionJsonSerializer.Register<WrongLevel3Region>();
RegionJsonSerializer.Register<WrongJailRegion>();
// Blackthorn Dungeon
RegionJsonSerializer.Register<BlackthornDungeonRegion>();
RegionJsonSerializer.Register<CousteauPerronHouseRegion>();
RegionJsonSerializer.Register<ApprenticeRegion>();
RegionJsonSerializer.Register<SeaMarketRegion>();
// Exploring the Deep
RegionJsonSerializer.Register<ExploringDeepCreaturesRegion>();
RegionJsonSerializer.Register<UnderwaterRegion>();
// Exodus Dungeon
RegionJsonSerializer.Register<ExodusDungeonRegion>();
// Doom
RegionJsonSerializer.Register<DoomGuardianRegion>();
// Tokuno
RegionJsonSerializer.Register<TokunoDocksRegion>();
// Tomb of Kings
RegionJsonSerializer.Register<TombOfKingsRegion>();
RegionJsonSerializer.Register<ToKBridgeRegion>();
// Myrmidex
RegionJsonSerializer.Register<BattleRegion>();
}
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class SeaMarketRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public SeaMarketRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public SeaMarketRegion(string name, Map map, Region parent, int priority, params Rectangle3D[] area) : base(name, map, parent, priority, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class ToKBridgeRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public ToKBridgeRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public ToKBridgeRegion(string name, Map map, Region parent, int priority, params Rectangle3D[] area) : base(name, map, parent, priority, area)
{
}

View file

@ -1,9 +1,11 @@
using System;
using System.Text.Json.Serialization;
namespace Server.Regions;
public class TokunoDocksRegion : NoHousingGuardedRegion
{
[JsonConstructor] // Don't include parent, since it is special
public TokunoDocksRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}

View file

@ -1,7 +1,14 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
public class TombOfKingsRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public TombOfKingsRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public TombOfKingsRegion(string name, Map map, Region parent, int priority, params Rectangle3D[] area) : base(name, map, parent, priority, area)
{
}

View file

@ -1,8 +1,13 @@
using System.Text.Json.Serialization;
namespace Server.Regions;
public class TownRegion : GuardedRegion
{
public Point3D Entrance { get; set; }
[JsonConstructor] // Don't include parent, since it is special
public TownRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public TownRegion(string name, Map map, Region parent, params Rectangle3D[] area)
: base(name, map, parent, area)
@ -13,4 +18,6 @@ public class TownRegion : GuardedRegion
: base(name, map, parent, priority, area)
{
}
public Point3D Entrance { get; set; }
}

View file

@ -1,3 +1,4 @@
using System.Text.Json.Serialization;
using Server.Network;
using Server.Spells;
using Server.Spells.Ninjitsu;
@ -6,6 +7,11 @@ namespace Server.Regions;
public class TwistedWealdDesertRegion : MondainRegion
{
[JsonConstructor] // Don't include parent, since it is special
public TwistedWealdDesertRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public TwistedWealdDesertRegion(string name, Map map, Region parent, params Rectangle3D[] area)
: base(name, map, parent, area)
{

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement
public class UnderwaterRegion : BaseRegion
{
[JsonConstructor] // Don't include parent, since it is special
public UnderwaterRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public UnderwaterRegion(string name, Map map, Region parent, int priority, params Rectangle3D[] area) : base(name, map, parent, priority, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement jail safe zone
public class WrongJailRegion : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public WrongJailRegion(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public WrongJailRegion(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,8 +1,15 @@
namespace Server.Regions;
using System.Text.Json.Serialization;
namespace Server.Regions;
// TODO: Implement jail
public class WrongLevel3Region : DungeonRegion
{
[JsonConstructor] // Don't include parent, since it is special
public WrongLevel3Region(string name, Map map, int priority, params Rectangle3D[] area) : base(name, map, priority, area)
{
}
public WrongLevel3Region(string name, Map map, Region parent, params Rectangle3D[] area) : base(name, map, parent, area)
{
}

View file

@ -1,4 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.9.6"
"version": "0.9.7"
}