mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 21:01:52 +00:00
34 lines
770 B
C#
34 lines
770 B
C#
namespace DotNetScriptingHelper;
|
|
|
|
public readonly struct EcsEntity
|
|
{
|
|
// Binary Format:
|
|
// Bits: [0 - 31] [32 - 64]
|
|
// Data: Version Index
|
|
|
|
private readonly ulong _id;
|
|
|
|
internal uint Version => (uint)_id;
|
|
|
|
internal uint Index => (uint)(_id >> 32);
|
|
|
|
public EcsEntity(uint index, uint version)
|
|
{
|
|
_id = ((ulong)index << 32) | version;
|
|
}
|
|
|
|
public bool IsValid => Index != InvalidEntity.Index;
|
|
|
|
public static readonly EcsEntity InvalidEntity = new(uint.MaxValue, 0);
|
|
|
|
public static bool operator ==(EcsEntity left, EcsEntity right)
|
|
{
|
|
return left._id == right._id;
|
|
}
|
|
|
|
public static bool operator !=(EcsEntity left, EcsEntity right)
|
|
{
|
|
return left._id != right._id;
|
|
}
|
|
}
|