Updates teleporter generator (#105)
This commit is contained in:
parent
141ec11330
commit
be0c33bc8a
5 changed files with 15228 additions and 1440 deletions
15
Projects/Server/JsonConverters/MapConverter.cs
Normal file
15
Projects/Server/JsonConverters/MapConverter.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
using System;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class MapConverter : JsonConverter<Map>
|
||||
{
|
||||
public override Map Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
=> Map.Parse(reader.GetString());
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, Map value, JsonSerializerOptions options)
|
||||
=> writer.WriteStringValue(value.Name);
|
||||
}
|
||||
}
|
||||
47
Projects/Server/JsonConverters/Point3dConverter.cs
Normal file
47
Projects/Server/JsonConverters/Point3dConverter.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Server.Json
|
||||
{
|
||||
public class Point3dConverter : JsonConverter<Point3D>
|
||||
{
|
||||
public override Point3D Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
if (reader.TokenType != JsonTokenType.StartArray)
|
||||
throw new JsonException("Point3d must be an array of x, y, z");
|
||||
|
||||
var data = new int[3];
|
||||
int count = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
reader.Read();
|
||||
if (reader.TokenType == JsonTokenType.EndArray)
|
||||
break;
|
||||
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
{
|
||||
if (count < 3)
|
||||
data[count] = reader.GetInt32();
|
||||
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (count < 2 || count > 3)
|
||||
throw new JsonException("Point3d must be an array of x, y, z");
|
||||
|
||||
return new Point3D(data[0], data[1], data[2]);
|
||||
}
|
||||
public override void Write(Utf8JsonWriter writer, Point3D value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStartArray();
|
||||
writer.WriteNumberValue(value.X);
|
||||
writer.WriteNumberValue(value.Y);
|
||||
writer.WriteNumberValue(value.Z);
|
||||
writer.WriteEndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -294,8 +294,6 @@ namespace Server.Network
|
|||
return -1;
|
||||
}
|
||||
|
||||
Console.WriteLine("Processing Packet... {0:X}", packetId);
|
||||
|
||||
if (!ns.Seeded)
|
||||
{
|
||||
if (packetId == 0xEF)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue