#W# Go menu: You can now specify a map in the go menu .json file.
This commit is contained in:
parent
5d67792ee1
commit
50857d4a7a
10 changed files with 34 additions and 1240 deletions
|
|
@ -159,10 +159,23 @@ public class GoGump : DynamicGump
|
|||
index -= _node.Categories.Length;
|
||||
if (index < _node.Locations.Length)
|
||||
{
|
||||
from.MoveToWorld(_node.Locations[index].Location, _tree.Map);
|
||||
//from.MoveToWorld(_node.Locations[index].Location, _tree.Map);
|
||||
var loc = _node.Locations[index];
|
||||
Map targetMap = _tree.Map;
|
||||
if (!string.IsNullOrEmpty(loc.MapName))
|
||||
{
|
||||
foreach (Map m in Map.AllMaps)
|
||||
{
|
||||
if (m != null && string.Equals(m.Name, loc.MapName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
targetMap = m;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
from.MoveToWorld(loc.Location, targetMap);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,4 +9,6 @@ public class GoLocation
|
|||
[JsonPropertyName("name")] public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("location")] public Point3D Location { get; set; }
|
||||
}
|
||||
|
||||
[JsonPropertyName("map")] public string MapName { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,48 +11,18 @@ public static class GoLocations
|
|||
{
|
||||
private static readonly ILogger logger = LogFactory.GetLogger(typeof(GoLocations));
|
||||
|
||||
private static LocationTree _felucca;
|
||||
private static LocationTree _trammel;
|
||||
private static LocationTree _ilshenar;
|
||||
private static LocationTree _malas;
|
||||
private static LocationTree _tokuno;
|
||||
private static LocationTree _terMur;
|
||||
private static LocationTree _world;
|
||||
|
||||
public static LocationTree GetLocations(Map map)
|
||||
{
|
||||
if (map == Map.Ilshenar)
|
||||
{
|
||||
return _ilshenar ??= LoadLocations("ilshenar", Map.Ilshenar);
|
||||
}
|
||||
|
||||
if (map == Map.TerMur)
|
||||
{
|
||||
return _terMur ??= LoadLocations("termur", Map.TerMur);
|
||||
}
|
||||
|
||||
if (map == Map.Trammel)
|
||||
{
|
||||
return _trammel ??= LoadLocations("trammel", Map.Trammel);
|
||||
}
|
||||
|
||||
if (map == Map.Malas)
|
||||
{
|
||||
return _malas ??= LoadLocations("malas", Map.Malas);
|
||||
}
|
||||
|
||||
if (map == Map.Tokuno)
|
||||
{
|
||||
return _tokuno ??= LoadLocations("tokuno", Map.Tokuno);
|
||||
}
|
||||
|
||||
return _felucca ??= LoadLocations("felucca", Map.Felucca);
|
||||
// Always return the same world tree, regardless of which map 'GetLocations' is called with
|
||||
return _world ??= LoadLocations("go", Map.Felucca);
|
||||
}
|
||||
|
||||
private static LocationTree LoadLocations(string fileName, Map map)
|
||||
{
|
||||
var lastBranch = new Dictionary<Mobile, GoCategory>();
|
||||
|
||||
var path = Path.Combine($"Data/Locations/{fileName}.json");
|
||||
var path = Path.Combine($"Data/{fileName}.json");
|
||||
|
||||
try
|
||||
{
|
||||
|
|
@ -67,7 +37,7 @@ public static class GoLocations
|
|||
catch (Exception e)
|
||||
{
|
||||
logger.Error(e, "Failed to load file {Path}.", path);
|
||||
return new LocationTree(map, [], null);
|
||||
return new LocationTree(map, lastBranch, new GoCategory { Name = "Error", Categories = [], Locations = [] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue