adapt entlong to display in the unity inspector

This commit is contained in:
Mikhail 2024-05-13 16:21:30 +08:00
parent 30080e51e7
commit 9522766529

View File

@ -16,12 +16,23 @@ namespace DCFApixels.DragonECS
[DebuggerTypeProxy(typeof(DebuggerProxy))] [DebuggerTypeProxy(typeof(DebuggerProxy))]
//[DataContract] //[DataContract]
[Serializable] [Serializable]
public readonly struct entlong : IEquatable<long>, IEquatable<entlong> #if UNITY_EDITOR
public
#else
public readonly
#endif
struct entlong : IEquatable<long>, IEquatable<entlong>
{ {
public static readonly entlong NULL = default; public static readonly entlong NULL = default;
//[DataMember] //[DataMember]
[FieldOffset(0)] [FieldOffset(0)]
internal readonly long _full; //Union #if UNITY_EDITOR
[UnityEngine.SerializeField]
internal
#else
internal readonly
#endif
long _full; //Union
[FieldOffset(0), NonSerialized] [FieldOffset(0), NonSerialized]
internal readonly int _id; internal readonly int _id;
[FieldOffset(4), NonSerialized] [FieldOffset(4), NonSerialized]
@ -343,6 +354,17 @@ namespace DCFApixels.DragonECS
#endregion #endregion
#region Constructors #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) public EntitySlotInfo(int id, short gen, short world)
{ {
this.id = id; this.id = id;