mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-16 00:54:54 +00:00
Allow the gui to render for both vehicles and vehicle-mounted players.
This commit is contained in:
parent
57dfeb829a
commit
213b7020a3
1 changed files with 13 additions and 6 deletions
|
|
@ -147,22 +147,29 @@ void GuiSpeedometerHud::initPersistFields()
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
Gui onRender method.
|
Gui onRender method.
|
||||||
Renders a health bar with filled background and border.
|
Renders an analog speedometer needle over a specified bitmap background.
|
||||||
*/
|
*/
|
||||||
void GuiSpeedometerHud::onRender(Point2I offset, const RectI &updateRect)
|
void GuiSpeedometerHud::onRender(Point2I offset, const RectI &updateRect)
|
||||||
{
|
{
|
||||||
// Must have a connection and player control object
|
// Must have a connection
|
||||||
GameConnection* conn = GameConnection::getConnectionToServer();
|
GameConnection* conn = GameConnection::getConnectionToServer();
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return;
|
return;
|
||||||
Vehicle* control = dynamic_cast<Vehicle*>(conn->getControlObject());
|
|
||||||
if (!control)
|
// Requires either a vehicle control object or a vehicle-mounted player
|
||||||
return;
|
Vehicle* vehicle = dynamic_cast<Vehicle*>(conn->getControlObject());
|
||||||
|
if(!vehicle){
|
||||||
|
Player * player = dynamic_cast<Player*>(conn->getControlObject());
|
||||||
|
if(!player) return;
|
||||||
|
if (!player->isMounted()) return;
|
||||||
|
vehicle = dynamic_cast<Vehicle*>(player->getObjectMount());
|
||||||
|
if(!vehicle) return;
|
||||||
|
}
|
||||||
|
|
||||||
Parent::onRender(offset,updateRect);
|
Parent::onRender(offset,updateRect);
|
||||||
|
|
||||||
// Use the vehicle's velocity as its speed...
|
// Use the vehicle's velocity as its speed...
|
||||||
mSpeed = control->getVelocity().len();
|
mSpeed = vehicle->getVelocity().len();
|
||||||
if (mSpeed > mMaxSpeed)
|
if (mSpeed > mMaxSpeed)
|
||||||
mSpeed = mMaxSpeed;
|
mSpeed = mMaxSpeed;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue