2023-12-24 15:40:19 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS
|
2023-05-07 00:50:02 +08:00
|
|
|
|
{
|
|
|
|
|
|
public abstract class EcsQueryExecutor
|
|
|
|
|
|
{
|
2023-12-24 15:40:19 +08:00
|
|
|
|
private EcsWorld _source;
|
2024-03-17 05:22:36 +08:00
|
|
|
|
public short WorldID
|
2023-12-24 15:40:19 +08:00
|
|
|
|
{
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-03-17 05:22:36 +08:00
|
|
|
|
get { return _source.id; }
|
2023-12-24 15:40:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
public EcsWorld World
|
|
|
|
|
|
{
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-03-17 05:22:36 +08:00
|
|
|
|
get { return _source; }
|
2023-12-24 15:40:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
public abstract long Version { get; }
|
2023-05-27 15:59:46 +08:00
|
|
|
|
internal void Initialize(EcsWorld world)
|
|
|
|
|
|
{
|
2023-12-24 15:40:19 +08:00
|
|
|
|
_source = world;
|
2023-05-27 15:59:46 +08:00
|
|
|
|
OnInitialize();
|
|
|
|
|
|
}
|
2023-12-24 15:40:19 +08:00
|
|
|
|
internal void Destroy()
|
|
|
|
|
|
{
|
|
|
|
|
|
OnDestroy();
|
|
|
|
|
|
_source = null;
|
|
|
|
|
|
}
|
2023-06-08 04:04:39 +08:00
|
|
|
|
protected abstract void OnInitialize();
|
2023-05-26 06:18:09 +08:00
|
|
|
|
protected abstract void OnDestroy();
|
2023-05-07 00:50:02 +08:00
|
|
|
|
}
|
2024-08-23 22:31:43 +08:00
|
|
|
|
|
|
|
|
|
|
public readonly struct PoolVersionsChecker
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly EcsMask _mask;
|
|
|
|
|
|
private readonly long[] _versions;
|
|
|
|
|
|
|
|
|
|
|
|
public PoolVersionsChecker(EcsMask mask) : this()
|
|
|
|
|
|
{
|
|
|
|
|
|
_mask = mask;
|
|
|
|
|
|
_versions = new long[mask._inc.Length + mask._exc.Length];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool NextEquals()
|
|
|
|
|
|
{
|
|
|
|
|
|
var slots = _mask.World._poolSlots;
|
|
|
|
|
|
bool result = true;
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
foreach (var i in _mask._inc)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (slots[i].version != _versions[index++])
|
|
|
|
|
|
{
|
|
|
|
|
|
result = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
foreach (var i in _mask._exc)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (slots[i].version != _versions[index++])
|
|
|
|
|
|
{
|
|
|
|
|
|
result = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-12-24 15:40:19 +08:00
|
|
|
|
}
|