2023-02-06 01:27:32 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
|
{
|
2023-02-07 17:11:56 +08:00
|
|
|
|
public readonly struct EcsTag : IEcsMemberCachePool<EcsTag, TagType>
|
2023-02-06 01:27:32 +08:00
|
|
|
|
{
|
2023-02-07 17:11:56 +08:00
|
|
|
|
private readonly EcsPool<TagType> _pool;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
private readonly int _poolID;
|
|
|
|
|
|
2023-02-07 17:11:56 +08:00
|
|
|
|
public EcsPool<TagType> Pool => _pool;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
public int PoolID => _poolID;
|
|
|
|
|
|
|
|
|
|
private EcsTag(int poolID)
|
|
|
|
|
{
|
|
|
|
|
_pool = null;
|
|
|
|
|
_poolID = poolID;
|
|
|
|
|
}
|
2023-02-07 17:11:56 +08:00
|
|
|
|
internal EcsTag(EcsPool<TagType> pool)
|
2023-02-06 01:27:32 +08:00
|
|
|
|
{
|
|
|
|
|
_pool = pool;
|
|
|
|
|
_poolID = pool.ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Add(int entityID)
|
|
|
|
|
{
|
|
|
|
|
_pool.Add(entityID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-02-07 17:11:56 +08:00
|
|
|
|
public static implicit operator EcsTag(in int poolID) => new EcsTag(poolID);
|
2023-02-06 01:27:32 +08:00
|
|
|
|
|
2023-02-07 17:11:56 +08:00
|
|
|
|
void IEcsMemberCachePool<EcsTag, TagType>.Inject(out EcsTag self, EcsPool<TagType> pool)
|
2023-02-06 01:27:32 +08:00
|
|
|
|
{
|
2023-02-07 17:11:56 +08:00
|
|
|
|
self = new EcsTag(pool);
|
2023-02-06 01:27:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-07 17:11:56 +08:00
|
|
|
|
public readonly struct EcsIncTag : IEcsMemberCachePool<EcsIncTag, TagType>
|
2023-02-06 01:27:32 +08:00
|
|
|
|
{
|
2023-02-07 17:11:56 +08:00
|
|
|
|
private readonly EcsPool<TagType> _pool;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
private readonly int _poolID;
|
2023-02-07 17:11:56 +08:00
|
|
|
|
|
|
|
|
|
public EcsPool<TagType> Pool => _pool;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
public int PoolID => _poolID;
|
|
|
|
|
|
|
|
|
|
private EcsIncTag(int poolID)
|
|
|
|
|
{
|
2023-02-07 17:11:56 +08:00
|
|
|
|
_pool = null;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
_poolID = poolID;
|
|
|
|
|
}
|
2023-02-07 17:11:56 +08:00
|
|
|
|
internal EcsIncTag(EcsPool<TagType> pool)
|
|
|
|
|
{
|
|
|
|
|
_pool = pool;
|
|
|
|
|
_poolID = pool.ID;
|
|
|
|
|
}
|
2023-02-06 01:27:32 +08:00
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-02-07 17:11:56 +08:00
|
|
|
|
public static implicit operator EcsIncTag(in int poolID) => new EcsIncTag(poolID);
|
|
|
|
|
|
|
|
|
|
void IEcsMemberCachePool<EcsIncTag, TagType>.Inject(out EcsIncTag self, EcsPool<TagType> pool)
|
|
|
|
|
{
|
|
|
|
|
self = new EcsIncTag(pool);
|
|
|
|
|
}
|
2023-02-06 01:27:32 +08:00
|
|
|
|
}
|
2023-02-07 17:11:56 +08:00
|
|
|
|
public readonly struct EcsExcTag : IEcsMemberCachePool<EcsExcTag, TagType>
|
2023-02-06 01:27:32 +08:00
|
|
|
|
{
|
2023-02-07 17:11:56 +08:00
|
|
|
|
private readonly EcsPool<TagType> _pool;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
private readonly int _poolID;
|
2023-02-07 17:11:56 +08:00
|
|
|
|
|
|
|
|
|
public EcsPool<TagType> Pool => _pool;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
public int PoolID => _poolID;
|
|
|
|
|
|
|
|
|
|
private EcsExcTag(int poolID)
|
|
|
|
|
{
|
2023-02-07 17:11:56 +08:00
|
|
|
|
_pool = null;
|
2023-02-06 01:27:32 +08:00
|
|
|
|
_poolID = poolID;
|
|
|
|
|
}
|
2023-02-07 17:11:56 +08:00
|
|
|
|
internal EcsExcTag(EcsPool<TagType> pool)
|
|
|
|
|
{
|
|
|
|
|
_pool = pool;
|
|
|
|
|
_poolID = pool.ID;
|
|
|
|
|
}
|
2023-02-06 01:27:32 +08:00
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-02-07 17:11:56 +08:00
|
|
|
|
public static implicit operator EcsExcTag(in int poolID) => new EcsExcTag(poolID);
|
|
|
|
|
|
|
|
|
|
void IEcsMemberCachePool<EcsExcTag, TagType>.Inject(out EcsExcTag self, EcsPool<TagType> pool)
|
|
|
|
|
{
|
|
|
|
|
self = new EcsExcTag(pool);
|
|
|
|
|
}
|
2023-02-06 01:27:32 +08:00
|
|
|
|
}
|
|
|
|
|
}
|