mirror of
https://github.com/tribes2/engine.git
synced 2026-04-29 16:25:27 +00:00
t2 engine svn checkout
This commit is contained in:
commit
ff569bd2ae
988 changed files with 394180 additions and 0 deletions
67
hud/hudEnergyCtrl.cc
Normal file
67
hud/hudEnergyCtrl.cc
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// V12 Engine
|
||||
//
|
||||
// Copyright (c) 2001 GarageGames.Com
|
||||
// Portions Copyright (c) 2001 by Sierra Online, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "hudBarBaseCtrl.h"
|
||||
#include "game/gameConnection.h"
|
||||
#include "game/shapeBase.h"
|
||||
|
||||
//===========================================================================
|
||||
// CLASS: HudEnergyCtrl
|
||||
//
|
||||
// This object displays the players energy level in a bar format
|
||||
//===========================================================================
|
||||
|
||||
class HudEnergyCtrl : public HudBarBaseCtrl {
|
||||
private:
|
||||
typedef HudBarBaseCtrl Parent;
|
||||
|
||||
public:
|
||||
|
||||
F32 getValue();
|
||||
|
||||
DECLARE_CONOBJECT( HudEnergyCtrl );
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
// HudEnergyCtrl Implementation
|
||||
//===========================================================================
|
||||
IMPLEMENT_CONOBJECT( HudEnergyCtrl );
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// getValue
|
||||
//
|
||||
// This method is overridden from hudBarBaseCtrl, it returns the
|
||||
// energy level of the player as a percentile
|
||||
//
|
||||
// Return: Energy level of the player as a percentile
|
||||
//------------------------------------------------------------------
|
||||
F32 HudEnergyCtrl::getValue() {
|
||||
GameConnection *con = GameConnection::getServerConnection();
|
||||
|
||||
if( !con )
|
||||
return(0.f);
|
||||
|
||||
ShapeBase *obj = con->getControlObject();
|
||||
if( !obj )
|
||||
return(0.f);
|
||||
|
||||
if( mDisplayMounted ) {
|
||||
ShapeBase *mount = obj->getObjectMount();
|
||||
|
||||
while( mount && mount->isMounted() )
|
||||
mount = mount->getObjectMount();
|
||||
|
||||
if( mount )
|
||||
return( mClampF( mount->getEnergyValue(), 0.f, 1.f ) );
|
||||
else
|
||||
return( 0.f );
|
||||
}
|
||||
else
|
||||
return mClampF( obj->getEnergyValue(), 0.f, 1.f );
|
||||
}
|
||||
|
||||
// hudEnergy.cc
|
||||
Loading…
Add table
Add a link
Reference in a new issue