Git Product home page Git Product logo

Comments (7)

JamesMcMahon avatar JamesMcMahon commented on April 28, 2024

Another possible oddity, for Matchers instead of OnEntityUpdate it's OnEntityAddedOrRemoved. If these methods represent the same functionality they should probably have the same method name.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

I think you're right. In this case we can remove

gameBoardElements.OnEntityUpdated += onGameBoardElementUpdated

since replacing a component will also call OnEntityRemoved and OnEntityAdded. So it's redundant... I'll remove it from the example.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

OnEntityAddedOrRemoved means it triggers when added OR when removed from the group.
To recap:

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

from entitas.

JamesMcMahon avatar JamesMcMahon commented on April 28, 2024

Makes sense. I appreciate the explanation.

from entitas.

ifshuaishuai avatar ifshuaishuai commented on April 28, 2024

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.

from entitas.

sschmid avatar sschmid commented on April 28, 2024

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'll work on a fix.
Thanks for letting me know! :)

from entitas.

raveneer avatar raveneer commented on April 28, 2024

I destroyed my entity than entity's last component removed.
after long testing, I understand the mechanism (casting component Arg to removed component)
this is very confusing...
how about adding simple event?
like

Group.OnEntityRemoved(Entity entity);

have a good day.

from entitas.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.