filter test

main
cosmonaut 2022-03-07 12:11:51 -08:00
parent 223a6b3147
commit 52119ac63e
4 changed files with 14 additions and 3 deletions

@ -1 +1 @@
Subproject commit 1d7db58d437ce370a31e2ae11a17350cec2089f7 Subproject commit 227aae9a1a6fb0096580b0dd0c4d1787351fbc6a

View File

@ -19,6 +19,10 @@ namespace MoonWorksECSTest
var entity = world.CreateEntity(); var entity = world.CreateEntity();
world.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(200, 200) }); world.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(200, 200) });
world.Set(entity, new StaticPositionComponent());
entity = world.CreateEntity();
world.Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(100, 100) });
} }
protected override void Update(System.TimeSpan dt) protected override void Update(System.TimeSpan dt)

View File

@ -9,7 +9,10 @@ namespace MoonWorksECSTest
public PositionSystem(World world) : base(world) public PositionSystem(World world) : base(world)
{ {
PositionFilter = FilterBuilder.Include<PositionComponent>().Build(); PositionFilter =
FilterBuilder.Include<PositionComponent>()
.Exclude<StaticPositionComponent>()
.Build();
} }
public override void Update(TimeSpan delta) public override void Update(TimeSpan delta)
@ -22,7 +25,7 @@ namespace MoonWorksECSTest
{ {
var positionComponent = Get<PositionComponent>(entity); var positionComponent = Get<PositionComponent>(entity);
Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(positionComponent.Position.X + 10, positionComponent.Position.Y)}); Set(entity, new PositionComponent { Position = new MoonWorks.Math.Vector2(positionComponent.Position.X + 10, positionComponent.Position.Y)});
Console.WriteLine("Position: " + Get<PositionComponent>(entity).Position); Console.WriteLine("Entity: " + entity.ID + ", Position: " + Get<PositionComponent>(entity).Position);
} }
} }
} }

View File

@ -0,0 +1,4 @@
namespace MoonWorksECSTest
{
public struct StaticPositionComponent { }
}