Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

world.createComponent to create components without adding them to an entity #81

Closed
fernandojsg opened this issue Sep 17, 2019 · 2 comments

Comments

@fernandojsg
Copy link
Member

Currently is possible to add a component by passing the component class and an object to replace the default values:

entity.addComponent(ComponentA);
entity.addComponent(ComponentB, {value: 23, other: 'test'});

It would be interesting to be able to request a component without adding it to an entity automatically:

var component = world.createComponent(ComponentB);
component.value = 23;
component.other = 'test';

entity.addComponent(component);

// You could still do this the "old" way
entity.addComponent(ComponentA); // Just some sugar to detect the component
@wingyplus
Copy link
Contributor

What’s benefit from this approach?

@fernandojsg
Copy link
Member Author

This is based on a concept of attaching / detaching entities or components from the world, so they are being created but not being added to any query.
But this is already outdated as we were thinking about other ways to provide that functionality that will get added soon to the repo. Closing it

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

No branches or pull requests

2 participants