-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Question] What is the point of OnEntityUpdated? #44
Comments
Another possible oddity, for |
I think you're right. In this case we can remove
since replacing a component will also call OnEntityRemoved and OnEntityAdded. So it's redundant... I'll remove it from the example. |
OnEntityAddedOrRemoved means it triggers when added OR when removed from the group. Adding a component to an entity might result in the entity being added to a group. This will trigger OnEntityAdded Replacing the component will trigger OnEntityRemoved, OnEntityAdded, OnEntityUpdated Removing the component will trigger OnEntityRemoved Usually reactive systems are interested in changes in the group thus triggering OnEntityAdded. In my experience it's a rare case when you actually want to trigger OnEntityAddedOrRemoved, meaning reacting on any change in the group, e.g AccelerateSystem.cs |
Makes sense. I appreciate the explanation. |
I noticed OnEntityUpdated not function well when i change value in Unity inspector, when value changed, previousComponent is equals to newComponent.Same as OnEntityRemoved, when OnEntityRemoved's event is called, component's value(string type) has already be changed.I don't know if it is an issue. |
I think you're right. The entity inspector just calls entity.ReplaceComponent() without using the componentPool and providing both the previous and the new component like the generated methods do. |
I destroyed my entity than entity's last component removed. Group.OnEntityRemoved(Entity entity); have a good day. |
Hello again,
I have another question about the design of Entitas. What is the intended use of
OnEntityUpdated
? I understand what it is actually can be used for but I am unclear about its intended purpose, given that Entitas use a faux immutable paradigm that fires on Add or Remove on any entity change.Here is the implementation that I am refering to in
Group.cs
:So I get that if you want to cover your bases and have a catch all method for both adds and removes you could use update. But the CreateGameBoardCacheSystem class in the MatchOne example makes me think I may be missing something.
snip:
Maybe this is just a poor usage choice in the example project but it looks like it would be redundant to use
OnEntityUpdated
here as bothOnEntityRemoved
andOnEntityAdded
have already been called at this point.I was using this example as a basis for some of my own systems and I saw this oddity and wanted to make sure I wasn't missing behavior.
The text was updated successfully, but these errors were encountered: