This commit is contained in:
CortexCore
2024-11-03 16:38:17 +08:00
parent 056e2cada5
commit 4ba741408d
4693 changed files with 2445 additions and 5443 deletions

View File

@@ -54,79 +54,87 @@ namespace BITKit.Entities
public T[] QueryComponents<T>()
{
return _queryCache.GetOrAdd(typeof(T), type =>
{
return _entities.Values.Where(entity => entity.TryGetComponent(out T component)).ToArray();
}).Cast<T>().ToArray();
throw new NotImplementedException();
// return _queryCache.GetOrAdd(typeof(T), type =>
// {
// return _entities.Values.Where(entity => entity.TryGetComponent(out T component)).ToArray();
// }).Cast<T>().ToArray();
}
public (T, T1)[] QueryComponents<T, T1>()
{
List<(T, T1)> list = new();
foreach (var entity in _entities.Values)
{
if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1))
list.Add((t, t1));
}
return list.ToArray();
throw new NotImplementedException();
// List<(T, T1)> list = new();
// foreach (var entity in _entities.Values)
// {
// if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1))
// list.Add((t, t1));
// }
// return list.ToArray();
}
public (T, T1, T2)[] QueryComponents<T, T1, T2>()
{
List<(T, T1, T2)> list = new();
foreach (var entity in _entities.Values)
{
if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1) && entity.TryGetComponent(out T2 t2))
list.Add((t, t1, t2));
}
return list.ToArray();
throw new NotImplementedException();
// List<(T, T1, T2)> list = new();
// foreach (var entity in _entities.Values)
// {
// if (entity.TryGetComponent(out T t) && entity.TryGetComponent(out T1 t1) && entity.TryGetComponent(out T2 t2))
// list.Add((t, t1, t2));
// }
// 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();
throw new NotImplementedException();
// 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();
throw new NotImplementedException();
// 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();
throw new NotImplementedException();
// 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();
throw new NotImplementedException();
// 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();
// throw new NotImplementedException();
}
}
}