using System.Runtime.InteropServices; namespace Djup.Native; [StructLayout(LayoutKind.Sequential)] public struct Vec2 { public float X { get; } public float Y { get; } public Vec2(float x, float y) { X = x; Y = y; } public override string ToString() => $"({X}, {Y})"; } public enum EntityKind { None = 0, Ball } [StructLayout(LayoutKind.Explicit)] public struct Entity { [FieldOffset(0)] public EntityKind kind; [FieldOffset(4)] public Ball ball; } [StructLayout(LayoutKind.Sequential)] public struct Ball { public Vec2 Position { get; set; } public Vec2 Velocity { get; set; } }