fix: Fixes region priority and resolution. (#1254)
- [X] Fixes world location JSON deserializer. - [X] Fixes region resolver and priorities. - [X] Removes DynamicJson from regions. - [X] Adds missing region music.
This commit is contained in:
parent
139be1bc23
commit
18c4459e6b
31 changed files with 3809 additions and 3677 deletions
61
Projects/Server/Regions/RegionJsonDto.cs
Normal file
61
Projects/Server/Regions/RegionJsonDto.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*************************************************************************
|
||||
* 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
|
||||
{
|
||||
[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 != region.DefaultMusic ? region.Music : null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue