2023-04-17 22:58:52 +08:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2023-04-07 05:08:48 +08:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
|
{
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public interface IEcsQueryMember { }
|
|
|
|
|
public interface IEcsQueryReadonlyField<TComponent> : IEcsQueryMember
|
|
|
|
|
{
|
|
|
|
|
public ref TComponent Read(ent entityID);
|
|
|
|
|
public bool Has(ent entityID);
|
|
|
|
|
}
|
|
|
|
|
public interface IEcsQueryField<TComponent> : IEcsQueryReadonlyField<TComponent>
|
2023-04-07 05:08:48 +08:00
|
|
|
|
where TComponent : struct
|
|
|
|
|
{
|
2023-04-09 02:52:39 +08:00
|
|
|
|
public ref TComponent Add(ent entityID);
|
2023-04-08 05:50:44 +08:00
|
|
|
|
public ref TComponent Write(ent entityID);
|
|
|
|
|
public void Del(ent entityID);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-17 22:58:52 +08:00
|
|
|
|
#region select
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public readonly struct inc_<TComponent> : IEcsQueryField<TComponent>
|
2023-04-07 05:08:48 +08:00
|
|
|
|
where TComponent : struct
|
|
|
|
|
{
|
2023-04-17 22:58:52 +08:00
|
|
|
|
internal readonly EcsPool<TComponent> pool;
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
internal inc_(EcsPool<TComponent> pool) => this.pool = pool;
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Add(ent entityID) => ref pool.Add(entityID.id);
|
2023-04-09 02:52:39 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Write(ent entityID) => ref pool.Write(entityID.id);
|
2023-04-07 17:15:31 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Read(ent entityID) => ref pool.Read(entityID.id);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public bool Has(ent entityID) => pool.Has(entityID.id);
|
2023-04-07 17:15:31 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public void Del(ent entityID) => pool.Del(entityID.id);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public static implicit operator inc_<TComponent>(EcsQueryBuilderBase buider) => buider.Include<TComponent>();
|
2023-04-07 05:08:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public readonly struct exc_<TComponent> : IEcsQueryField<TComponent>
|
2023-04-07 05:08:48 +08:00
|
|
|
|
where TComponent : struct
|
|
|
|
|
{
|
2023-04-17 22:58:52 +08:00
|
|
|
|
internal readonly EcsPool<TComponent> pool;
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
internal exc_(EcsPool<TComponent> pool) => this.pool = pool;
|
2023-04-09 02:52:39 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Add(ent entityID) => ref pool.Add(entityID.id);
|
2023-04-07 17:15:31 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Write(ent entityID) => ref pool.Write(entityID.id);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Read(ent entityID) => ref pool.Read(entityID.id);
|
2023-04-07 17:15:31 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public bool Has(ent entityID) => pool.Has(entityID.id);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public void Del(ent entityID) => pool.Del(entityID.id);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public static implicit operator exc_<TComponent>(EcsQueryBuilderBase buider) => buider.Exclude<TComponent>();
|
2023-04-07 05:08:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public readonly struct opt_<TComponent> : IEcsQueryField<TComponent>
|
2023-04-07 05:08:48 +08:00
|
|
|
|
where TComponent : struct
|
|
|
|
|
{
|
2023-04-17 22:58:52 +08:00
|
|
|
|
internal readonly EcsPool<TComponent> pool;
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
internal opt_(EcsPool<TComponent> pool) => this.pool = pool;
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Add(ent entityID) => ref pool.Add(entityID.id);
|
2023-04-09 02:52:39 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Write(ent entityID) => ref pool.Write(entityID.id);
|
2023-04-07 17:15:31 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public ref TComponent Read(ent entityID) => ref pool.Read(entityID.id);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public bool Has(ent entityID) => pool.Has(entityID.id);
|
2023-04-07 17:15:31 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public void Del(ent entityID) => pool.Del(entityID.id);
|
2023-04-07 05:08:48 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-17 22:58:52 +08:00
|
|
|
|
public static implicit operator opt_<TComponent>(EcsQueryBuilderBase buider) => buider.Optional<TComponent>();
|
2023-04-07 05:08:48 +08:00
|
|
|
|
}
|
2023-04-17 22:58:52 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
// #region select_readonly
|
|
|
|
|
// [StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public readonly struct inc_readonly_<T> : IEcsQueryReadonlyField<T>
|
|
|
|
|
// where T : struct
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// {
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// internal readonly EcsPool<T> pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// internal inc_readonly_(EcsPool<T> pool) => this.pool = pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public ref T Read(ent entityID) => ref pool.Read(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public bool Has(ent entityID) => pool.Has(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
//
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public static implicit operator inc_readonly_<T>(EcsQueryBuilderBase buider) => buider.Include<T>();
|
|
|
|
|
// public static implicit operator inc_readonly_<T>(inc_<T> o) => new inc_readonly_<T>(o.pool);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// [StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public readonly struct exc_readonly_<T> : IEcsQueryReadonlyField<T>
|
|
|
|
|
// where T : struct
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// {
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// internal readonly EcsPool<T> pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// internal exc_readonly_(EcsPool<T> pool) => this.pool = pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public ref T Read(ent entityID) => ref pool.Read(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public bool Has(ent entityID) => pool.Has(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
//
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public static implicit operator exc_readonly_<T>(EcsQueryBuilderBase buider) => buider.Exclude<T>();
|
|
|
|
|
// public static implicit operator exc_readonly_<T>(exc_<T> o) => new exc_readonly_<T>(o.pool);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// [StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public readonly struct opt_readonly_<T> : IEcsQueryReadonlyField<T>
|
|
|
|
|
// where T : struct
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// {
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// internal readonly EcsPool<T> pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// internal opt_readonly_(EcsPool<T> pool) => this.pool = pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public ref T Read(ent entityID) => ref pool.Read(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public bool Has(ent entityID) => pool.Has(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
//
|
2023-04-20 18:23:23 +08:00
|
|
|
|
// public static implicit operator opt_readonly_<T>(EcsQueryBuilderBase buider) => buider.Optional<T>();
|
|
|
|
|
// public static implicit operator opt_readonly_<T>(opt_<T> o) => new opt_readonly_<T>(o.pool);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// }
|
|
|
|
|
// #endregion
|
|
|
|
|
//
|
|
|
|
|
// #region join
|
|
|
|
|
// [StructLayout(LayoutKind.Sequential, Pack = 8, Size = 8)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public readonly struct attach : IEcsQueryField<Edge>
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// {
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// internal readonly EcsPool<Edge> pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// internal attach(EcsPool<Edge> pool) => this.pool = pool;
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public ref Edge Add(ent entityID) => ref pool.Add(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public ref Edge Write(ent entityID) => ref pool.Write(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public ref Edge Read(ent entityID) => ref pool.Read(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public bool Has(ent entityID) => pool.Has(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public void Del(ent entityID) => pool.Del(entityID.uniqueID);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2023-04-18 19:35:42 +08:00
|
|
|
|
// public static implicit operator attach(EcsQueryBuilderBase buider) => buider.Include<Edge>();
|
|
|
|
|
// public static implicit operator attach(inc_<Edge> o) => new attach(o.pool);
|
2023-04-17 22:58:52 +08:00
|
|
|
|
// }
|
|
|
|
|
// #endregion
|
2023-04-07 05:08:48 +08:00
|
|
|
|
}
|