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

@ -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();