mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 18:14:37 +08:00
update queries
This commit is contained in:
parent
16c62e69a6
commit
5f5940f443
@ -21,6 +21,11 @@
|
||||
a0 = b.Combine<A0>(0);
|
||||
a1 = b.Combine<A1>(1);
|
||||
}
|
||||
public void Deconstruct(out A0 a0, out A1 a1)
|
||||
{
|
||||
a0 = this.a0;
|
||||
a1 = this.a1;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2> : EcsAspect
|
||||
@ -37,6 +42,12 @@
|
||||
a1 = b.Combine<A1>(1);
|
||||
a2 = b.Combine<A2>(2);
|
||||
}
|
||||
public void Deconstruct(out A0 a0, out A1 a1, out A2 a2)
|
||||
{
|
||||
a0 = this.a0;
|
||||
a1 = this.a1;
|
||||
a2 = this.a2;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2, A3> : EcsAspect
|
||||
@ -56,6 +67,13 @@
|
||||
a2 = b.Combine<A2>(2);
|
||||
a3 = b.Combine<A3>(3);
|
||||
}
|
||||
public void Deconstruct(out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
{
|
||||
a0 = this.a0;
|
||||
a1 = this.a1;
|
||||
a2 = this.a2;
|
||||
a3 = this.a3;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2, A3, A4> : EcsAspect
|
||||
@ -78,6 +96,14 @@
|
||||
a3 = b.Combine<A3>(3);
|
||||
a4 = b.Combine<A4>(4);
|
||||
}
|
||||
public void Deconstruct(out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
{
|
||||
a0 = this.a0;
|
||||
a1 = this.a1;
|
||||
a2 = this.a2;
|
||||
a3 = this.a3;
|
||||
a4 = this.a4;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2, A3, A4, A5> : EcsAspect
|
||||
@ -103,167 +129,146 @@
|
||||
a4 = b.Combine<A4>(4);
|
||||
a5 = b.Combine<A5>(5);
|
||||
}
|
||||
public void Deconstruct(out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
{
|
||||
a0 = this.a0;
|
||||
a1 = this.a1;
|
||||
a2 = this.a2;
|
||||
a3 = this.a3;
|
||||
a4 = this.a4;
|
||||
a5 = this.a5;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CombinedAspectExtensions
|
||||
{
|
||||
#region Where 2
|
||||
public static EcsReadonlyGroup Where<A0, A1>(this EcsWorld self, out A0 a0, out A1 a1)
|
||||
public static EcsSpan Where<TCollection, A0, A1>(this TCollection entities, out A0 a0, out A1 a1)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return self.WhereFor(self.Entities, out a0, out a1);
|
||||
return entities.ToSpan().Where(out a0, out a1);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out A0 a0, out A1 a1)
|
||||
public static EcsSpan Where<A0, A1>(this EcsReadonlyGroup group, out A0 a0, out A1 a1)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
var combined = self.GetAspect<CombinedAspect<A0, A1>>();
|
||||
a0 = combined.a0;
|
||||
a1 = combined.a1;
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1>>(sourceGroup);
|
||||
return group.ToSpan().Where(out a0, out a1);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1>(this EcsWorld self)
|
||||
public static EcsSpan Where<A0, A1>(this EcsSpan span, out A0 a0, out A1 a1)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroup<CombinedAspect<A0, A1>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1>>(sourceGroup);
|
||||
var result = span.Where(out CombinedAspect<A0, A1> combined);
|
||||
(a0, a1) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 3
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2>(this EcsWorld self, out A0 a0, out A1 a1, out A2 a2)
|
||||
public static EcsSpan Where<TCollection, A0, A1, A2>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return self.WhereFor(self.Entities, out a0, out a1, out a2);
|
||||
return entities.ToSpan().Where(out a0, out a1, out a2);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out A0 a0, out A1 a1, out A2 a2)
|
||||
public static EcsSpan Where<A0, A1, A2>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
var combined = self.GetAspect<CombinedAspect<A0, A1, A2>>();
|
||||
a0 = combined.a0;
|
||||
a1 = combined.a1;
|
||||
a2 = combined.a2;
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2>>(sourceGroup);
|
||||
return group.ToSpan().Where(out a0, out a1, out a2);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2>(this EcsWorld self)
|
||||
public static EcsSpan Where<A0, A1, A2>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroup<CombinedAspect<A0, A1, A2>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2>>(sourceGroup);
|
||||
var result = span.Where(out CombinedAspect<A0, A1, A2> combined);
|
||||
(a0, a1, a2) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 4
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3>(this EcsWorld self, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
public static EcsSpan Where<TCollection, A0, A1, A2, A3>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return self.WhereFor(self.Entities, out a0, out a1, out a2, out a3);
|
||||
return entities.ToSpan().Where(out a0, out a1, out a2, out a3);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2, A3>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
public static EcsSpan Where<A0, A1, A2, A3>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
var combined = self.GetAspect<CombinedAspect<A0, A1, A2, A3>>();
|
||||
a0 = combined.a0;
|
||||
a1 = combined.a1;
|
||||
a2 = combined.a2;
|
||||
a3 = combined.a3;
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2, A3>>(sourceGroup);
|
||||
return group.ToSpan().Where(out a0, out a1, out a2, out a3);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3>(this EcsWorld self)
|
||||
public static EcsSpan Where<A0, A1, A2, A3>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroup<CombinedAspect<A0, A1, A2, A3>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2, A3>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2, A3>>(sourceGroup);
|
||||
var result = span.Where(out CombinedAspect<A0, A1, A2, A3> combined);
|
||||
(a0, a1, a2, a3) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 5
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3, A4>(this EcsWorld self, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
public static EcsSpan Where<TCollection, A0, A1, A2, A3, A4>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return self.WhereFor(self.Entities, out a0, out a1, out a2, out a3, out a4);
|
||||
return entities.ToSpan().Where(out a0, out a1, out a2, out a3, out a4);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2, A3, A4>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
public static EcsSpan Where<A0, A1, A2, A3, A4>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
var combined = self.GetAspect<CombinedAspect<A0, A1, A2, A3, A4>>();
|
||||
a0 = combined.a0;
|
||||
a1 = combined.a1;
|
||||
a2 = combined.a2;
|
||||
a3 = combined.a3;
|
||||
a4 = combined.a4;
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2, A3, A4>>(sourceGroup);
|
||||
return group.ToSpan().Where(out a0, out a1, out a2, out a3, out a4);
|
||||
}
|
||||
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3, A4>(this EcsWorld self)
|
||||
public static EcsSpan Where<A0, A1, A2, A3, A4>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroup<CombinedAspect<A0, A1, A2, A3, A4>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2, A3, A4>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2, A3, A4>>(sourceGroup);
|
||||
var result = span.Where(out CombinedAspect<A0, A1, A2, A3, A4> combined);
|
||||
(a0, a1, a2, a3, a4) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 6
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3, A4, A5>(this EcsWorld self, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
public static EcsSpan Where<TCollection, A0, A1, A2, A3, A4, A5>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().Where(out a0, out a1, out a2, out a3, out a4, out a5);
|
||||
}
|
||||
public static EcsSpan Where<A0, A1, A2, A3, A4, A5>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
@ -271,9 +276,9 @@
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
return self.WhereFor(self.Entities, out a0, out a1, out a2, out a3, out a4, out a5);
|
||||
return group.ToSpan().Where(out a0, out a1, out a2, out a3, out a4, out a5);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2, A3, A4, A5>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
public static EcsSpan Where<A0, A1, A2, A3, A4, A5>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
@ -281,28 +286,139 @@
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
var combined = self.GetAspect<CombinedAspect<A0, A1, A2, A3, A4, A5>>();
|
||||
a0 = combined.a0;
|
||||
a1 = combined.a1;
|
||||
a2 = combined.a2;
|
||||
a3 = combined.a3;
|
||||
a4 = combined.a4;
|
||||
a5 = combined.a5;
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2, A3, A4, A5>>(sourceGroup);
|
||||
var result = span.Where(out CombinedAspect<A0, A1, A2, A3, A4, A5> combined);
|
||||
(a0, a1, a2, a3, a4, a5) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3, A4, A5>(this EcsWorld self)
|
||||
#region WhereToGroup 2
|
||||
public static EcsReadonlyGroup WhereToGroup<TCollection, A0, A1>(this TCollection entities, out A0 a0, out A1 a1)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return self.WhereToGroup<CombinedAspect<A0, A1, A2, A3, A4, A5>>();
|
||||
return entities.ToSpan().WhereToGroup(out a0, out a1);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2, A3, A4, A5>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1>(this EcsReadonlyGroup group, out A0 a0, out A1 a1)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
return group.ToSpan().WhereToGroup(out a0, out a1);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1>(this EcsSpan span, out A0 a0, out A1 a1)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
var result = span.WhereToGroup(out CombinedAspect<A0, A1> combined);
|
||||
(a0, a1) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WhereToGroup 3
|
||||
public static EcsReadonlyGroup WhereToGroup<TCollection, A0, A1, A2>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().WhereToGroup(out a0, out a1, out a2);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
return group.ToSpan().WhereToGroup(out a0, out a1, out a2);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
var result = span.WhereToGroup(out CombinedAspect<A0, A1, A2> combined);
|
||||
(a0, a1, a2) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WhereToGroup 4
|
||||
public static EcsReadonlyGroup WhereToGroup<TCollection, A0, A1, A2, A3>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().WhereToGroup(out a0, out a1, out a2, out a3);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2, A3>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
return group.ToSpan().WhereToGroup(out a0, out a1, out a2, out a3);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2, A3>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2, out A3 a3)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
var result = span.WhereToGroup(out CombinedAspect<A0, A1, A2, A3> combined);
|
||||
(a0, a1, a2, a3) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WhereToGroup 5
|
||||
public static EcsReadonlyGroup WhereToGroup<TCollection, A0, A1, A2, A3, A4>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().WhereToGroup(out a0, out a1, out a2, out a3, out a4);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2, A3, A4>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
return group.ToSpan().WhereToGroup(out a0, out a1, out a2, out a3, out a4);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2, A3, A4>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
var result = span.WhereToGroup(out CombinedAspect<A0, A1, A2, A3, A4> combined);
|
||||
(a0, a1, a2, a3, a4) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WhereToGroup 6
|
||||
public static EcsReadonlyGroup WhereToGroup<TCollection, A0, A1, A2, A3, A4, A5>(this TCollection entities, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().WhereToGroup(out a0, out a1, out a2, out a3, out a4, out a5);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2, A3, A4, A5>(this EcsReadonlyGroup group, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
@ -310,7 +426,19 @@
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
return self.WhereToGroupFor<CombinedAspect<A0, A1, A2, A3, A4, A5>>(sourceGroup);
|
||||
return group.ToSpan().WhereToGroup(out a0, out a1, out a2, out a3, out a4, out a5);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<A0, A1, A2, A3, A4, A5>(this EcsSpan span, out A0 a0, out A1 a1, out A2 a2, out A3 a3, out A4 a4, out A5 a5)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
var result = span.WhereToGroup(out CombinedAspect<A0, A1, A2, A3, A4, A5> combined);
|
||||
(a0, a1, a2, a3, a4, a5) = combined;
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
|
||||
[DebuggerTypeProxy(typeof(DebuggerProxy))]
|
||||
public unsafe class EcsGroup : IDisposable, IEnumerable<int>
|
||||
public unsafe class EcsGroup : IDisposable, IEnumerable<int>, IEntitiesCollection
|
||||
{
|
||||
private EcsWorld _source;
|
||||
private int[] _dense;
|
||||
|
@ -6,7 +6,7 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public abstract partial class EcsWorld
|
||||
public abstract partial class EcsWorld: IEntitiesCollection
|
||||
{
|
||||
public readonly short id;
|
||||
private IEcsWorldConfig _config;
|
||||
@ -189,83 +189,16 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Where Query
|
||||
public EcsReadonlyGroup WhereToGroupFor<TAspect>(EcsSpan span, out TAspect aspect) where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
var executor = GetExecutor<EcsWhereExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.ExecuteFor(span);
|
||||
}
|
||||
public EcsReadonlyGroup WhereToGroupFor<TAspect>(EcsSpan span) where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
return GetExecutor<EcsWhereExecutor<TAspect>>().ExecuteFor(span);
|
||||
}
|
||||
public EcsReadonlyGroup WhereToGroup<TAspect>(out TAspect aspect) where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
var executor = GetExecutor<EcsWhereExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.Execute();
|
||||
}
|
||||
public EcsReadonlyGroup WhereToGroup<TAspect>() where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
return GetExecutor<EcsWhereExecutor<TAspect>>().Execute();
|
||||
}
|
||||
|
||||
public EcsSpan WhereFor<TAspect>(EcsSpan span, out TAspect aspect) where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
var executor = GetExecutor<EcsWhereSpanExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.ExecuteFor(span);
|
||||
}
|
||||
public EcsSpan WhereFor<TAspect>(EcsSpan span) where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
return GetExecutor<EcsWhereSpanExecutor<TAspect>>().ExecuteFor(span);
|
||||
}
|
||||
public EcsSpan Where<TAspect>(out TAspect aspect) where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
var executor = GetExecutor<EcsWhereSpanExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.Execute();
|
||||
}
|
||||
public EcsSpan Where<TAspect>() where TAspect : EcsAspect
|
||||
{
|
||||
if (_isEnableAutoReleaseDelEntBuffer)
|
||||
{
|
||||
ReleaseDelEntityBufferAll();
|
||||
}
|
||||
return GetExecutor<EcsWhereSpanExecutor<TAspect>>().Execute();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Entity
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsSpan ToSpan()
|
||||
{
|
||||
return _allEntites.ToSpan();
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int NewEntity()
|
||||
{
|
||||
int entityID = _entityDispenser.GetFree();
|
||||
@ -424,7 +357,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public void ReleaseDelEntityBufferAll()
|
||||
{
|
||||
ReleaseDelEntityBuffer(-1);
|
||||
ReleaseDelEntityBuffer(_delEntBufferCount);
|
||||
}
|
||||
public void ReleaseDelEntityBuffer(int count)
|
||||
{
|
||||
@ -432,15 +365,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (count < 0)
|
||||
{
|
||||
count = _delEntBufferCount;
|
||||
}
|
||||
else if (count > _delEntBufferCount)
|
||||
{
|
||||
count = _delEntBufferCount;
|
||||
}
|
||||
count = Math.Clamp(count, 0, _delEntBufferCount);
|
||||
_delEntBufferCount -= count;
|
||||
ReadOnlySpan<int> buffser = new ReadOnlySpan<int>(_delEntBuffer, _delEntBufferCount, count);
|
||||
for (int i = 0; i < _poolsCount; i++)
|
||||
@ -452,7 +377,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
_entityDispenser.Release(buffser[i]);
|
||||
}
|
||||
_freeSpace += count;// _entitesCapacity - _entitiesCount;
|
||||
_freeSpace += count;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -3,66 +3,6 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public sealed class EcsWhereExecutor<TAspect> : EcsQueryExecutor where TAspect : EcsAspect
|
||||
{
|
||||
private TAspect _aspect;
|
||||
private EcsGroup _filteredGroup;
|
||||
|
||||
private long _version;
|
||||
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
||||
#endif
|
||||
|
||||
#region Properties
|
||||
public TAspect Aspect
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _aspect;
|
||||
}
|
||||
public sealed override long Version
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _version;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region OnInitialize/OnDestroy
|
||||
protected sealed override void OnInitialize()
|
||||
{
|
||||
_aspect = World.GetAspect<TAspect>();
|
||||
_filteredGroup = EcsGroup.New(World);
|
||||
}
|
||||
protected sealed override void OnDestroy()
|
||||
{
|
||||
_filteredGroup.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup Execute() => ExecuteFor(_aspect.World.Entities);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup ExecuteFor(EcsSpan span)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeMarker.Begin();
|
||||
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
||||
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
||||
#endif
|
||||
unchecked { _version++; }
|
||||
_aspect.GetIteratorFor(span).CopyTo(_filteredGroup);
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeMarker.End();
|
||||
#endif
|
||||
return _filteredGroup.Readonly;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public sealed class EcsWhereSpanExecutor<TAspect> : EcsQueryExecutor where TAspect : EcsAspect
|
||||
{
|
||||
private TAspect _aspect;
|
||||
private int[] _filteredEntities;
|
||||
|
61
src/Executors/EcsWhereToGroupExecutor.cs
Normal file
61
src/Executors/EcsWhereToGroupExecutor.cs
Normal file
@ -0,0 +1,61 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public sealed class EcsWhereToGroupExecutor<TAspect> : EcsQueryExecutor where TAspect : EcsAspect
|
||||
{
|
||||
private TAspect _aspect;
|
||||
private EcsGroup _filteredGroup;
|
||||
|
||||
private long _version;
|
||||
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
private readonly EcsProfilerMarker _executeMarker = new EcsProfilerMarker("Where");
|
||||
#endif
|
||||
|
||||
#region Properties
|
||||
public TAspect Aspect
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _aspect;
|
||||
}
|
||||
public sealed override long Version
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _version;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region OnInitialize/OnDestroy
|
||||
protected sealed override void OnInitialize()
|
||||
{
|
||||
_aspect = World.GetAspect<TAspect>();
|
||||
_filteredGroup = EcsGroup.New(World);
|
||||
}
|
||||
protected sealed override void OnDestroy()
|
||||
{
|
||||
_filteredGroup.Dispose();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup Execute() => ExecuteFor(_aspect.World.Entities);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public EcsReadonlyGroup ExecuteFor(EcsSpan span)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeMarker.Begin();
|
||||
if (span.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
||||
if (span.WorldID != WorldID) throw new System.ArgumentException();//TODO составить текст исключения.
|
||||
#endif
|
||||
unchecked { _version++; }
|
||||
_aspect.GetIteratorFor(span).CopyTo(_filteredGroup);
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeMarker.End();
|
||||
#endif
|
||||
return _filteredGroup.Readonly;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
107
src/Executors/Queries.cs
Normal file
107
src/Executors/Queries.cs
Normal file
@ -0,0 +1,107 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public interface IEntitiesCollection
|
||||
{
|
||||
EcsSpan ToSpan();
|
||||
}
|
||||
public static class Queries
|
||||
{
|
||||
#region Where
|
||||
public static EcsSpan Where<TCollection, TAspect>(this TCollection entities, out TAspect aspect)
|
||||
where TAspect : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().Where(out aspect);
|
||||
}
|
||||
public static EcsSpan Where<TAspect>(this EcsReadonlyGroup group, out TAspect aspect)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
return group.ToSpan().Where(out aspect);
|
||||
}
|
||||
public static EcsSpan Where<TAspect>(this EcsSpan span, out TAspect aspect)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
EcsWorld world = span.World;
|
||||
if (world.IsEnableReleaseDelEntBuffer)
|
||||
{
|
||||
world.ReleaseDelEntityBufferAll();
|
||||
}
|
||||
var executor = world.GetExecutor<EcsWhereToGroupExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.ExecuteFor(span);
|
||||
}
|
||||
|
||||
|
||||
public static EcsSpan Where<TCollection, TAspect>(this TCollection entities)
|
||||
where TAspect : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().Where<TAspect>();
|
||||
}
|
||||
public static EcsSpan Where<TAspect>(this EcsReadonlyGroup group)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
return group.ToSpan().Where<TAspect>();
|
||||
}
|
||||
public static EcsSpan Where<TAspect>(this EcsSpan span)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
EcsWorld world = span.World;
|
||||
if (world.IsEnableReleaseDelEntBuffer)
|
||||
{
|
||||
world.ReleaseDelEntityBufferAll();
|
||||
}
|
||||
return world.GetExecutor<EcsWhereToGroupExecutor<TAspect>>().ExecuteFor(span);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region WhereToGroup
|
||||
public static EcsReadonlyGroup WhereToGroup<TCollection ,TAspect>(this TCollection entities, out TAspect aspect)
|
||||
where TAspect : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().WhereToGroup(out aspect);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<TAspect>(this EcsReadonlyGroup group, out TAspect aspect)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
return group.ToSpan().WhereToGroup(out aspect);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<TAspect>(this EcsSpan span, out TAspect aspect)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
EcsWorld world = span.World;
|
||||
if (world.IsEnableReleaseDelEntBuffer)
|
||||
{
|
||||
world.ReleaseDelEntityBufferAll();
|
||||
}
|
||||
var executor = world.GetExecutor<EcsWhereToGroupExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.ExecuteFor(span);
|
||||
}
|
||||
|
||||
|
||||
public static EcsReadonlyGroup WhereToGroup<TCollection, TAspect>(this TCollection entities)
|
||||
where TAspect : EcsAspect
|
||||
where TCollection : IEntitiesCollection
|
||||
{
|
||||
return entities.ToSpan().WhereToGroup<TAspect>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<TAspect>(this EcsReadonlyGroup group)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
return group.ToSpan().WhereToGroup<TAspect>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereToGroup<TAspect>(this EcsSpan span)
|
||||
where TAspect : EcsAspect
|
||||
{
|
||||
EcsWorld world = span.World;
|
||||
if (world.IsEnableReleaseDelEntBuffer)
|
||||
{
|
||||
world.ReleaseDelEntityBufferAll();
|
||||
}
|
||||
return world.GetExecutor<EcsWhereToGroupExecutor<TAspect>>().ExecuteFor(span);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user