You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On occasion, I find myself writing code like this:
for(_, eid)in(&foo,&entities).join(){ifletSome(bar) = bar.remove(eid){// Do something with bar}}
Or this:
// To reduce allocation costs, working_set is owned by the system structfor(_, eid)in(&bar,&entities).join(){self.working_set.push(eid);}for eid inself.working_set.drain(..){ifletSome(bar) = bar.remove(eid){// ...}}
Both of these rub me the wrong way, especially the second pattern with its redundant loop and owned list of entities. It seems to me that this logic should be available as some kind of modifier on the usual iteration patterns, since the storage already maintains a list of which entities have its associated components.
What I'd like to be able to write is something like the following:
// Remove "bar" from all entities that have itfor bar in bar.drain(){// ...}// Remove "bar" only from entities that also have "foo"for(_, bar)in(&foo, bar.drain()).join(){// Do something with bar}
I brought this up earlier on IRC earlier. @kvark suggested the name "drain" and @Aceeri suggested implementing it as a new Storage type. I'm not convinced the latter makes sense but I'm open to more suggestions.
The text was updated successfully, but these errors were encountered:
On occasion, I find myself writing code like this:
Or this:
Both of these rub me the wrong way, especially the second pattern with its redundant loop and owned list of entities. It seems to me that this logic should be available as some kind of modifier on the usual iteration patterns, since the storage already maintains a list of which entities have its associated components.
What I'd like to be able to write is something like the following:
I brought this up earlier on IRC earlier. @kvark suggested the name "drain" and @Aceeri suggested implementing it as a new Storage type. I'm not convinced the latter makes sense but I'm open to more suggestions.
The text was updated successfully, but these errors were encountered: