Advertisement
VirtualMaestro

Code Snippet

Oct 26th, 2019
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using Leopotam.Ecs;
  2.  
  3. namespace TestLeoEcs.tests
  4. {
  5.     public class TestUpdateFilters
  6.     {
  7.         private EcsWorld _world;
  8.         private EcsSystems _systems;
  9.        
  10.         public TestUpdateFilters()
  11.         {
  12.             _world = new EcsWorld();
  13.             _systems = new EcsSystems(_world);
  14.            
  15.             _systems.Add(new RemoveEntitySystem());
  16.  
  17.             _systems.ProcessInjects();
  18.             _systems.Init();
  19.            
  20.             _systems.Run();
  21.             _world.EndFrame();
  22.         }
  23.     }
  24.    
  25.     public class RemoveEntitySystem : IEcsInitSystem, IEcsRunSystem
  26.     {
  27.         EcsWorld _world;
  28.  
  29.         private EcsFilter<IncludeComponent> _incFilter;
  30.         private EcsFilter<IncludeComponent>.Exclude<ExcludeComponent> _incExFilter;
  31.        
  32.         public void Init()
  33.         {
  34.             _world.NewEntityWith<IncludeComponent>(out var includeComponent1);
  35.             _world.NewEntityWith<IncludeComponent, ExcludeComponent>(out var includeComponent2, out var excludeComponent);
  36.         }
  37.        
  38.         public void Run()
  39.         {
  40.             ref var entity = ref _incFilter.Entities[0];
  41.             entity.Destroy();
  42.         }
  43.     }
  44.    
  45.     public class IncludeComponent
  46.     {}
  47.    
  48.     public class ExcludeComponent : IEcsOneFrame, IEcsIgnoreInFilter
  49.     {}
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement