From 9522766529dbb2444672dc97c45ad3eca1230b4f Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 13 May 2024 16:21:30 +0800 Subject: [PATCH] adapt entlong to display in the unity inspector --- src/entlong.cs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/entlong.cs b/src/entlong.cs index 9ea9621..e076069 100644 --- a/src/entlong.cs +++ b/src/entlong.cs @@ -16,12 +16,23 @@ namespace DCFApixels.DragonECS [DebuggerTypeProxy(typeof(DebuggerProxy))] //[DataContract] [Serializable] - public readonly struct entlong : IEquatable, IEquatable +#if UNITY_EDITOR + public +#else + public readonly +#endif + struct entlong : IEquatable, IEquatable { public static readonly entlong NULL = default; //[DataMember] [FieldOffset(0)] - internal readonly long _full; //Union +#if UNITY_EDITOR + [UnityEngine.SerializeField] + internal +#else + internal readonly +#endif + long _full; //Union [FieldOffset(0), NonSerialized] internal readonly int _id; [FieldOffset(4), NonSerialized] @@ -343,6 +354,17 @@ namespace DCFApixels.DragonECS #endregion #region Constructors + public EntitySlotInfo(long full) + { + unchecked + { + ulong ufull = (ulong)full; + id = (int)((ufull >> 0) & 0x0000_0000_FFFF_FFFF); + gen = (short)((ufull >> 32) & 0x0000_0000_0000_FFFF); + world = (short)((ufull >> 48) & 0x0000_0000_0000_FFFF); + _full = full; + } + } public EntitySlotInfo(int id, short gen, short world) { this.id = id;