DragonECS/tmp/AutoTableMembers/EcsTag.cs

98 lines
2.6 KiB
C#
Raw Normal View History

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-08 17:07:39 +08:00
public readonly struct EcsTag : IEcsMemberCachePool<EcsTag, tag>
2023-02-09 02:26:43 +08:00
where T :struct
2023-02-06 01:27:32 +08:00
{
2023-02-08 17:07:39 +08:00
private readonly EcsPool<tag> _pool;
2023-02-06 01:27:32 +08:00
private readonly int _poolID;
2023-02-08 17:07:39 +08:00
public EcsPool<tag> Pool => _pool;
2023-02-06 01:27:32 +08:00
public int PoolID => _poolID;
private EcsTag(int poolID)
{
_pool = null;
_poolID = poolID;
}
2023-02-08 17:07:39 +08:00
internal EcsTag(EcsPool<tag> 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-08 17:07:39 +08:00
void IEcsMemberCachePool<EcsTag, tag>.Inject(out EcsTag self, EcsPool<tag> 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-08 17:07:39 +08:00
public readonly struct EcsIncTag : IEcsMemberCachePool<EcsIncTag, tag>
2023-02-09 02:26:43 +08:00
where T :struct
2023-02-06 01:27:32 +08:00
{
2023-02-08 17:07:39 +08:00
private readonly EcsPool<tag> _pool;
2023-02-06 01:27:32 +08:00
private readonly int _poolID;
2023-02-07 17:11:56 +08:00
2023-02-08 17:07:39 +08:00
public EcsPool<tag> 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-08 17:07:39 +08:00
internal EcsIncTag(EcsPool<tag> pool)
2023-02-07 17:11:56 +08:00
{
_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);
2023-02-08 17:07:39 +08:00
void IEcsMemberCachePool<EcsIncTag, tag>.Inject(out EcsIncTag self, EcsPool<tag> pool)
2023-02-07 17:11:56 +08:00
{
self = new EcsIncTag(pool);
}
2023-02-06 01:27:32 +08:00
}
2023-02-08 17:07:39 +08:00
public readonly struct EcsExcTag : IEcsMemberCachePool<EcsExcTag, tag>
2023-02-09 02:26:43 +08:00
where T :struct
2023-02-06 01:27:32 +08:00
{
2023-02-08 17:07:39 +08:00
private readonly EcsPool<tag> _pool;
2023-02-06 01:27:32 +08:00
private readonly int _poolID;
2023-02-07 17:11:56 +08:00
2023-02-08 17:07:39 +08:00
public EcsPool<tag> 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-08 17:07:39 +08:00
internal EcsExcTag(EcsPool<tag> pool)
2023-02-07 17:11:56 +08:00
{
_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);
2023-02-08 17:07:39 +08:00
void IEcsMemberCachePool<EcsExcTag, tag>.Inject(out EcsExcTag self, EcsPool<tag> pool)
2023-02-07 17:11:56 +08:00
{
self = new EcsExcTag(pool);
}
2023-02-06 01:27:32 +08:00
}
}