}
private void addProximityListener(boolean live) {
// Fetch the proximity component, we will need this below. If it does
// not exist (it should), then log an error
ProximityComponentMO component = cellRef.get().getComponent(ProximityComponentMO.class);
if (component == null) {
logger.warning("The Cone of Silence Component does not have a " +
"Proximity Component for Cell ID " + cellID);
return;
}
if (proximityListenerRef != null) {
ConeOfSilenceProximityListener proximityListener = proximityListenerRef.get();
proximityListener.remove();
component.removeProximityListener(proximityListener);
proximityListenerRef = null;
//System.out.println("Removing proximity listener...");
}
// If we are making this component live, then add a listener to the proximity component.
if (live == true) {
BoundingVolume[] boundingVolume = new BoundingVolume[1];
//System.out.println("BOUNDS TYPE " + boundsType);
if (boundsType.equals(COSBoundsType.CELL_BOUNDS)) {
boundingVolume[0] = cellRef.get().getLocalBounds();
logger.warning("COS Using cell local bounds: " + boundingVolume[0]);
System.out.println("COS Using cell local bounds: " + boundingVolume[0]);
} else if (boundsType.equals(COSBoundsType.BOX)) {
boundingVolume[0] = new BoundingBox(new Vector3f(), bounds.getX(),
bounds.getY(), bounds.getZ());
logger.warning("COS Using specified BOX: " + boundingVolume[0]);
System.out.println("COS Using specified BOX: " + boundingVolume[0]);
} else {
boundingVolume[0] = new BoundingSphere(bounds.getX(), new Vector3f());
logger.warning("COS Using specified radius: " + boundingVolume[0]);
System.out.println("COS Using specified radius: " + boundingVolume[0]);
}
ConeOfSilenceProximityListener proximityListener =
new ConeOfSilenceProximityListener(cellRef.get(), name, outsideAudioVolume);
proximityListenerRef = AppContext.getDataManager().createReference(proximityListener);
component.addProximityListener(proximityListener, boundingVolume);
}
}