diff --git a/src/Bevy.cs b/src/Bevy.cs index 36a5c0f..23bee6f 100644 --- a/src/Bevy.cs +++ b/src/Bevy.cs @@ -389,35 +389,12 @@ internal Query(Query query) : base(query) { } } } -public class Query : Query, IIntoSystemParam +public class Query : SystemParam, IIntoSystemParam where TQueryData : struct, IData, IQueryIterator, allows ref struct where TQueryFilter : struct, IFilter, allows ref struct -{ - internal Query(Query query) : base(query) { } - - public new static ISystemParam Generate(World arg) - { - if (arg.Entity>>().Has>>()) - return arg.Entity>>().Get>>().Value; - - var builder = arg.QueryBuilder(); - TQueryData.Build(builder); - TQueryFilter.Build(builder); - var q = new Query(builder.Build()); - arg.Entity>>().Set(new Placeholder>() { Value = q }); - return q; - } -} - -public class Query : SystemParam, IIntoSystemParam - where TQueryData : struct, IData, IQueryIterator, allows ref struct - where TQueryFilter : struct, IFilter, allows ref struct - where TQueryDetection : struct, IDetection, allows ref struct { private readonly Query _query; - private static readonly Func _fn = TQueryDetection.Detection; - internal Query(Query query) { _query = query; @@ -425,15 +402,14 @@ internal Query(Query query) public static ISystemParam Generate(World arg) { - if (arg.Entity>>().Has>>()) - return arg.Entity>>().Get>>().Value; + if (arg.Entity>>().Has>>()) + return arg.Entity>>().Get>>().Value; var builder = arg.QueryBuilder(); TQueryData.Build(builder); TQueryFilter.Build(builder); - TQueryDetection.Build(builder); - var q = new Query(builder.Build()); - arg.Entity>>().Set(new Placeholder>() { Value = q }); + var q = new Query(builder.Build()); + arg.Entity>>().Set(new Placeholder>() { Value = q }); return q; } @@ -585,7 +561,7 @@ public interface IQueryIterator bool MoveNext(); } -public interface IData : ITermCreator where TData : struct, allows ref struct +public interface IData : ITermCreator, IQueryIterator where TData : struct, allows ref struct { public static abstract TData CreateIterator(QueryIterator iterator); } @@ -594,7 +570,6 @@ public interface IFilter : ITermCreator { } public interface IDetection : ITermCreator { - internal static abstract bool Detection(uint[,] ticks, int column, int row, uint value); } public interface INestedFilter @@ -616,7 +591,7 @@ public static bool Build(QueryBuilder builder) } } -public ref struct Empty : IData, IQueryIterator, IFilter, IDetection +public ref struct Empty : IData, IFilter { private QueryIterator _iterator; @@ -627,22 +602,12 @@ public static void Build(QueryBuilder builder) } - public static bool Detection(uint[,] ticks, int column, int row, uint value) - { - return true; - } - public static Empty CreateIterator(QueryIterator iterator) { return new Empty(iterator); } - [UnscopedRef] - public ref Empty Current - { - - get => ref this; - } + [UnscopedRef] public ref Empty Current => ref this; public readonly void Deconstruct(out ReadOnlySpan entities, out int count) { @@ -712,99 +677,6 @@ public void BuildAsParam(QueryBuilder builder) } } -public readonly struct Changed : IDetection - where T : struct -{ - public static void Build(QueryBuilder builder) - { - - } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool Detection(uint[,] ticks, int column, int row, uint value) - { - return value == 0 || ticks[column, row] != value; - } -} - - -///// -///// Used in query filters to find entities with any of the corrisponding components/tag. -///// -///// -//public readonly struct AtLeast : ITuple, IFilter where T : struct, ITuple -//{ -// static readonly ITuple _value = default(T)!; - -// public object? this[int index] => _value[index]; - -// public int Length => _value.Length; -// public static void Build(QueryBuilder builder) -// { -// throw new NotImplementedException(); -// } -//} - -///// -///// Used in query filters to find entities with exactly the corrisponding components/tag. -///// -///// -//public readonly struct Exactly : ITuple, IFilter where T : struct, ITuple -//{ -// static readonly ITuple _value = default(T)!; - -// public object? this[int index] => _value[index]; - -// public int Length => _value.Length; -// public static void Build(QueryBuilder builder) -// { -// throw new NotImplementedException(); -// } -//} - -///// -///// Used in query filters to find entities with none the corrisponding components/tag. -///// -///// -//public readonly struct None : ITuple, IFilter where T : struct, ITuple -//{ -// static readonly ITuple _value = default(T)!; - -// public object? this[int index] => _value[index]; - -// public int Length => _value.Length; -// public static void Build(QueryBuilder builder) -// { -// throw new NotImplementedException(); -// } -//} - -///// -///// Used in query filters to accomplish the 'or' logic. -///// -///// -//public readonly struct Or, IFilter, INestedFilter -// where TFirst : struct, IComponent -// where TSecond : struct, IComponent -//{ -// public static void Build(QueryBuilder builder) -// { -// //builder.Optional(); -// //builder.Optional(); - -// var ok0 = FilterBuilder.Build(builder); -// var ok1 = FilterBuilder.Build(builder); - -// builder.AtLeast(builder.World.Component().ID, builder.World.Component().ID); -// } - -// public void BuildAsParam(QueryBuilder builder) -// { -// Build(builder); -// } -//} - - public partial struct Parent { } public partial interface IChildrenComponent { }