summaryrefslogtreecommitdiff
path: root/Djup.Native/Types.cs
diff options
context:
space:
mode:
authorJoel Stålnacke <joel@saker.fi>2025-07-26 21:09:26 +0300
committerJoel Stålnacke <joel@saker.fi>2025-07-26 21:09:26 +0300
commit63506e59366acddf4a9e017ad8aebeadcf58c164 (patch)
tree2fa106661b85497fc1d63b7743a78e523ab48fba /Djup.Native/Types.cs
parent53f68bb7b0dce309723675c4b97f726a469031c0 (diff)
Old changesHEADmaster
Diffstat (limited to 'Djup.Native/Types.cs')
-rw-r--r--Djup.Native/Types.cs52
1 files changed, 42 insertions, 10 deletions
diff --git a/Djup.Native/Types.cs b/Djup.Native/Types.cs
index 478208f..7d9c41e 100644
--- a/Djup.Native/Types.cs
+++ b/Djup.Native/Types.cs
@@ -1,4 +1,5 @@
using System.Diagnostics;
+using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Djup.Native;
@@ -21,29 +22,60 @@ public struct Vec2
public override string ToString() => $"({X}, {Y})";
}
-public enum EntityKind
+public enum EntityState : byte
{
- None = 0,
- Ball
+ Inactive = 0,
+ Active,
+ Removed,
+ Dead
}
-[StructLayout(LayoutKind.Explicit)]
-public struct Entity
+public enum PlayerInput : byte
{
- [FieldOffset(0)]
- public EntityKind kind;
+ Up = 1 << 0,
+ Down = 1 << 1,
+ Left = 1 << 2,
+ Right = 1 << 3
+}
- [FieldOffset(4)]
- public Ball ball;
+[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 Ball
+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,