Skip to content
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

Rework flat entity model to entity hierarchy #14

Closed
mrtrizer opened this issue Jan 11, 2017 · 0 comments
Closed

Rework flat entity model to entity hierarchy #14

mrtrizer opened this issue Jan 11, 2017 · 0 comments

Comments

@mrtrizer
Copy link
Owner

mrtrizer commented Jan 11, 2017

This should solve problems with object transport. Entities become untied of EntityManager.
When entity is added to EntityManager hierarchy and get access to ManagerList, we should send a Connected event to connected subtree. Optionally we can also pass managerList in this event. When subtree is disconnected, all children get Disconnected event. Presenter components use this events to create/remove renders.

SomeComponent::SomeComponent() {
   on([this](Connected e) {
       ...
   });
   on([this](Disconnected e) {
   });
   on([this](Update e) {
   });
}

(I realised that such code can't work, because all components of entity will get this events at same time. Thus I can't call Connected event on component creation.)

Also this code can be placed in Component base class and usual virtual connected()/disconnected()/init() methods could be called.
Finally, this approach can help us to simplify entity-component tree.

To provide necessary methods for entity manipulation, we can create common parent class for EntityManager and Entity.

About memory safety. We can create temporary entity for component in Component constructor. So we can use entity() method in component constructor without crashes. This temporary entity will be removed when component is added to another entity. If programmer added some components to temprorary entity they also will be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant