Added entity filering support and fixed minor bug

This commit is contained in:
Mergul 2020-06-10 15:35:42 +02:00
parent 5018464a41
commit 8cba2626be
3 changed files with 48 additions and 12 deletions

View file

@ -134,9 +134,21 @@ struct Launcher
vec2 position;
ComponentRef[] add_comps;
ushort[] rem_comps;
ushort[] filter;
bool filterEntity(ref const Entity entity)
{
EntityMeta meta = entity.getMeta();
foreach(id;filter)
{
if(!meta.hasComponent(id))return false;
}
return true;
}
void removeEntity(IteratorSystem.EntitiesData data)
{
if(!filterEntity(data.entity[0]))return;
foreach(i;0..data.length)
{
vec2 rel_vec = data.location[i] - position;
@ -147,6 +159,7 @@ struct Launcher
void addComponent(IteratorSystem.EntitiesData data)
{
if(!filterEntity(data.entity[0]))return;
foreach(i;0..data.length)
{
vec2 rel_vec = data.location[i] - position;
@ -157,6 +170,7 @@ struct Launcher
void overrideComponent(IteratorSystem.EntitiesData data)
{
if(!filterEntity(data.entity[0]))return;
foreach(i;0..data.length)
{
vec2 rel_vec = data.location[i] - position;
@ -171,6 +185,7 @@ struct Launcher
void removeComponent(IteratorSystem.EntitiesData data)
{
if(!filterEntity(data.entity[0]))return;
foreach(i;0..data.length)
{
vec2 rel_vec = data.location[i] - position;
@ -185,6 +200,7 @@ struct Launcher
Iterator iterator;
iterator.size2 = size2;
iterator.position = position;
iterator.filter = gui_manager.filter_list[];
switch(used_tool)
{