-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional excluded list of Components for Node #8
Conversation
You can set up excluded list for Node creating public static array named without. Entities with excluded components are not added to the NodeList. Adding/removing excluded component causes entity to be removed/added from the NodeList.
@richardlord this is great feature, I'm already using it. Thx Wrobel! |
Sorry to take so long to get back to you. I'm struggling to imagine when this is useful, can you give an example of when it would be useful. |
I'm working on a game where entities movement are managed by a couple of systems, but only one system at the same time. the tasks of the entities are prioritised, and the managment of tasks of entity is done in node layer, based on what component plane has and has not. Excluded components in node helped me to remove all "activation" components and system to manage this components. example is very hard to explain because this feature is useful if you have many systems working on the same components but with some exceptions. Let me try to show you a simple example. My entity is a plane, an user can manualy fly the plane by drawing a path, exept a plane that is driven by autopilot to a target. In Node PathNode we have PathComponent and in AutoPilotNode we have AutoPilotComponent. So, my plane can have a target and path at the same time, i do not have to remove AutoPilot when adding a Path, and when path is done my plane will fly to target... there is no managment between node/system and there is no Activation/Type components also. Managment is moved to Node Layer, it's clear and simple. this is very simple example, in my game there is about 10 different behaviors of planes movement in 6 different systems. With other solutions, complication of type/activation components, and some manager system to react on nodeAdded and nodeRemoved to manage those behaviors between systems ware colossal and hard to maintain. |
I can also think about this feature like anti-flags. You add type components like Player or Enemy to filter nodes. I'd think of an example of Enemy with Invulnerable anti-flag that makes Enemies not collide with bullets (EnemyCollisionNode) |
Removed system still had values of next and previous so when adding that system again it could have wrong linked list nodes causing infinite loop. Fixed the problem just by nulling next and previous values when removing system.
I just added fix for infinite loop problem in SystemsList. All info in commit message above. I couldn't have created separate pull request so don't worry to just copy paste fix if you don't want to add optional excluded components in Node to Ash |
The next and previous cannot be set to null when removing a system because this breaks list iteration if you remove the current node. I have created an alternative fix and added it, along with your test, to the master branch. Thank you. |
I have conflicting feelings about allowing excluded lists in nodes. It is just one of the more sophisticated entity selection requests I've received and I've so far rejected them. However, I am open to changing my mind and have created a separate issue to discuss the broader question. Please would you take a look and give me your thoughts - #10 |
I thought all test pass then its fine - so maybe there should be a test covering the case of removing system while iterating. I totally understand pureness of the core so I think we can close this pull request. And let's talk about the option for extending the framework :) Thanks |
You can set up excluded list for Node creating public static array named without. Entities with excluded components are not added to the NodeList. Adding/removing excluded component causes entity to be removed/added from the NodeList.
Unfortunately feature when excluded component is removed from entity nothing listens to componentRemoved signal. So I had to add that listener for all entities. I added some optimisation when there's no families with excluded components then that listener is not added.
I started developing that feature from writing tests so it passes all three tests I added. There might be more cases for this feature and I'll add them when there will be any problems.