/** * Called by the widget body to signal something. * * @param event one of the WidgetBody.SIGNAL_* constants. * @param extra some Object relevant to the event. SIGNAL_TARGET for example should also pass a * Point3f */ protected void handleWidgetEvent(int event, Object extra) { switch (event) { case WidgetBody.TARGET: if (fWidgetOwner.getCurrentWidget() == this) fWidgetOwner.setHUDTarget(this, (Point3f) extra); break; case WidgetBody.DESTROYED: case WidgetBody.TERMINATED: dispose(); break; } }
/** * Get the health of the widget. * * @return float */ public float getHealth() { return fWidgetOwner.getHealth(); }
/** * Get how much energy the player has. * * @return float */ public float getEnergy() { return fWidgetOwner.getEnergy(); }
/** Dispose of the widget. */ public void dispose() { // let the owner know we're going away fWidgetOwner.widgetDisposed(this); fWidgetOwner.removePlayerStateListener(this); }
/** * Add a damage listener to the player. * * @param dl q2java.baseq2.event.DamageListener */ public void addDamageListener(DamageListener dl) { fWidgetOwner.addDamageListener(dl); }
/** * Set the player who made this. * * @param w barryp.widgetwar.WidgetWarrior */ public void setWidgetOwner(WidgetWarrior w) { fWidgetOwner = w; // register to be called if the player disconnects w.addPlayerStateListener(this); }
/** * Set the health of the widget. * * @param f float */ public void setHealth(float f) { fWidgetOwner.setHealth(f); }
/** * Set how much energy the player has. * * @param f float */ public void setEnergy(float f) { fWidgetOwner.setEnergy(f); }
/** * Remove a DamageListener from the player. * * @param dl q2java.baseq2.event.DamageListener */ public void removeDamageListener(DamageListener dl) { fWidgetOwner.removeDamageListener(dl); }