From 873d16a592e3caba3465e877ed6dfb27716d1014 Mon Sep 17 00:00:00 2001 From: gered Date: Sun, 27 Oct 2013 15:08:30 -0400 Subject: [PATCH] convenience helpers for checking the preset type used to create an entity --- src/com/blarg/gdx/entities/Entity.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/com/blarg/gdx/entities/Entity.java b/src/com/blarg/gdx/entities/Entity.java index 3f57b5f..0d77ef8 100644 --- a/src/com/blarg/gdx/entities/Entity.java +++ b/src/com/blarg/gdx/entities/Entity.java @@ -1,5 +1,7 @@ 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. // There IS a better way to do what you were thinking of doing that DOESN'T involve // subclassing Entity! @@ -34,4 +36,16 @@ public final class Entity { public boolean has(Class componentType) { return entityManager.hasComponent(componentType, this); } + + public boolean wasCreatedViaPreset() { + return entityManager.hasComponent(EntityPresetComponent.class, this); + } + + public Class getPresetUsedToCreate() { + EntityPresetComponent presetComponent = entityManager.getComponent(EntityPresetComponent.class, this); + if (presetComponent != null) + return presetComponent.presetType; + else + return null; + } }