Git Product home page Git Product logo

Comments (4)

robertlong avatar robertlong commented on August 27, 2024

Yes, I'd really like addComponent to return the component directly.

I'm not sure what should happen with regard to triggering the changed event. I think I would just handle any logic that deals with the properties in the added event in the same way that I would handle them if I did this addComponent(ComponentA, { some: "props" })

from ecsy.

netpro2k avatar netpro2k commented on August 27, 2024

Mostly indifferent to returning the component or entity, but it doesn't seem right to be modifying a component ref you didn't get from getMutableComponent so I maybe prefer returning the entity to avoid that confusion. I think if we end up moving pooling out of addComponent you end up passing a component instance into addComponent and so this becomes unnecessary anyway.

from ecsy.

robertlong avatar robertlong commented on August 27, 2024

Yeah, just passing the instance is probably fine too. It just depends on how we implement pooling. If addComponent(ComponentA) creates a new instance of ComponentA via its ComponentManager then I'd want addComponent() to return the instance.

If you acquire a new component instance from some other method like world.createComponent(ComponentA) or world.getComponentManager(ComponentA).create() then that would be fine as well. I think this is closely related to how we handle component pooling so maybe we should figure that out first?

from ecsy.

fernandojsg avatar fernandojsg commented on August 27, 2024

Leaving it like this (= returning the entity) in favor to https://github.com/fernandojsg/ecsy/issues/81 to avoid side effects or unwanted use cases as storing a reference to an component or so

from ecsy.

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.