use of de.gurkenlabs.litiengine.entities.ICollisionEntity in project litiengine by gurkenlabs.
the class Environment method unload.
/**
* Unload the specified entity by performing the following steps:
* <ol>
* <li>remove entities from physics engine</li>
* <li>unregister units from update</li>
* <li>unregister ai controller from update</li>
* <li>unregister animation controller from update</li>
* <li>unregister movement controller from update</li>
* </ol>
*
* @param entity
*/
private void unload(final IEntity entity) {
// 1. remove from physics engine
if (entity instanceof CollisionBox) {
final CollisionBox coll = (CollisionBox) entity;
if (coll.isObstacle()) {
Game.getPhysicsEngine().remove(coll.getBoundingBox());
} else {
Game.getPhysicsEngine().remove(coll);
}
} else if (entity instanceof ICollisionEntity) {
final ICollisionEntity coll = (ICollisionEntity) entity;
Game.getPhysicsEngine().remove(coll);
}
// 2. unregister from update
if (entity instanceof IUpdateable) {
Game.getLoop().detach((IUpdateable) entity);
}
// 3. unregister ai controller from update
final IEntityController<? extends IEntity> controller = Game.getEntityControllerManager().getAIController(entity);
if (controller != null) {
Game.getLoop().detach(controller);
}
// 4. unregister animation controller from update
final IAnimationController animation = Game.getEntityControllerManager().getAnimationController(entity);
if (animation != null) {
Game.getLoop().detach(animation);
}
// 5. unregister movement controller from update
if (entity instanceof IMobileEntity) {
final IMovementController<? extends IMobileEntity> movementController = Game.getEntityControllerManager().getMovementController((IMobileEntity) entity);
if (movementController != null) {
Game.getLoop().detach(movementController);
}
}
if (entity instanceof Emitter) {
Emitter em = (Emitter) entity;
em.deactivate();
}
}
use of de.gurkenlabs.litiengine.entities.ICollisionEntity in project litiengine by gurkenlabs.
the class DebugRenderer method renderEntityDebugInfo.
public static void renderEntityDebugInfo(final Graphics2D g, final IEntity entity) {
if (!Game.getConfiguration().debug().isDebugEnabled()) {
return;
}
if (Game.getConfiguration().debug().renderEntityNames()) {
drawMapId(g, entity);
}
if (Game.getConfiguration().debug().renderHitBoxes() && entity instanceof ICombatEntity) {
g.setColor(Color.RED);
Game.getRenderEngine().renderOutline(g, ((ICombatEntity) entity).getHitBox());
}
if (Game.getConfiguration().debug().renderBoundingBoxes()) {
g.setColor(Color.RED);
Game.getRenderEngine().renderOutline(g, entity.getBoundingBox());
}
if (Game.getConfiguration().debug().renderCollisionBoxes() && entity instanceof ICollisionEntity) {
final ICollisionEntity collisionEntity = (ICollisionEntity) entity;
g.setColor(collisionEntity.hasCollision() ? Color.RED : Color.ORANGE);
Game.getRenderEngine().renderOutline(g, collisionEntity.getCollisionBox());
}
}
Aggregations