mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 12:14:45 +00:00
offload weapon/ammo counter update commands to the generic damagemodel
This commit is contained in:
parent
7cad861536
commit
53ad8ccc6d
|
|
@ -23,6 +23,7 @@ function DamageModel::onCreateGameServer(%this)
|
|||
%this.queueExec("./scripts/server/shapeBase");
|
||||
%this.queueExec("./scripts/server/vehicle");
|
||||
%this.queueExec("./scripts/server/player");
|
||||
%this.queueExec("./scripts/server/commands");
|
||||
}
|
||||
|
||||
//This is called when the server is shut down due to the game/map being exited
|
||||
|
|
@ -35,6 +36,7 @@ function DamageModel::initClient(%this)
|
|||
{
|
||||
%this.queueExec("./guis/damageGuiOverlay.gui");
|
||||
%this.queueExec("./scripts/client/playGui");
|
||||
%this.queueExec("./scripts/client/client");
|
||||
}
|
||||
|
||||
//This is called when a client connects to a server
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
|
||||
// ----------------------------------------------------------------------------
|
||||
// WeaponHUD
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Update the Ammo Counter with current ammo, if not any then hide the counter.
|
||||
function clientCmdSetAmmoAmountHud(%amount, %amountInClips)
|
||||
{
|
||||
if (!%amount)
|
||||
AmmoAmount.setVisible(false);
|
||||
else
|
||||
{
|
||||
AmmoAmount.setVisible(true);
|
||||
AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips);
|
||||
}
|
||||
}
|
||||
|
||||
// Here we update the Weapon Preview image & reticle for each weapon. We also
|
||||
// update the Ammo Counter (just so we don't have to call it separately).
|
||||
// Passing an empty parameter ("") hides the HUD component.
|
||||
|
||||
function clientCmdRefreshWeaponHUD(%amount, %preview, %ret, %zoomRet, %amountInClips)
|
||||
{
|
||||
if (!%amount)
|
||||
AmmoAmount.setVisible(false);
|
||||
else
|
||||
{
|
||||
AmmoAmount.setVisible(true);
|
||||
AmmoAmount.setText("Ammo: " @ %amount @ "/" @ %amountInClips);
|
||||
}
|
||||
|
||||
if (%preview $= "" || detag(%preview) $= "blank")
|
||||
{
|
||||
WeaponHUD.setVisible(false);
|
||||
PreviewImage.setBitmap("");
|
||||
}
|
||||
else
|
||||
{
|
||||
WeaponHUD.setVisible(true);
|
||||
PreviewImage.setbitmap(detag(%preview));
|
||||
}
|
||||
|
||||
if (%ret $= "" || detag(%ret) $= "blank")
|
||||
{
|
||||
Reticle.setVisible(false);
|
||||
Reticle.setBitmap("");
|
||||
}
|
||||
else
|
||||
{
|
||||
Reticle.setVisible(true);
|
||||
Reticle.setbitmap(detag(%ret));
|
||||
}
|
||||
|
||||
if (isObject(ZoomReticle) || detag(%zoomRet) $= "blank")
|
||||
{
|
||||
if (%zoomRet $= "" || detag(%zoomRet) $= "blank")
|
||||
{
|
||||
ZoomReticle.setVisible(false);
|
||||
ZoomReticle.setBitmap("");
|
||||
}
|
||||
else
|
||||
{
|
||||
ZoomReticle.setVisible(true);
|
||||
ZoomReticle.setBitmap(detag(%zoomRet));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// ----------------------------------------------------------------------------
|
||||
// weapon HUD
|
||||
// ----------------------------------------------------------------------------
|
||||
function GameConnection::setAmmoAmountHud(%client, %amount, %amountInClips )
|
||||
{
|
||||
commandToClient(%client, 'SetAmmoAmountHud', %amount, %amountInClips);
|
||||
}
|
||||
|
||||
function GameConnection::RefreshWeaponHud(%client, %amount, %preview, %ret, %zoomRet, %amountInClips)
|
||||
{
|
||||
commandToClient(%client, 'RefreshWeaponHud', %amount, %preview, %ret, %zoomRet, %amountInClips);
|
||||
}
|
||||
Loading…
Reference in a new issue