Formats UO Content (#201)
This commit is contained in:
parent
86b7b3aed1
commit
ad3775c4d7
3249 changed files with 431083 additions and 440981 deletions
|
|
@ -1,58 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Json;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class LocationTree
|
||||
{
|
||||
public LocationTree(string fileName, Map map)
|
||||
{
|
||||
LastBranch = new Dictionary<Mobile, GoCategory>();
|
||||
Map = map;
|
||||
|
||||
string path = Path.Combine($"Data/Locations/{fileName}.json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine("Go Locations: {0} does not exist", path);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Root = JsonConfig.Deserialize<GoCategory>(path);
|
||||
SetParents(Root);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Go Locations: Error in deserializing {0}", path);
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<Mobile, GoCategory> LastBranch { get; }
|
||||
|
||||
public Map Map { get; }
|
||||
|
||||
public GoCategory Root { get; }
|
||||
|
||||
private static void SetParents(GoCategory parent)
|
||||
{
|
||||
// Deserialization may leave these null
|
||||
parent.Categories ??= Array.Empty<GoCategory>();
|
||||
parent.Locations ??= Array.Empty<GoLocation>();
|
||||
|
||||
for (int i = 0; i < parent.Categories.Length; i++)
|
||||
{
|
||||
GoCategory category = parent.Categories[i];
|
||||
category.Parent = parent;
|
||||
SetParents(category);
|
||||
}
|
||||
|
||||
for (int j = 0; j < parent.Locations.Length; j++)
|
||||
parent.Locations[j].Parent = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Server.Json;
|
||||
|
||||
namespace Server.Gumps
|
||||
{
|
||||
public class LocationTree
|
||||
{
|
||||
public LocationTree(string fileName, Map map)
|
||||
{
|
||||
LastBranch = new Dictionary<Mobile, GoCategory>();
|
||||
Map = map;
|
||||
|
||||
var path = Path.Combine($"Data/Locations/{fileName}.json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Console.WriteLine("Go Locations: {0} does not exist", path);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Root = JsonConfig.Deserialize<GoCategory>(path);
|
||||
SetParents(Root);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("Go Locations: Error in deserializing {0}", path);
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<Mobile, GoCategory> LastBranch { get; }
|
||||
|
||||
public Map Map { get; }
|
||||
|
||||
public GoCategory Root { get; }
|
||||
|
||||
private static void SetParents(GoCategory parent)
|
||||
{
|
||||
// Deserialization may leave these null
|
||||
parent.Categories ??= Array.Empty<GoCategory>();
|
||||
parent.Locations ??= Array.Empty<GoLocation>();
|
||||
|
||||
for (var i = 0; i < parent.Categories.Length; i++)
|
||||
{
|
||||
var category = parent.Categories[i];
|
||||
category.Parent = parent;
|
||||
SetParents(category);
|
||||
}
|
||||
|
||||
for (var j = 0; j < parent.Locations.Length; j++)
|
||||
parent.Locations[j].Parent = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue