fixed packets
This commit is contained in:
parent
7eea232196
commit
f9fc871390
|
|
@ -2,15 +2,15 @@ namespace mine2d.backend.data;
|
||||||
|
|
||||||
public interface IPacket
|
public interface IPacket
|
||||||
{
|
{
|
||||||
string Type { get; }
|
public string Type { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly struct MovePacket : IPacket
|
public struct MovePacket : IPacket
|
||||||
{
|
{
|
||||||
public string Type => "move";
|
public readonly string Type => "move";
|
||||||
|
|
||||||
readonly public string PlayerName;
|
public readonly string PlayerName;
|
||||||
readonly public Vector2 Movement;
|
public readonly Vector2 Movement;
|
||||||
|
|
||||||
public MovePacket(string playerName, Vector2 movement)
|
public MovePacket(string playerName, Vector2 movement)
|
||||||
{
|
{
|
||||||
|
|
@ -19,9 +19,9 @@ readonly struct MovePacket : IPacket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly struct ConnectPacket
|
public readonly struct ConnectPacket : IPacket
|
||||||
{
|
{
|
||||||
public readonly string Type = "connect";
|
public readonly string Type => "connect";
|
||||||
public readonly string PlayerName;
|
public readonly string PlayerName;
|
||||||
public readonly Guid PlayerGuid;
|
public readonly Guid PlayerGuid;
|
||||||
|
|
||||||
|
|
@ -32,9 +32,9 @@ readonly struct ConnectPacket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly struct TickPacket
|
readonly struct TickPacket : IPacket
|
||||||
{
|
{
|
||||||
public readonly string Type = "tick";
|
public readonly string Type => "tick";
|
||||||
public readonly uint Tick;
|
public readonly uint Tick;
|
||||||
|
|
||||||
public TickPacket(uint tick)
|
public TickPacket(uint tick)
|
||||||
|
|
@ -43,9 +43,9 @@ readonly struct TickPacket
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
readonly struct SelfMovedPacket
|
readonly struct SelfMovedPacket : IPacket
|
||||||
{
|
{
|
||||||
public readonly string Type = "selfMoved";
|
public readonly string Type => "selfMoved";
|
||||||
public readonly Vector2 Target;
|
public readonly Vector2 Target;
|
||||||
|
|
||||||
public SelfMovedPacket(Vector2 target)
|
public SelfMovedPacket(Vector2 target)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ public static class PacketUtils
|
||||||
{
|
{
|
||||||
Console.WriteLine(pp.Name);
|
Console.WriteLine(pp.Name);
|
||||||
}
|
}
|
||||||
var p = t.GetField(nameof(IPacket.Type));
|
var p = t.GetProperty(nameof(IPacket.Type));
|
||||||
if (p == null)
|
if (p == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(p), "p undef");
|
throw new ArgumentNullException(nameof(p), "p undef");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue