This commit is contained in:
CortexCore
2024-06-22 17:58:05 +08:00
parent 46b2da988e
commit 07b6fbc2f3
9 changed files with 256 additions and 6 deletions

View File

@@ -63,6 +63,31 @@ public class UnityEntitiesServiceSingleton:IEntitiesService
{
return UnityEntitiesService.QueryComponents<T, T1, T2>();
}
public (T, T1, T2, T3)[] QueryComponents<T, T1, T2, T3>()
{
return UnityEntitiesService.QueryComponents<T, T1, T2, T3>();
}
public (T, T1, T2, T3, T4)[] QueryComponents<T, T1, T2, T3, T4>()
{
return UnityEntitiesService.QueryComponents<T, T1, T2, T3, T4>();
}
public (T, T1, T2, T3, T4, T5)[] QueryComponents<T, T1, T2, T3, T4, T5>()
{
return UnityEntitiesService.QueryComponents<T, T1, T2, T3, T4, T5>();
}
public (T, T1, T2, T3, T4, T5, T6)[] QueryComponents<T, T1, T2, T3, T4, T5, T6>()
{
return UnityEntitiesService.QueryComponents<T, T1, T2, T3, T4, T5, T6>();
}
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();
}
}
public class UnityEntitiesService : MonoBehaviour,IEntitiesService
@@ -198,4 +223,81 @@ public class UnityEntitiesService : MonoBehaviour,IEntitiesService
ListPool<(T t, T1 t1, T2 t2)>.Release(list);
return value;
}
(T, T1, T2, T3)[] IEntitiesService.QueryComponents<T, T1, T2, T3>() => QueryComponents<T, T1, T2, T3>();
public static (T, T1, T2, T3)[] QueryComponents<T, T1, T2, T3>()
{
var list = ListPool<(T, T1, T2, T3)>.Get();
foreach (var iEntity in Entities)
{
switch (iEntity as Entity)
{
case var x when x != null && x.TryGetComponentAny<T>(out var t) && x.TryGetComponentAny<T1>(out var t1) && x.TryGetComponentAny<T2>(out var t2) && x.TryGetComponentAny<T3>(out var t3):
list.Add((t, t1, t2, t3));
break;
}
}
var value = list.ToArray();
list.Clear();
ListPool<(T, T1, T2, T3)>.Release(list);
return value;
}
(T, T1, T2, T3, T4)[] IEntitiesService.QueryComponents<T, T1, T2, T3, T4>() => QueryComponents<T, T1, T2, T3, T4>();
public static (T, T1, T2, T3, T4)[] QueryComponents<T, T1, T2, T3, T4>()
{
var list = ListPool<(T, T1, T2, T3, T4)>.Get();
foreach (var iEntity in Entities)
{
switch (iEntity as Entity)
{
case var x when x != null && x.TryGetComponentAny<T>(out var t) && x.TryGetComponentAny<T1>(out var t1) && x.TryGetComponentAny<T2>(out var t2) && x.TryGetComponentAny<T3>(out var t3) && x.TryGetComponentAny<T4>(out var t4):
list.Add((t, t1, t2, t3, t4));
break;
}
}
var value = list.ToArray();
list.Clear();
ListPool<(T, T1, T2, T3, T4)>.Release(list);
return value;
}
(T, T1, T2, T3, T4, T5)[] IEntitiesService.QueryComponents<T, T1, T2, T3, T4, T5>() => QueryComponents<T, T1, T2, T3, T4, T5>();
public static (T, T1, T2, T3, T4, T5)[] QueryComponents<T, T1, T2, T3, T4, T5>()
{
var list = ListPool<(T, T1, T2, T3, T4, T5)>.Get();
foreach (var iEntity in Entities)
{
switch (iEntity as Entity)
{
case var x when x != null && x.TryGetComponentAny<T>(out var t) && x.TryGetComponentAny<T1>(out var t1) && x.TryGetComponentAny<T2>(out var t2) && x.TryGetComponentAny<T3>(out var t3) && x.TryGetComponentAny<T4>(out var t4) && x.TryGetComponentAny<T5>(out var t5):
list.Add((t, t1, t2, t3, t4, t5));
break;
}
}
var value = list.ToArray();
list.Clear();
ListPool<(T, T1, T2, T3, T4, T5)>.Release(list);
return value;
}
(T, T1, T2, T3, T4, T5, T6)[] IEntitiesService.QueryComponents<T, T1, T2, T3, T4, T5, T6>() => QueryComponents<T, T1, T2, T3, T4, T5, T6>();
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();
}
public static (T, T1, T2, T3, T4, T5, T6)[] QueryComponents<T, T1, T2, T3, T4, T5, T6>()
{
var list = ListPool<(T, T1, T2, T3, T4, T5, T6)>.Get();
foreach (var iEntity in Entities)
{
switch (iEntity as Entity)
{
case var x when x != null && x.TryGetComponentAny<T>(out var t) && x.TryGetComponentAny<T1>(out var t1) && x.TryGetComponentAny<T2>(out var t2) && x.TryGetComponentAny<T3>(out var t3) && x.TryGetComponentAny<T4>(out var t4) && x.TryGetComponentAny<T5>(out var t5) && x.TryGetComponentAny<T6>(out var t6):
list.Add((t, t1, t2, t3, t4, t5, t6));
break;
}
}
var value = list.ToArray();
list.Clear();
ListPool<(T, T1, T2, T3, T4, T5, T6)>.Release(list);
return value;
}
}