beginning query syntax system
							parent
							
								
									2abffd1cf9
								
							
						
					
					
						commit
						728109bfc6
					
				|  | @ -561,7 +561,7 @@ namespace Encompass | |||
|         /// <param name="easeInTime">The time that will elapse before time is fully dilated, in real time.</param> | ||||
|         /// <param name="activeTime">The length of real time that time will be fully dilated.</param> | ||||
|         /// <param name="easeOutTime">The time that will elapse before time is fully undilated.</param> | ||||
|         public void ActivateTimeDilation(double factor, double easeInTime, double activeTime, double easeOutTime) | ||||
|         protected void ActivateTimeDilation(double factor, double easeInTime, double activeTime, double easeOutTime) | ||||
|         { | ||||
|             timeManager.ActivateTimeDilation(factor, easeInTime, activeTime, easeOutTime); | ||||
|         } | ||||
|  | @ -576,7 +576,7 @@ namespace Encompass | |||
|         /// <param name="easeInFunction">An easing function for the easing in of time dilation.</param> | ||||
|         /// <param name="activeTime">The length of real time that time will be fully dilated.</param> | ||||
|         /// <param name="easeOutTime">The time that will elapse before time is fully undilated.</param> | ||||
|         public void ActivateTimeDilation(double factor, double easeInTime, System.Func<double, double, double, double, double> easeInFunction, double activeTime, double easeOutTime) | ||||
|         protected void ActivateTimeDilation(double factor, double easeInTime, System.Func<double, double, double, double, double> easeInFunction, double activeTime, double easeOutTime) | ||||
|         { | ||||
|             timeManager.ActivateTimeDilation(factor, easeInTime, easeInFunction, activeTime, easeOutTime); | ||||
|         } | ||||
|  | @ -591,7 +591,7 @@ namespace Encompass | |||
|         /// <param name="activeTime">The length of real time that time will be fully dilated.</param> | ||||
|         /// <param name="easeOutTime">The time that will elapse before time is fully undilated.</param> | ||||
|         /// <param name="easeOutFunction">An easing function for the easing out of time dilation.</param> | ||||
|         public void ActivateTimeDilation(double factor, double easeInTime, double activeTime, double easeOutTime, System.Func<double, double, double, double, double> easeOutFunction) | ||||
|         protected void ActivateTimeDilation(double factor, double easeInTime, double activeTime, double easeOutTime, System.Func<double, double, double, double, double> easeOutFunction) | ||||
|         { | ||||
|             timeManager.ActivateTimeDilation(factor, easeInTime, activeTime, easeOutTime, easeOutFunction); | ||||
|         } | ||||
|  | @ -607,14 +607,14 @@ namespace Encompass | |||
|         /// <param name="activeTime">The length of real time that time will be fully dilated.</param> | ||||
|         /// <param name="easeOutTime">The time that will elapse before time is fully undilated.</param> | ||||
|         /// <param name="easeOutFunction">An easing function for the easing out of time dilation.</param> | ||||
|         public void ActivateTimeDilation(double factor, double easeInTime, System.Func<double, double, double, double, double> easeInFunction, double activeTime, double easeOutTime, System.Func<double, double, double, double, double> easeOutFunction) | ||||
|         protected void ActivateTimeDilation(double factor, double easeInTime, System.Func<double, double, double, double, double> easeInFunction, double activeTime, double easeOutTime, System.Func<double, double, double, double, double> easeOutFunction) | ||||
|         { | ||||
|             timeManager.ActivateTimeDilation(factor, easeInTime, easeInFunction, activeTime, easeOutTime, easeOutFunction); | ||||
|         } | ||||
| 
 | ||||
