summaryrefslogtreecommitdiff
path: root/Djup.Native/src/Types.cs
diff options
context:
space:
mode:
authorJoel Stålnacke <joel@saker.fi>2026-03-19 22:30:56 +0200
committerJoel Stålnacke <joel@saker.fi>2026-03-19 22:30:56 +0200
commit745406dc65aecc438a53f96badc387a32b7a338f (patch)
treecc597855dac943efe627fce160782585e27feadf /Djup.Native/src/Types.cs
parent3b60cd682120947119f442bb71ab2a5e98decccc (diff)
Add Mibo project
The Djup project is DesktopGL project
Diffstat (limited to 'Djup.Native/src/Types.cs')
-rw-r--r--Djup.Native/src/Types.cs89
1 files changed, 89 insertions, 0 deletions
diff --git a/Djup.Native/src/Types.cs b/Djup.Native/src/Types.cs
new file mode 100644
index 0000000..7d9c41e
--- /dev/null
+++ b/Djup.Native/src/Types.cs
@@ -0,0 +1,89 @@
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+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)
+ {
+ Debug.Assert(float.IsFinite(x));
+ Debug.Assert(float.IsFinite(y));
+
+ X = x;
+ Y = y;
+ }
+
+ public override string ToString() => $"({X}, {Y})";
+}
+
+public enum EntityState : byte
+{
+ Inactive = 0,
+ Active,
+ Removed,
+ Dead
+}
+
+public enum PlayerInput : byte
+{
+ Up = 1 << 0,
+ Down = 1 << 1,
+ Left = 1 << 2,
+ Right = 1 << 3
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public struct Player
+{
+ public EntityState State { get; }
+ private byte input;
+ public Vec2 Position { get; set; }
+ public Vec2 Velocity { get; set; }
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public struct Bullet
+{
+ public EntityState State { get; set; }
+ public Vec2 Position { get; set; }
+ public Vec2 Velocity { get; set; }
+}
+
+[StructLayout(LayoutKind.Sequential)]
+public struct Snapshot
+{
+ [InlineArray(Constants.WorldMaxPlayers)]
+ public struct PlayerArray
+ {
+ private Player _element0;
+ }
+
+ [InlineArray(Constants.WorldMaxBullets)]
+ public struct BallArray
+ {
+ private Bullet _element0;
+ }
+
+ private byte active;
+ public uint Tick { get; }
+ public PlayerArray Players { get; }
+ public BallArray Bullets { get; }
+}
+
+public enum LogLevel
+{
+ Trace,
+ Debug,
+ Info,
+ Warn,
+ Error,
+ Fatal
+}
+
+public delegate void LoggerDelegate(LogLevel level, string source, int line, string message);