using System.Text.Json.Serialization; namespace Backend; // -------- Client → Server -------- /// Cursor position update from the browser. public sealed class CursorMessage { [JsonPropertyName("type")] public string Type { get; set; } = "cursor"; [JsonPropertyName("x")] public float X { get; set; } [JsonPropertyName("y")] public float Y { get; set; } } // -------- Server → Client -------- /// Sent once on WebSocket open. Tells the client the world dimensions. public sealed class InitFrame { [JsonPropertyName("type")] public string Type { get; set; } = "init"; [JsonPropertyName("world")] public float[] World { get; set; } = new[] { 1f, 1f }; } /// Sent every physics tick with the current ship pose and target. public sealed class StateFrame { [JsonPropertyName("type")] public string Type { get; set; } = "state"; [JsonPropertyName("x")] public float X { get; set; } [JsonPropertyName("y")] public float Y { get; set; } [JsonPropertyName("angle")] public float Angle { get; set; } [JsonPropertyName("engine")] public int Engine { get; set; } [JsonPropertyName("target")] public float[] Target { get; set; } = new[] { 0.5f, 0.5f }; [JsonPropertyName("step")] public int Step { get; set; } } /// Source-gen JSON contracts. [JsonSourceGenerationOptions(WriteIndented = false)] [JsonSerializable(typeof(CursorMessage))] [JsonSerializable(typeof(InitFrame))] [JsonSerializable(typeof(StateFrame))] internal partial class WireJsonContext : System.Text.Json.Serialization.JsonSerializerContext { }