From aba19f98b91728707a7d951fcce64a14d8303e93 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 17 Jul 2023 15:54:28 +0800 Subject: [PATCH] setup entlong serialization --- src/entlong.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/entlong.cs b/src/entlong.cs index c8bd9a6..dc1d730 100644 --- a/src/entlong.cs +++ b/src/entlong.cs @@ -12,16 +12,17 @@ namespace DCFApixels.DragonECS /// Strong identifier/Permanent entity identifier [StructLayout(LayoutKind.Explicit, Pack = 2, Size = 8)] [DebuggerTypeProxy(typeof(DebuggerProxy))] + [Serializable] public readonly struct entlong : IEquatable, IEquatable { public static readonly entlong NULL = default; [FieldOffset(0)] internal readonly long full; //Union - [FieldOffset(0)] + [FieldOffset(0), NonSerialized] internal readonly int id; - [FieldOffset(4)] + [FieldOffset(4), NonSerialized] internal readonly short gen; - [FieldOffset(6)] + [FieldOffset(6), NonSerialized] internal readonly short world; #region Properties @@ -154,16 +155,18 @@ namespace DCFApixels.DragonECS #region operators [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator ==(in entlong a, in entlong b) => a.full == b.full; + public static bool operator ==(entlong a, entlong b) => a.full == b.full; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool operator !=(in entlong a, in entlong b) => a.full != b.full; + public static bool operator !=(entlong a, entlong b) => a.full != b.full; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator long(in entlong a) => a.full; + public static explicit operator long(entlong a) => a.full; [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator int(in entlong a) => a.ID; + public static explicit operator entlong(long a) => new entlong(a); + + [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static explicit operator entlong(in long a) => new entlong(a); + public static explicit operator int(entlong a) => a.ID; #endregion #region DebuggerProxy