Comments (4)
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.
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.
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.
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)
- Expose `getEntityByName` in `World`? HOT 1
- Fix stats for ecsy-devtools HOT 1
- Adding automatic system execution order using a system graph
- TypeScript: improve ComponentConstructor type
- Improvement: TypeScript tests
- Improvement: Inferring schema types on Components HOT 3
- typescript: TypeError: c.getName is not a function
- creating a new Entity copies over any values from Custom Entity class
- Integrate version.js in the build system
- [QUESTION] Project status/outlook HOT 9
- Is there any way to inject service in System or World? HOT 1
- Assigning default value for Ref type in a schema can cause sideeffects
- Babylon.js ball example seems a bit broken
- Feature request: Support multiple components of the same type per entity.
- Typescript - Mandatory field is not present on the SystemQueries interface
- Class constructor System cannot be invoked without 'new'
- Clear system resource after Removing a system HOT 1
- The removal queries can react pooled entity when removing entity inside system
- is ecsy dead? HOT 10
- TypeScript: Generic type 'Component<C>' requires 1 type argument(s) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ecsy.