DragonECS/src/Interfaces/IEcsReadonlyTable.cs

42 lines
1.5 KiB
C#
Raw Normal View History

2023-04-06 11:50:31 +08:00
using System;
2023-04-08 00:47:35 +08:00
using System.Runtime.CompilerServices;
2023-04-06 11:50:31 +08:00
namespace DCFApixels.DragonECS
{
2023-04-06 23:40:47 +08:00
public interface IEcsReadonlyTable
2023-04-06 11:50:31 +08:00
{
#region Properties
2023-04-06 23:40:47 +08:00
/// <summary>Table Archetype</summary>
2023-04-06 11:50:31 +08:00
public Type ArchetypeType { get; }
2023-04-08 00:47:35 +08:00
public int Count { get; }
public int Capacity { get; }
2023-04-06 11:50:31 +08:00
#endregion
2023-04-06 23:40:47 +08:00
#region Methods
2023-04-06 11:50:31 +08:00
public EcsPool<T> GetPool<T>() where T : struct;
2023-04-08 00:47:35 +08:00
public ReadOnlySpan<IEcsPool> GetAllPools();
public TQuery Query<TQuery>(out TQuery query) where TQuery : EcsQueryBase;
2023-04-06 11:50:31 +08:00
2023-04-08 00:47:35 +08:00
public int GetComponentID<T>();
public bool IsMaskCompatible<TInc, TExc>(int entityID) where TInc : struct, IInc where TExc : struct, IExc;
public bool IsMaskCompatible(EcsComponentMask mask, int entityID);
public bool IsMaskCompatibleWithout(EcsComponentMask mask, int entity, int componentID);
2023-04-06 23:40:47 +08:00
#endregion
2023-04-06 11:50:31 +08:00
2023-04-06 23:40:47 +08:00
#region Internal Methods
2023-04-08 00:47:35 +08:00
internal void OnEntityComponentAdded(int entityID, int componentID);
internal void OnEntityComponentRemoved(int entityID, int componentID);
2023-04-06 11:50:31 +08:00
internal void RegisterGroup(EcsGroup group);
#endregion
}
2023-04-08 00:47:35 +08:00
public static class IEcsReadonlyTableExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool IsMaskCompatible<TInc>(this IEcsReadonlyTable self, int entityID) where TInc : struct, IInc
{
return self.IsMaskCompatible<TInc, Exc>(entityID);
}
}
2023-04-06 11:50:31 +08:00
}