private void respawn(RespawnPlayerEvent event) { final Player player = event.getPlayer(); if (player.isLocalPlayer()) { enqueueHelper.enqueue( new Callable<Void>() { @Override public Void call() throws Exception { setEnabled(true); panShipStatus.setShieldsPercentage(1f); panShipStatus.setHitPointsPercentage(1f); return null; } }); } else { final Node ship = player.getShip(); enqueueHelper.enqueue( new Callable<Void>() { @Override public Void call() throws Exception { HUDMarkerControl markerControl = getMarkerControl(ship, player); markerControl.setEnabled(true); HUDArrowControl arrowControl = getArrowControl(ship, player); arrowControl.setEnabled(true); return null; } }); } for (AbstractShipMarkerControl control : shipControls) { control.onRespawnPlayer(event); } }
private void changeEntityProperty(EntityPropertyChangeEvent event) { Spatial entity = event.getEntity(); final Player player = entity.getUserData(EntityConstants.PLAYER); if (player != null) { String propertyName = event.getPropertyName(); if (player.isLocalPlayer()) { if (propertyName.equals(EntityConstants.SHIELDS)) { long maxShields = entity.getUserData(EntityConstants.MAX_SHIELDS); Long currentShields = (Long) event.getPropertyValue(); final float percentage = currentShields / (float) maxShields; enqueueHelper.enqueue( new Callable<Void>() { @Override public Void call() throws Exception { panShipStatus.setShieldsPercentage(percentage); return null; } }); } else if (propertyName.equals(EntityConstants.HIT_POINTS)) { long maxHitPoints = entity.getUserData(EntityConstants.MAX_HIT_POINTS); Long currentHitPoints = (Long) event.getPropertyValue(); final float percentage = currentHitPoints / (float) maxHitPoints; enqueueHelper.enqueue( new Callable<Void>() { @Override public Void call() throws Exception { panShipStatus.setHitPointsPercentage(percentage); return null; } }); } } else if (propertyName.equals(EntityConstants.HIT_POINTS)) { Long currentHitPoints = (Long) event.getPropertyValue(); if (currentHitPoints <= 0l) { final Node ship = player.getShip(); enqueueHelper.enqueue( new Callable<Void>() { @Override public Void call() throws Exception { HUDMarkerControl markerControl = getMarkerControl(ship, player); markerControl.setEnabled(false); HUDArrowControl arrowControl = getArrowControl(ship, player); arrowControl.setEnabled(false); return null; } }); } } } }