-
Notifications
You must be signed in to change notification settings - Fork 20
Extended Component Mappers
Daan van Yperen edited this page Oct 2, 2015
·
6 revisions
Out of date, some of this functionality has been merged with odb-core
Easily create and remove components, helps you write shorter code.
if ( !mPhysics.has(e) ) { e.edit().add(Physics.class); }
Physics p = mPhysics.get(e);
becomes
Physics p = mPhysics.create(e);
Identical to ComponentMapper, but adds:
-
#create(entity)
Creates component, or returns existing. -
#remove(entity)
Removes component, does nothing when already removed. -
#getSafe(entity,passthrough)
Returns component, or passthrough if missing. -
#set(entity, boolean)
Toggle components, useful for tag components.
Uses Transmuters behind the scenes.
WorldConfiguration myConfig = new WorldConfigurationBuilder()
.with(new ExtendedComponentMapperPlugin())
.build();
new World (myConfig);
@Wire
public class ExampleSystem extends EntityProcessingSystem {
protected M<Pos> mPos;
protected M<Color> mColor;
}