Hey, everyone.
I recently tried out Artemis a bit, and boy has it changed since I last used it.
Basically, I’m having trouble initializing a component after creating an entity. I’m doing this:
Archetype archetype = new ArchetypeBuilder().add(Position.class).build(world);
int entity = world.create(archetype);
At this point, I want to initialize the Position component to the initial position of the entity. However, this seems to be impossible to do cleanly.
- ComponentMapper doesn’t work since I’m not inside a System.
- If I use an Entity object, I can use entity.getComponent(Position.class), but that function delegates to a protected function in ComponentManager which I can’t call directly with an int entity.
Literally the only way I’ve managed to get the Position component is to use this monstrosity:
Position p = (Position) world.getComponentManager().getComponentsFor(entity, new Bag<>()).get(0);
Am I approaching this wrong? Am I supposed to do this in some other way? Am I missing something obvious?