convenience helpers for checking the preset type used to create an entity
This commit is contained in:
parent
cf49f66e85
commit
873d16a592
|
@ -1,5 +1,7 @@
|
||||||
package com.blarg.gdx.entities;
|
package com.blarg.gdx.entities;
|
||||||
|
|
||||||
|
import com.blarg.gdx.entities.systemcomponents.EntityPresetComponent;
|
||||||
|
|
||||||
// Yes, this class SHOULD be marked final. No, you ARE wrong for wanting to subclass this.
|
// Yes, this class SHOULD be marked final. No, you ARE wrong for wanting to subclass this.
|
||||||
// There IS a better way to do what you were thinking of doing that DOESN'T involve
|
// There IS a better way to do what you were thinking of doing that DOESN'T involve
|
||||||
// subclassing Entity!
|
// subclassing Entity!
|
||||||
|
@ -34,4 +36,16 @@ public final class Entity {
|
||||||
public <T extends Component> boolean has(Class<T> componentType) {
|
public <T extends Component> boolean has(Class<T> componentType) {
|
||||||
return entityManager.hasComponent(componentType, this);
|
return entityManager.hasComponent(componentType, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean wasCreatedViaPreset() {
|
||||||
|
return entityManager.hasComponent(EntityPresetComponent.class, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends EntityPreset> getPresetUsedToCreate() {
|
||||||
|
EntityPresetComponent presetComponent = entityManager.getComponent(EntityPresetComponent.class, this);
|
||||||
|
if (presetComponent != null)
|
||||||
|
return presetComponent.presetType;
|
||||||
|
else
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue