public void setStatus(CellStatus status,boolean increasing) {
this.status = status;
switch(status) {
case ACTIVE :
if (increasing && cell!=null) {
Entity parentEntity= findParentEntity(cell.getParent());
Entity thisEntity = getEntity();
if (thisEntity==null) {
logger.severe("Got null entity for "+this.getClass().getName());
return;
}
thisEntity.addComponent(CellRefComponent.class, new CellRefComponent(cell));
if (parentEntity!=null) {
parentEntity.addEntity(thisEntity);
} else {
ClientContextJME.getWorldManager().addEntity(thisEntity);
}
// Figure out the correct parent entity for this cells entity.
if (parentEntity!=null && thisEntity!=null) {
RenderComponent parentRendComp = (RenderComponent) parentEntity.getComponent(RenderComponent.class);
RenderComponent thisRendComp = (RenderComponent)thisEntity.getComponent(RenderComponent.class);
if (parentRendComp!=null && parentRendComp.getSceneRoot()!=null && thisRendComp!=null) {
thisRendComp.setAttachPoint(parentRendComp.getSceneRoot());
}
}
// enable the collision listener
collisionListener.enable();
} else {
logger.info("No Entity for Cell "+cell.getClass().getName());
}
break;
case INACTIVE :
if (!increasing) {
collisionListener.disable();
try {
Entity child = getEntity();
Entity parent = child.getParent();
if (parent!=null)
parent.removeEntity(child);
else
ClientContextJME.getWorldManager().removeEntity(child);
cleanupSceneGraph(child);
} catch(Exception e) {
System.err.println("NPE in "+this);