1
This commit is contained in:
@@ -2,6 +2,8 @@ using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Security.AccessControl;
|
||||
using System.Threading;
|
||||
|
||||
namespace BITKit.Entities
|
||||
@@ -47,7 +49,7 @@ namespace BITKit.Entities
|
||||
|
||||
public IEntity[] Query<T>()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new NotImplementedException("Obsoleted");
|
||||
}
|
||||
|
||||
public T[] QueryComponents<T>()
|
||||
@@ -77,6 +79,55 @@ namespace BITKit.Entities
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public (T, T1, T2, T3)[] QueryComponents<T, T1, T2, T3>()
|
||||
{
|
||||
List<(T, T1, T2, T3)> list = new();
|
||||
foreach (var entity in _entities.Values)
|
||||
{
|
||||
if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1) && entity.TryGetComponent(out T2 t2) && entity.TryGetComponent(out T3 t3))
|
||||
list.Add((t, t1, t2, t3));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public (T, T1, T2, T3, T4)[] QueryComponents<T, T1, T2, T3, T4>()
|
||||
{
|
||||
List<(T, T1, T2, T3, T4)> list = new();
|
||||
foreach (var entity in _entities.Values)
|
||||
{
|
||||
if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1) && entity.TryGetComponent(out T2 t2) && entity.TryGetComponent(out T3 t3) && entity.TryGetComponent(out T4 t4))
|
||||
list.Add((t, t1, t2, t3, t4));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public (T, T1, T2, T3, T4, T5)[] QueryComponents<T, T1, T2, T3, T4, T5>()
|
||||
{
|
||||
List<(T, T1, T2, T3, T4, T5)> list = new();
|
||||
foreach (var entity in _entities.Values)
|
||||
{
|
||||
if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1) && entity.TryGetComponent(out T2 t2) && entity.TryGetComponent(out T3 t3) && entity.TryGetComponent(out T4 t4) && entity.TryGetComponent(out T5 t5))
|
||||
list.Add((t, t1, t2, t3, t4, t5));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public (T, T1, T2, T3, T4, T5, T6)[] QueryComponents<T, T1, T2, T3, T4, T5, T6>()
|
||||
{
|
||||
List<(T, T1, T2, T3, T4, T5, T6)> list = new();
|
||||
foreach (var entity in _entities.Values)
|
||||
{
|
||||
if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1) && entity.TryGetComponent(out T2 t2) && entity.TryGetComponent(out T3 t3) && entity.TryGetComponent(out T4 t4) && entity.TryGetComponent(out T5 t5) && entity.TryGetComponent(out T6 t6))
|
||||
list.Add((t, t1, t2, t3, t4, t5, t6));
|
||||
}
|
||||
return list.ToArray();
|
||||
}
|
||||
|
||||
public ValueTuple<T, T1, T2, T3, T4, T5, T6, TRest>[] QueryComponents<T, T1, T2, T3, T4, T5, T6, TRest>() where TRest : struct
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ namespace BITKit.Entities
|
||||
int Id { get; }
|
||||
CancellationToken CancellationToken { get; }
|
||||
bool TryGetComponent<T>(out T component);
|
||||
bool TryGetComponent(Type type, out IEntityComponent component);
|
||||
IEntityComponent[] Components { get; }
|
||||
bool RegisterComponent<T>(T component);
|
||||
IServiceProvider ServiceProvider { get; }
|
||||
@@ -124,5 +125,63 @@ namespace BITKit.Entities
|
||||
/// <returns></returns>
|
||||
ValueTuple<T, T1, T2>[] QueryComponents<T, T1, T2>();
|
||||
|
||||
/// <summary>
|
||||
/// 查询4个组件
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <typeparam name="T2"></typeparam>
|
||||
/// <typeparam name="T3"></typeparam>
|
||||
/// <returns></returns>
|
||||
ValueTuple<T, T1, T2, T3>[] QueryComponents<T, T1, T2, T3>();
|
||||
|
||||
/// <summary>
|
||||
/// 查询5个组件
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <typeparam name="T2"></typeparam>
|
||||
/// <typeparam name="T3"></typeparam>
|
||||
/// <typeparam name="T4"></typeparam>
|
||||
/// <returns></returns>
|
||||
ValueTuple<T, T1, T2, T3, T4>[] QueryComponents<T, T1, T2, T3, T4>();
|
||||
/// <summary>
|
||||
/// 查询6个组件
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <typeparam name="T2"></typeparam>
|
||||
/// <typeparam name="T3"></typeparam>
|
||||
/// <typeparam name="T4"></typeparam>
|
||||
/// <typeparam name="T5"></typeparam>
|
||||
/// <returns></returns>
|
||||
ValueTuple<T, T1, T2, T3, T4, T5>[] QueryComponents<T, T1, T2, T3, T4, T5>();
|
||||
|
||||
/// <summary>
|
||||
/// 查询7个组件
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <typeparam name="T2"></typeparam>
|
||||
/// <typeparam name="T3"></typeparam>
|
||||
/// <typeparam name="T4"></typeparam>
|
||||
/// <typeparam name="T5"></typeparam>
|
||||
/// <typeparam name="T6"></typeparam>
|
||||
/// <returns></returns>
|
||||
ValueTuple<T, T1, T2, T3, T4, T5, T6>[] QueryComponents<T, T1, T2, T3, T4, T5, T6>();
|
||||
|
||||
/// <summary>
|
||||
/// 查询8个组件
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="T1"></typeparam>
|
||||
/// <typeparam name="T2"></typeparam>
|
||||
/// <typeparam name="T3"></typeparam>
|
||||
/// <typeparam name="T4"></typeparam>
|
||||
/// <typeparam name="T5"></typeparam>
|
||||
/// <typeparam name="T6"></typeparam>
|
||||
/// <typeparam name="TRest">剩余实例</typeparam>
|
||||
/// <returns></returns>
|
||||
ValueTuple<T, T1, T2, T3, T4, T5, T6, TRest>[] QueryComponents<T, T1, T2, T3, T4, T5, T6, TRest>() where TRest : struct;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user