|         public IEnumerable<Entity> EntitiesWithComponents(IEnumerable<Type> types) | ||||
|         protected EntitySetQuery QueryEntities() | ||||
|         { | ||||
|             return componentManager.EntitiesWithComponents(types); | ||||
|             return new EntitySetQuery(componentManager); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -0,0 +1,48 @@ | |||
| using System; | ||||
| using System.Collections; | ||||
| using System.Collections.Generic; | ||||
| using System.Collections.Immutable; | ||||
| 
 | ||||
| namespace Encompass | ||||
| { | ||||
|     public struct EntitySetQuery : IEnumerable<Entity> | ||||
|     { | ||||
|         private EntitySetQuery(ComponentManager componentManager, ImmutableArray<Type> includes, ImmutableArray<Type> excludes) | ||||
|         { | ||||
|             ComponentManager = componentManager; | ||||
|             Includes = includes; | ||||
|             Excludes = excludes; | ||||
|         } | ||||
| 
 | ||||
|         internal EntitySetQuery(ComponentManager componentManager) | ||||
|         { | ||||
|             ComponentManager = componentManager; | ||||
|             Includes = ImmutableArray.Create<Type>(); | ||||
|             Excludes = ImmutableArray.Create<Type>(); | ||||
|         } | ||||
| 
 | ||||
|         private ComponentManager ComponentManager { get; } | ||||
|         private ImmutableArray<Type> Includes { get; } | ||||
|         private ImmutableArray<Type> Excludes { get; } | ||||
| 
 | ||||
|         public EntitySetQuery With<TComponent>() where TComponent : struct, IComponent | ||||
|         { | ||||
|             return new EntitySetQuery(ComponentManager, Includes.Add(typeof(TComponent)), Excludes); | ||||
|         } | ||||
| 
 | ||||
|         public EntitySetQuery Without<TComponent>() where TComponent : struct, IComponent | ||||
|         { | ||||
|             return new EntitySetQuery(ComponentManager, Includes, Excludes.Add(typeof(TComponent))); | ||||
|         } | ||||
| 
 | ||||
|         public IEnumerator<Entity> GetEnumerator() | ||||
|         { | ||||
|             return ComponentManager.EntitiesWithComponents(Includes).GetEnumerator(); | ||||
|         } | ||||
| 
 | ||||
|         IEnumerator IEnumerable.GetEnumerator() | ||||
|         { | ||||
|             return GetEnumerator(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | @ -1,4 +1,4 @@ | |||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
| <Project Sdk="Microsoft.NET.Sdk"> | ||||
|   <PropertyGroup> | ||||
|     <TargetFramework>netstandard2.0</TargetFramework> | ||||
|     <RootNamespace>Encompass</RootNamespace> | ||||
|  | @ -9,7 +9,7 @@ | |||
|     <Company>Moonside Games</Company> | ||||
|     <Product>Encompass ECS</Product> | ||||
|     <PackageProjectUrl>https://github.com/encompass-ecs</PackageProjectUrl> | ||||
|     <PackageLicenseUrl /> | ||||
|     <PackageLicenseUrl/> | ||||
|     <Copyright>Evan Hemsley 2019</Copyright> | ||||
|     <Description>Encompass is an engine-agnostic Hyper ECS framework to help you code games, or other kinds of simulations.</Description> | ||||
|     <GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||||
|  | @ -19,10 +19,11 @@ | |||
|   <ItemGroup> | ||||
|     <None Include="..\LICENSE"> | ||||
|       <Pack>True</Pack> | ||||
|       <PackagePath /> | ||||
|       <PackagePath/> | ||||
|     </None> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="MoonTools.Core.Graph" Version="1.0.0" /> | ||||
|     <PackageReference Include="MoonTools.Core.Graph" Version="1.0.0"/> | ||||
|     <PackageReference Include="System.Collections.Immutable" Version="1.7.0"/> | ||||
|   </ItemGroup> | ||||
| </Project> | ||||
| </Project> | ||||
|  | @ -1096,7 +1096,7 @@ namespace Tests | |||
|         { | ||||
|             public override void Update(double dt) | ||||
|             { | ||||
|                 queriedEntities = EntitiesWithComponents(new Type[] { typeof(MockComponent), typeof(MockComponentB) }).ToArray(); | ||||
|                 queriedEntities = QueryEntities().With<MockComponent>().With<MockComponentB>().ToArray(); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue