mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
rename Subject to Aspect
This commit is contained in:
parent
65878aa9a0
commit
2b5cc8b27b
317
src/Builtin/Aspects.cs
Normal file
317
src/Builtin/Aspects.cs
Normal file
@ -0,0 +1,317 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public sealed class EmptyAspect : EcsAspect { }
|
||||
|
||||
public sealed class SingleAspect<TPool> : EcsAspect where TPool : IEcsPoolImplementation, new()
|
||||
{
|
||||
public readonly TPool pool;
|
||||
public SingleAspect(Builder b)
|
||||
{
|
||||
pool = b.Include<TPool>();
|
||||
}
|
||||
}
|
||||
public sealed class CombinedAspect<A0, A1> : EcsAspect
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
public readonly A0 a0;
|
||||
public readonly A1 a1;
|
||||
public CombinedAspect(Builder b)
|
||||
{
|
||||
a0 = b.Combine<A0>(0);
|
||||
a1 = b.Combine<A1>(1);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2> : EcsAspect
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
public readonly A0 a0;
|
||||
public readonly A1 a1;
|
||||
public readonly A2 a2;
|
||||
public CombinedAspect(Builder b)
|
||||
{
|
||||
a0 = b.Combine<A0>(0);
|
||||
a1 = b.Combine<A1>(1);
|
||||
a2 = b.Combine<A2>(2);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2, A3> : EcsAspect
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
public readonly A0 a0;
|
||||
public readonly A1 a1;
|
||||
public readonly A2 a2;
|
||||
public readonly A3 a3;
|
||||
public CombinedAspect(Builder b)
|
||||
{
|
||||
a0 = b.Combine<A0>(0);
|
||||
a1 = b.Combine<A1>(1);
|
||||
a2 = b.Combine<A2>(2);
|
||||
a3 = b.Combine<A3>(3);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2, A3, A4> : EcsAspect
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
public readonly A0 a0;
|
||||
public readonly A1 a1;
|
||||
public readonly A2 a2;
|
||||
public readonly A3 a3;
|
||||
public readonly A4 a4;
|
||||
public CombinedAspect(Builder b)
|
||||
{
|
||||
a0 = b.Combine<A0>(0);
|
||||
a1 = b.Combine<A1>(1);
|
||||
a2 = b.Combine<A2>(2);
|
||||
a3 = b.Combine<A3>(3);
|
||||
a4 = b.Combine<A4>(4);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedAspect<A0, A1, A2, A3, A4, A5> : EcsAspect
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
public readonly A0 a0;
|
||||
public readonly A1 a1;
|
||||
public readonly A2 a2;
|
||||
public readonly A3 a3;
|
||||
public readonly A4 a4;
|
||||
public readonly A5 a5;
|
||||
public CombinedAspect(Builder b)
|
||||
{
|
||||
a0 = b.Combine<A0>(0);
|
||||
a1 = b.Combine<A1>(1);
|
||||
a2 = b.Combine<A2>(2);
|
||||
a3 = b.Combine<A3>(3);
|
||||
a4 = b.Combine<A4>(4);
|
||||
a5 = b.Combine<A5>(5);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CombinedAspectExtensions
|
||||
{
|
||||
#region Where 2
|
||||
public static EcsReadonlyGroup Where<A0, A1>(this EcsWorld self, out A0 a0, out A1 a1)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
return self.WhereFor(self.Entities, out a0, out a1);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1>(this EcsWorld self, EcsReadonlyGroup sourceGroup, 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.WhereFor<CombinedAspect<A0, A1>>(sourceGroup);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1>(this EcsWorld self)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
return self.Where<CombinedAspect<A0, A1>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
{
|
||||
return self.WhereFor<CombinedAspect<A0, A1>>(sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 3
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2>(this EcsWorld self, out A0 a0, out A1 a1, out A2 a2)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
return self.WhereFor(self.Entities, 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)
|
||||
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.WhereFor<CombinedAspect<A0, A1, A2>>(sourceGroup);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2>(this EcsWorld self)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
{
|
||||
return self.Where<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.WhereFor<CombinedAspect<A0, A1, A2>>(sourceGroup);
|
||||
}
|
||||
#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)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
return self.WhereFor(self.Entities, 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)
|
||||
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.WhereFor<CombinedAspect<A0, A1, A2, A3>>(sourceGroup);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3>(this EcsWorld self)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
{
|
||||
return self.Where<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.WhereFor<CombinedAspect<A0, A1, A2, A3>>(sourceGroup);
|
||||
}
|
||||
#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)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
return self.WhereFor(self.Entities, 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)
|
||||
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.WhereFor<CombinedAspect<A0, A1, A2, A3, A4>>(sourceGroup);
|
||||
}
|
||||
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3, A4>(this EcsWorld self)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
{
|
||||
return self.Where<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.WhereFor<CombinedAspect<A0, A1, A2, A3, A4>>(sourceGroup);
|
||||
}
|
||||
#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)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
return self.WhereFor(self.Entities, 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)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
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.WhereFor<CombinedAspect<A0, A1, A2, A3, A4, A5>>(sourceGroup);
|
||||
}
|
||||
|
||||
|
||||
public static EcsReadonlyGroup Where<A0, A1, A2, A3, A4, A5>(this EcsWorld self)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
return self.Where<CombinedAspect<A0, A1, A2, A3, A4, A5>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<A0, A1, A2, A3, A4, A5>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where A0 : EcsAspect
|
||||
where A1 : EcsAspect
|
||||
where A2 : EcsAspect
|
||||
where A3 : EcsAspect
|
||||
where A4 : EcsAspect
|
||||
where A5 : EcsAspect
|
||||
{
|
||||
return self.WhereFor<CombinedAspect<A0, A1, A2, A3, A4, A5>>(sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -141,9 +141,12 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
}
|
||||
|
||||
public static class InjectSystemExtensions
|
||||
public static partial class EcsPipelineExtensions
|
||||
{
|
||||
public static void Inject<T>(EcsPipeline self, T data) => self.GetRunner<IEcsInject<T>>().Inject(data);
|
||||
}
|
||||
public static partial class EcsPipelineBuilderExtensions
|
||||
{
|
||||
public static EcsPipeline.Builder Inject<T>(this EcsPipeline.Builder self, T data)
|
||||
{
|
||||
if (data == null) throw new ArgumentNullException();
|
||||
|
@ -1,317 +0,0 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public sealed class EmptySubject : EcsSubject { }
|
||||
|
||||
public sealed class SingleSubject<TPool> : EcsSubject where TPool : IEcsPoolImplementation, new()
|
||||
{
|
||||
public readonly TPool pool;
|
||||
public SingleSubject(Builder b)
|
||||
{
|
||||
pool = b.Include<TPool>();
|
||||
}
|
||||
}
|
||||
public sealed class CombinedSubject<S0, S1> : EcsSubject
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
{
|
||||
public readonly S0 s0;
|
||||
public readonly S1 s1;
|
||||
public CombinedSubject(Builder b)
|
||||
{
|
||||
s0 = b.Combine<S0>(0);
|
||||
s1 = b.Combine<S1>(1);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedSubject<S0, S1, S2> : EcsSubject
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
{
|
||||
public readonly S0 s0;
|
||||
public readonly S1 s1;
|
||||
public readonly S2 s2;
|
||||
public CombinedSubject(Builder b)
|
||||
{
|
||||
s0 = b.Combine<S0>(0);
|
||||
s1 = b.Combine<S1>(1);
|
||||
s2 = b.Combine<S2>(2);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedSubject<S0, S1, S2, S3> : EcsSubject
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
{
|
||||
public readonly S0 s0;
|
||||
public readonly S1 s1;
|
||||
public readonly S2 s2;
|
||||
public readonly S3 s3;
|
||||
public CombinedSubject(Builder b)
|
||||
{
|
||||
s0 = b.Combine<S0>(0);
|
||||
s1 = b.Combine<S1>(1);
|
||||
s2 = b.Combine<S2>(2);
|
||||
s3 = b.Combine<S3>(3);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedSubject<S0, S1, S2, S3, S4> : EcsSubject
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
{
|
||||
public readonly S0 s0;
|
||||
public readonly S1 s1;
|
||||
public readonly S2 s2;
|
||||
public readonly S3 s3;
|
||||
public readonly S4 s4;
|
||||
public CombinedSubject(Builder b)
|
||||
{
|
||||
s0 = b.Combine<S0>(0);
|
||||
s1 = b.Combine<S1>(1);
|
||||
s2 = b.Combine<S2>(2);
|
||||
s3 = b.Combine<S3>(3);
|
||||
s4 = b.Combine<S4>(4);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CombinedSubject<S0, S1, S2, S3, S4, S5> : EcsSubject
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
where S5 : EcsSubject
|
||||
{
|
||||
public readonly S0 s0;
|
||||
public readonly S1 s1;
|
||||
public readonly S2 s2;
|
||||
public readonly S3 s3;
|
||||
public readonly S4 s4;
|
||||
public readonly S5 s5;
|
||||
public CombinedSubject(Builder b)
|
||||
{
|
||||
s0 = b.Combine<S0>(0);
|
||||
s1 = b.Combine<S1>(1);
|
||||
s2 = b.Combine<S2>(2);
|
||||
s3 = b.Combine<S3>(3);
|
||||
s4 = b.Combine<S4>(4);
|
||||
s5 = b.Combine<S5>(5);
|
||||
}
|
||||
}
|
||||
|
||||
public static class CombinedSubjectExtensions
|
||||
{
|
||||
#region Where 2
|
||||
public static EcsReadonlyGroup Where<S0, S1>(this EcsWorld self, out S0 s0, out S1 s1)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
{
|
||||
return self.WhereFor(self.Entities, out s0, out s1);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out S0 s0, out S1 s1)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
{
|
||||
var combined = self.GetSubject<CombinedSubject<S0, S1>>();
|
||||
s0 = combined.s0;
|
||||
s1 = combined.s1;
|
||||
return self.WhereFor<CombinedSubject<S0, S1>>(sourceGroup);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<S0, S1>(this EcsWorld self)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
{
|
||||
return self.Where<CombinedSubject<S0, S1>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
{
|
||||
return self.WhereFor<CombinedSubject<S0, S1>>(sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 3
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2>(this EcsWorld self, out S0 s0, out S1 s1, out S2 s2)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
{
|
||||
return self.WhereFor(self.Entities, out s0, out s1, out s2);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out S0 s0, out S1 s1, out S2 s2)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
{
|
||||
var combined = self.GetSubject<CombinedSubject<S0, S1, S2>>();
|
||||
s0 = combined.s0;
|
||||
s1 = combined.s1;
|
||||
s2 = combined.s2;
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2>>(sourceGroup);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2>(this EcsWorld self)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
{
|
||||
return self.Where<CombinedSubject<S0, S1, S2>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
{
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2>>(sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 4
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2, S3>(this EcsWorld self, out S0 s0, out S1 s1, out S2 s2, out S3 s3)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
{
|
||||
return self.WhereFor(self.Entities, out s0, out s1, out s2, out s3);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2, S3>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out S0 s0, out S1 s1, out S2 s2, out S3 s3)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
{
|
||||
var combined = self.GetSubject<CombinedSubject<S0, S1, S2, S3>>();
|
||||
s0 = combined.s0;
|
||||
s1 = combined.s1;
|
||||
s2 = combined.s2;
|
||||
s3 = combined.s3;
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2, S3>>(sourceGroup);
|
||||
}
|
||||
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2, S3>(this EcsWorld self)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
{
|
||||
return self.Where<CombinedSubject<S0, S1, S2, S3>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2, S3>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
{
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2, S3>>(sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 5
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2, S3, S4>(this EcsWorld self, out S0 s0, out S1 s1, out S2 s2, out S3 s3, out S4 s4)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
{
|
||||
return self.WhereFor(self.Entities, out s0, out s1, out s2, out s3, out s4);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2, S3, S4>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out S0 s0, out S1 s1, out S2 s2, out S3 s3, out S4 s4)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
{
|
||||
var combined = self.GetSubject<CombinedSubject<S0, S1, S2, S3, S4>>();
|
||||
s0 = combined.s0;
|
||||
s1 = combined.s1;
|
||||
s2 = combined.s2;
|
||||
s3 = combined.s3;
|
||||
s4 = combined.s4;
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2, S3, S4>>(sourceGroup);
|
||||
}
|
||||
|
||||
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2, S3, S4>(this EcsWorld self)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
{
|
||||
return self.Where<CombinedSubject<S0, S1, S2, S3, S4>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2, S3, S4>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
{
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2, S3, S4>>(sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Where 6
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2, S3, S4, S5>(this EcsWorld self, out S0 s0, out S1 s1, out S2 s2, out S3 s3, out S4 s4, out S5 s5)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
where S5 : EcsSubject
|
||||
{
|
||||
return self.WhereFor(self.Entities, out s0, out s1, out s2, out s3, out s4, out s5);
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2, S3, S4, S5>(this EcsWorld self, EcsReadonlyGroup sourceGroup, out S0 s0, out S1 s1, out S2 s2, out S3 s3, out S4 s4, out S5 s5)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
where S5 : EcsSubject
|
||||
{
|
||||
var combined = self.GetSubject<CombinedSubject<S0, S1, S2, S3, S4, S5>>();
|
||||
s0 = combined.s0;
|
||||
s1 = combined.s1;
|
||||
s2 = combined.s2;
|
||||
s3 = combined.s3;
|
||||
s4 = combined.s4;
|
||||
s5 = combined.s5;
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2, S3, S4, S5>>(sourceGroup);
|
||||
}
|
||||
|
||||
|
||||
public static EcsReadonlyGroup Where<S0, S1, S2, S3, S4, S5>(this EcsWorld self)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
where S5 : EcsSubject
|
||||
{
|
||||
return self.Where<CombinedSubject<S0, S1, S2, S3, S4, S5>>();
|
||||
}
|
||||
public static EcsReadonlyGroup WhereFor<S0, S1, S2, S3, S4, S5>(this EcsWorld self, EcsReadonlyGroup sourceGroup)
|
||||
where S0 : EcsSubject
|
||||
where S1 : EcsSubject
|
||||
where S2 : EcsSubject
|
||||
where S3 : EcsSubject
|
||||
where S4 : EcsSubject
|
||||
where S5 : EcsSubject
|
||||
{
|
||||
return self.WhereFor<CombinedSubject<S0, S1, S2, S3, S4, S5>>(sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -26,10 +26,10 @@ namespace DCFApixels.DragonECS
|
||||
public class DeleteOneFrameComponentSystem<TComponent> : IEcsRunProcess, IEcsInject<EcsWorld>
|
||||
where TComponent : struct, IEcsComponent
|
||||
{
|
||||
private sealed class Subject : EcsSubject
|
||||
private sealed class Aspect : EcsAspect
|
||||
{
|
||||
public EcsPool<TComponent> pool;
|
||||
public Subject(Builder b) => pool = b.Include<TComponent>();
|
||||
public Aspect(Builder b) => pool = b.Include<TComponent>();
|
||||
}
|
||||
List<EcsWorld> _worlds = new List<EcsWorld>();
|
||||
public void Inject(EcsWorld obj) => _worlds.Add(obj);
|
||||
@ -40,8 +40,8 @@ namespace DCFApixels.DragonECS
|
||||
EcsWorld world = _worlds[i];
|
||||
if (world.IsComponentTypeDeclared<TComponent>())
|
||||
{
|
||||
foreach (var e in world.Where(out Subject s))
|
||||
s.pool.Del(e);
|
||||
foreach (var e in world.Where(out Aspect a))
|
||||
a.pool.Del(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ using System.Text;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public abstract class EcsSubject
|
||||
public abstract class EcsAspect
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Always)]
|
||||
internal EcsWorld source;
|
||||
@ -29,41 +29,41 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
#region Builder
|
||||
protected virtual void Init(Builder b) { }
|
||||
public sealed class Builder : EcsSubjectBuilderBase
|
||||
public sealed class Builder : EcsAspectBuilderBase
|
||||
{
|
||||
private EcsWorld _world;
|
||||
private HashSet<int> _inc;
|
||||
private HashSet<int> _exc;
|
||||
private List<CombinedSubject> _subjects;
|
||||
private List<Combined> _combined;
|
||||
|
||||
public EcsWorld World => _world;
|
||||
|
||||
private Builder(EcsWorld world)
|
||||
{
|
||||
_world = world;
|
||||
_subjects = new List<CombinedSubject>();
|
||||
_combined = new List<Combined>();
|
||||
_inc = new HashSet<int>();
|
||||
_exc = new HashSet<int>();
|
||||
}
|
||||
internal static TSubject Build<TSubject>(EcsWorld world) where TSubject : EcsSubject
|
||||
internal static TAspect Build<TAspect>(EcsWorld world) where TAspect : EcsAspect
|
||||
{
|
||||
Builder builder = new Builder(world);
|
||||
Type subjectType = typeof(TSubject);
|
||||
ConstructorInfo constructorInfo = subjectType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(Builder) }, null);
|
||||
EcsSubject newSubject;
|
||||
Type aspectType = typeof(TAspect);
|
||||
ConstructorInfo constructorInfo = aspectType.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[] { typeof(Builder) }, null);
|
||||
EcsAspect newAspect;
|
||||
if (constructorInfo != null)
|
||||
{
|
||||
newSubject = (EcsSubject)constructorInfo.Invoke(new object[] { builder });
|
||||
newAspect = (EcsAspect)constructorInfo.Invoke(new object[] { builder });
|
||||
}
|
||||
else
|
||||
{
|
||||
newSubject = (EcsSubject)Activator.CreateInstance(typeof(TSubject));
|
||||
newSubject.Init(builder);
|
||||
newAspect = (EcsAspect)Activator.CreateInstance(typeof(TAspect));
|
||||
newAspect.Init(builder);
|
||||
}
|
||||
newSubject.source = world;
|
||||
builder.End(out newSubject.mask);
|
||||
newSubject._isInit = true;
|
||||
return (TSubject)newSubject;
|
||||
newAspect.source = world;
|
||||
builder.End(out newAspect.mask);
|
||||
newAspect._isInit = true;
|
||||
return (TAspect)newAspect;
|
||||
}
|
||||
|
||||
#region Include/Exclude/Optional
|
||||
@ -100,10 +100,10 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Combine
|
||||
public TOtherSubject Combine<TOtherSubject>(int order = 0) where TOtherSubject : EcsSubject
|
||||
public TOtherAspect Combine<TOtherAspect>(int order = 0) where TOtherAspect : EcsAspect
|
||||
{
|
||||
var result = _world.GetSubject<TOtherSubject>();
|
||||
_subjects.Add(new CombinedSubject(result, order));
|
||||
var result = _world.GetAspect<TOtherAspect>();
|
||||
_combined.Add(new Combined(result, order));
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
@ -117,14 +117,14 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
HashSet<int> maskInc;
|
||||
HashSet<int> maskExc;
|
||||
if (_subjects.Count > 0)
|
||||
if (_combined.Count > 0)
|
||||
{
|
||||
maskInc = new HashSet<int>();
|
||||
maskExc = new HashSet<int>();
|
||||
_subjects.Sort((a, b) => a.order - b.order);
|
||||
foreach (var item in _subjects)
|
||||
_combined.Sort((a, b) => a.order - b.order);
|
||||
foreach (var item in _combined)
|
||||
{
|
||||
EcsMask submask = item.subject.mask;
|
||||
EcsMask submask = item.aspect.mask;
|
||||
maskInc.ExceptWith(submask._exc);//удаляю конфликтующие ограничения
|
||||
maskExc.ExceptWith(submask._inc);//удаляю конфликтующие ограничения
|
||||
maskInc.UnionWith(submask._inc);
|
||||
@ -169,30 +169,30 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Iterator
|
||||
public EcsSubjectIterator GetIterator()
|
||||
public EcsAspectIterator GetIterator()
|
||||
{
|
||||
return new EcsSubjectIterator(this, source.Entities);
|
||||
return new EcsAspectIterator(this, source.Entities);
|
||||
}
|
||||
public EcsSubjectIterator GetIteratorFor(EcsReadonlyGroup sourceGroup)
|
||||
public EcsAspectIterator GetIteratorFor(EcsReadonlyGroup sourceGroup)
|
||||
{
|
||||
return new EcsSubjectIterator(this, sourceGroup);
|
||||
return new EcsAspectIterator(this, sourceGroup);
|
||||
}
|
||||
#endregion
|
||||
|
||||
private struct CombinedSubject
|
||||
private struct Combined
|
||||
{
|
||||
public EcsSubject subject;
|
||||
public EcsAspect aspect;
|
||||
public int order;
|
||||
public CombinedSubject(EcsSubject subject, int order)
|
||||
public Combined(EcsAspect aspect, int order)
|
||||
{
|
||||
this.subject = subject;
|
||||
this.aspect = aspect;
|
||||
this.order = order;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region BuilderBase
|
||||
public abstract class EcsSubjectBuilderBase
|
||||
public abstract class EcsAspectBuilderBase
|
||||
{
|
||||
public abstract TPool Include<TPool>() where TPool : IEcsPoolImplementation, new();
|
||||
public abstract TPool Exclude<TPool>() where TPool : IEcsPoolImplementation, new();
|
||||
@ -291,15 +291,15 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Iterator
|
||||
public ref struct EcsSubjectIterator
|
||||
public ref struct EcsAspectIterator
|
||||
{
|
||||
public readonly EcsMask mask;
|
||||
private EcsReadonlyGroup _sourceGroup;
|
||||
private Enumerator _enumerator;
|
||||
|
||||
public EcsSubjectIterator(EcsSubject subject, EcsReadonlyGroup sourceGroup)
|
||||
public EcsAspectIterator(EcsAspect aspect, EcsReadonlyGroup sourceGroup)
|
||||
{
|
||||
mask = subject.mask;
|
||||
mask = aspect.mask;
|
||||
_sourceGroup = sourceGroup;
|
||||
_enumerator = default;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29736b3a804309743ad63455ed8fa098
|
||||
guid: 094f935216fa31840883f30e413d7f0c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
@ -312,7 +312,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
|
||||
#region Extensions
|
||||
public static class EcsPipelineExtensions
|
||||
public static partial class EcsPipelineExtensions
|
||||
{
|
||||
public static bool IsNullOrDestroyed(this EcsPipeline self) => self == null || self.IsDestoryed;
|
||||
public static EcsPipeline.Builder Add(this EcsPipeline.Builder self, IEnumerable<IEcsProcess> range, string layerName = null)
|
||||
|
@ -119,7 +119,7 @@ namespace DCFApixels.DragonECS
|
||||
internal IEcsPoolImplementation[] _pools;
|
||||
private EcsNullPool _nullPool = EcsNullPool.instance;
|
||||
|
||||
private EcsSubject[] _subjects;
|
||||
private EcsAspect[] _aspects;
|
||||
private EcsQueryExecutor[] _executors;
|
||||
|
||||
private List<WeakReference<EcsGroup>> _groups = new List<WeakReference<EcsGroup>>();
|
||||
@ -166,7 +166,7 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
_allEntites = GetFreeGroup();
|
||||
|
||||
_subjects = new EcsSubject[128];
|
||||
_aspects = new EcsAspect[128];
|
||||
_executors = new EcsQueryExecutor[128];
|
||||
}
|
||||
public void Destroy()
|
||||
@ -175,7 +175,7 @@ namespace DCFApixels.DragonECS
|
||||
_gens = null;
|
||||
_pools = null;
|
||||
_nullPool = null;
|
||||
_subjects = null;
|
||||
_aspects = null;
|
||||
_executors = null;
|
||||
Worlds[id] = null;
|
||||
ReleaseData(id);
|
||||
@ -212,14 +212,14 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
return (TPool)_pools[index];
|
||||
}
|
||||
public TSubject GetSubject<TSubject>() where TSubject : EcsSubject
|
||||
public TAspect GetAspect<TAspect>() where TAspect : EcsAspect
|
||||
{
|
||||
int index = WorldMetaStorage.GetSubjectID<TSubject>(_worldTypeID);
|
||||
if (index >= _subjects.Length)
|
||||
Array.Resize(ref _subjects, _subjects.Length << 1);
|
||||
if (_subjects[index] == null)
|
||||
_subjects[index] = EcsSubject.Builder.Build<TSubject>(this);
|
||||
return (TSubject)_subjects[index];
|
||||
int index = WorldMetaStorage.GetAspectID<TAspect>(_worldTypeID);
|
||||
if (index >= _aspects.Length)
|
||||
Array.Resize(ref _aspects, _aspects.Length << 1);
|
||||
if (_aspects[index] == null)
|
||||
_aspects[index] = EcsAspect.Builder.Build<TAspect>(this);
|
||||
return (TAspect)_aspects[index];
|
||||
}
|
||||
public TExecutor GetExecutor<TExecutor>() where TExecutor : EcsQueryExecutor, new()
|
||||
{
|
||||
@ -239,25 +239,25 @@ namespace DCFApixels.DragonECS
|
||||
#endregion
|
||||
|
||||
#region Where Query
|
||||
public EcsReadonlyGroup WhereFor<TSubject>(EcsReadonlyGroup sourceGroup, out TSubject subject) where TSubject : EcsSubject
|
||||
public EcsReadonlyGroup WhereFor<TAspect>(EcsReadonlyGroup sourceGroup, out TAspect aspect) where TAspect : EcsAspect
|
||||
{
|
||||
var executor = GetExecutor<EcsWhereExecutor<TSubject>>();
|
||||
subject = executor.Subject;
|
||||
var executor = GetExecutor<EcsWhereExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.ExecuteFor(sourceGroup);
|
||||
}
|
||||
public EcsReadonlyGroup WhereFor<TSubject>(EcsReadonlyGroup sourceGroup) where TSubject : EcsSubject
|
||||
public EcsReadonlyGroup WhereFor<TAspect>(EcsReadonlyGroup sourceGroup) where TAspect : EcsAspect
|
||||
{
|
||||
return GetExecutor<EcsWhereExecutor<TSubject>>().ExecuteFor(sourceGroup);
|
||||
return GetExecutor<EcsWhereExecutor<TAspect>>().ExecuteFor(sourceGroup);
|
||||
}
|
||||
public EcsReadonlyGroup Where<TSubject>(out TSubject subject) where TSubject : EcsSubject
|
||||
public EcsReadonlyGroup Where<TAspect>(out TAspect aspect) where TAspect : EcsAspect
|
||||
{
|
||||
var executor = GetExecutor<EcsWhereExecutor<TSubject>>();
|
||||
subject = executor.Subject;
|
||||
var executor = GetExecutor<EcsWhereExecutor<TAspect>>();
|
||||
aspect = executor.Aspect;
|
||||
return executor.Execute();
|
||||
}
|
||||
public EcsReadonlyGroup Where<TSubject>() where TSubject : EcsSubject
|
||||
public EcsReadonlyGroup Where<TAspect>() where TAspect : EcsAspect
|
||||
{
|
||||
return GetExecutor<EcsWhereExecutor<TSubject>>().Execute();
|
||||
return GetExecutor<EcsWhereExecutor<TAspect>>().Execute();
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public sealed class EcsWhereExecutor<TSubject> : EcsQueryExecutor where TSubject : EcsSubject
|
||||
public sealed class EcsWhereExecutor<TAspect> : EcsQueryExecutor where TAspect : EcsAspect
|
||||
{
|
||||
private TSubject _subject;
|
||||
private TAspect _aspect;
|
||||
private EcsGroup _filteredGroup;
|
||||
|
||||
private long _executeVersion;
|
||||
@ -12,14 +12,14 @@
|
||||
#endif
|
||||
|
||||
#region Properties
|
||||
public TSubject Subject => _subject;
|
||||
public TAspect Aspect => _aspect;
|
||||
internal long ExecuteVersion => _executeVersion;
|
||||
#endregion
|
||||
|
||||
#region OnInitialize/OnDestroy
|
||||
protected sealed override void OnInitialize()
|
||||
{
|
||||
_subject = World.GetSubject<TSubject>();
|
||||
_aspect = World.GetAspect<TAspect>();
|
||||
_filteredGroup = EcsGroup.New(World);
|
||||
}
|
||||
protected sealed override void OnDestroy()
|
||||
@ -29,14 +29,14 @@
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public EcsReadonlyGroup Execute() => ExecuteFor(_subject.World.Entities);
|
||||
public EcsReadonlyGroup Execute() => ExecuteFor(_aspect.World.Entities);
|
||||
public EcsReadonlyGroup ExecuteFor(EcsReadonlyGroup sourceGroup)
|
||||
{
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeWhere.Begin();
|
||||
if (sourceGroup.IsNull) throw new System.ArgumentNullException();//TODO составить текст исключения.
|
||||
#endif
|
||||
_subject.GetIteratorFor(sourceGroup).CopyTo(_filteredGroup);
|
||||
_aspect.GetIteratorFor(sourceGroup).CopyTo(_filteredGroup);
|
||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||
_executeWhere.End();
|
||||
#endif
|
||||
|
@ -202,15 +202,15 @@ namespace DCFApixels.DragonECS
|
||||
return self.GetPool<EcsPool<TComponent>>();
|
||||
}
|
||||
|
||||
public static EcsPool<TComponent> Include<TComponent>(this EcsSubjectBuilderBase self) where TComponent : struct, IEcsComponent
|
||||
public static EcsPool<TComponent> Include<TComponent>(this EcsAspectBuilderBase self) where TComponent : struct, IEcsComponent
|
||||
{
|
||||
return self.Include<EcsPool<TComponent>>();
|
||||
}
|
||||
public static EcsPool<TComponent> Exclude<TComponent>(this EcsSubjectBuilderBase self) where TComponent : struct, IEcsComponent
|
||||
public static EcsPool<TComponent> Exclude<TComponent>(this EcsAspectBuilderBase self) where TComponent : struct, IEcsComponent
|
||||
{
|
||||
return self.Exclude<EcsPool<TComponent>>();
|
||||
}
|
||||
public static EcsPool<TComponent> Optional<TComponent>(this EcsSubjectBuilderBase self) where TComponent : struct, IEcsComponent
|
||||
public static EcsPool<TComponent> Optional<TComponent>(this EcsAspectBuilderBase self) where TComponent : struct, IEcsComponent
|
||||
{
|
||||
return self.Optional<EcsPool<TComponent>>();
|
||||
}
|
||||
|
@ -194,15 +194,15 @@ namespace DCFApixels.DragonECS
|
||||
return self.GetPool<EcsTagPool<TTagComponent>>();
|
||||
}
|
||||
|
||||
public static EcsTagPool<TTagComponent> Include<TTagComponent>(this EcsSubjectBuilderBase self) where TTagComponent : struct, IEcsTagComponent
|
||||
public static EcsTagPool<TTagComponent> Include<TTagComponent>(this EcsAspectBuilderBase self) where TTagComponent : struct, IEcsTagComponent
|
||||
{
|
||||
return self.Include<EcsTagPool<TTagComponent>>();
|
||||
}
|
||||
public static EcsTagPool<TTagComponent> Exclude<TTagComponent>(this EcsSubjectBuilderBase self) where TTagComponent : struct, IEcsTagComponent
|
||||
public static EcsTagPool<TTagComponent> Exclude<TTagComponent>(this EcsAspectBuilderBase self) where TTagComponent : struct, IEcsTagComponent
|
||||
{
|
||||
return self.Exclude<EcsTagPool<TTagComponent>>();
|
||||
}
|
||||
public static EcsTagPool<TTagComponent> Optional<TTagComponent>(this EcsSubjectBuilderBase self) where TTagComponent : struct, IEcsTagComponent
|
||||
public static EcsTagPool<TTagComponent> Optional<TTagComponent>(this EcsAspectBuilderBase self) where TTagComponent : struct, IEcsTagComponent
|
||||
{
|
||||
return self.Optional<EcsTagPool<TTagComponent>>();
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace DCFApixels.DragonECS
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int GetPoolID<T>(int worldID) => Pool<T>.Get(worldID);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int GetSubjectID<T>(int worldID) => Subject<T>.Get(worldID);
|
||||
public static int GetAspectID<T>(int worldID) => Aspect<T>.Get(worldID);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int GetExecutorID<T>(int worldID) => Executor<T>.Get(worldID);
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@ -159,10 +159,10 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
}
|
||||
}
|
||||
private static class Subject<T>
|
||||
private static class Aspect<T>
|
||||
{
|
||||
public static int[] ids;
|
||||
static Subject()
|
||||
static Aspect()
|
||||
{
|
||||
ids = new int[_tokenCount];
|
||||
for (int i = 0; i < ids.Length; i++)
|
||||
@ -174,7 +174,7 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
ref int id = ref ids[token];
|
||||
if (id < 0)
|
||||
id = _metas[token].subjectsCount++;
|
||||
id = _metas[token].aspectsCount++;
|
||||
return id;
|
||||
}
|
||||
private sealed class Resizer : ResizerBase
|
||||
@ -255,7 +255,7 @@ namespace DCFApixels.DragonECS
|
||||
public readonly Type worldType;
|
||||
public int id;
|
||||
public int componentCount;
|
||||
public int subjectsCount;
|
||||
public int aspectsCount;
|
||||
public int executorsCount;
|
||||
public int worldComponentCount;
|
||||
private Type[] _types = new Type[10];
|
||||
|
Loading…
Reference in New Issue
Block a user