mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
update entlong debug
This commit is contained in:
parent
514d761d00
commit
4490d1a0b5
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Security.Cryptography;
|
||||||
//using System.Runtime.Serialization;
|
//using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
@ -331,16 +332,24 @@ namespace DCFApixels.DragonECS
|
|||||||
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||||
public readonly struct EntitySlotInfo : IEquatable<EntitySlotInfo>
|
public readonly struct EntitySlotInfo : IEquatable<EntitySlotInfo>
|
||||||
{
|
{
|
||||||
|
private readonly long _full;
|
||||||
public readonly int id;
|
public readonly int id;
|
||||||
public readonly short gen;
|
public readonly short gen;
|
||||||
public readonly short world;
|
public readonly short world;
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
private EcsWorld World { get { return EcsWorld.GetWorld(world); } }
|
||||||
|
private EntState State { get { return _full == 0 ? EntState.Null : World.IsAlive(id, gen) ? EntState.Alive : EntState.Dead; } }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
public EntitySlotInfo(int id, short gen, short world)
|
public EntitySlotInfo(int id, short gen, short world)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
_full = ((long)world << 48 | (long)gen << 32 | (long)id);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -365,7 +374,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public override int GetHashCode() { return unchecked(id ^ gen ^ (world * EcsConsts.MAGIC_PRIME)); }
|
public override int GetHashCode() { return unchecked(id ^ gen ^ (world * EcsConsts.MAGIC_PRIME)); }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public override string ToString() { return $"slot(id:{id} g:{gen} w:{world})"; }
|
public override string ToString() { return $"slot(id:{id} g:{gen} w:{world} {(State == EntState.Null ? "null" : State == EntState.Alive ? "alive" : "not alive")})"; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public override bool Equals(object obj) { return obj is EntitySlotInfo other && this == other; }
|
public override bool Equals(object obj) { return obj is EntitySlotInfo other && this == other; }
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
@ -384,29 +393,33 @@ namespace DCFApixels.DragonECS
|
|||||||
id = this.id;
|
id = this.id;
|
||||||
world = this.world;
|
world = this.world;
|
||||||
}
|
}
|
||||||
|
public enum EntState { Null, Dead, Alive, }
|
||||||
internal class DebuggerProxy
|
internal class DebuggerProxy
|
||||||
{
|
{
|
||||||
private List<object> _componentsList = new List<object>();
|
private List<object> _componentsList = new List<object>();
|
||||||
private entlong _value;
|
private EntitySlotInfo _source;
|
||||||
public long full { get { return _value._full; } }
|
public long full { get { return _source._full; } }
|
||||||
public int id { get { return _value._id; } }
|
public int id { get { return _source.id; } }
|
||||||
public short gen { get { return _value._gen; } }
|
public short gen { get { return _source.gen; } }
|
||||||
public short world { get { return _value._world; } }
|
public short world { get { return _source.world; } }
|
||||||
public EntState State { get { return _value.IsNull ? EntState.Null : _value.IsAlive ? EntState.Alive : EntState.Dead; } }
|
public EntState State { get { return _source.State; } }
|
||||||
public EcsWorld EcsWorld { get { return EcsWorld.GetWorld(world); } }
|
public EcsWorld World { get { return _source.World; } }
|
||||||
public IEnumerable<object> components
|
public IEnumerable<object> Components
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_value.World.GetComponentsFor(_value.ID, _componentsList);
|
if(State == EntState.Alive)
|
||||||
return _componentsList;
|
{
|
||||||
|
World.GetComponentsFor(id, _componentsList);
|
||||||
|
return _componentsList;
|
||||||
|
}
|
||||||
|
return Array.Empty<object>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public DebuggerProxy(EntitySlotInfo value)
|
public DebuggerProxy(EntitySlotInfo value)
|
||||||
{
|
{
|
||||||
_value = new entlong(value.id, value.gen, value.world);
|
_source = value;
|
||||||
}
|
}
|
||||||
public enum EntState { Null, Dead, Alive, }
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user