mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
- BitArray has always at least sizeof(uint) bits - Renamed Entity to EcsEntity - Added value parameter to EcsWorld.AssignComponent - Matched EcsWorld generic parameters - Added Scene - Added Entity
30 lines
607 B
Beef
30 lines
607 B
Beef
using System;
|
|
|
|
using internal GlitchyEngine.World;
|
|
|
|
namespace GlitchyEngine.World
|
|
{
|
|
public struct EcsEntity : uint64
|
|
{
|
|
// Binary Format:
|
|
// Bits: [0 - 31] [32 - 64]
|
|
// Data: Version Index
|
|
|
|
[Inline]
|
|
internal uint32 Version => (uint32)this;
|
|
|
|
[Inline]
|
|
internal uint32 Index => (uint32)(this >> 32);
|
|
|
|
[Inline]
|
|
static internal EcsEntity CreateEntityID(uint32 index, uint32 version)
|
|
{
|
|
return ((uint64)index << 32) | version;
|
|
}
|
|
|
|
[Inline]
|
|
internal bool IsValid => Index != InvalidEntity.Index;
|
|
|
|
public const EcsEntity InvalidEntity = CreateEntityID(uint32.MaxValue, 0);
|
|
}
|
|
} |