Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

TribesGUI.HUDHealthBar


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
class HUDHealthBar extends HUDValueBar;

var() config HUDMaterial	healthInjectionMaterial;
var() config HUDMaterial	healthInjectionRemainingMaterial;
var() config HUDMaterial	lowHealthAlertMaterial;
var() config float			lowHealthThreshold;

var float	healthInjectionAmount;

//
// Updates the data
function UpdateData(ClientSideCharacter c)
{
	value = c.health;
	maximumValue = c.healthMaximum;
	healthInjectionAmount = c.healthInjectionAmount;

	super.UpdateData(c);
}

//
// Renders the element. Overridden here due to the special requirements
// of the effects on the health bar when healing & losing health
//
function RenderElement(Canvas C)
{
	local float oldClipX;
	local float injectionRatio;

	// calc the actual health ratio
	CalculateRatio();

	// draw the empty bar
	RenderHUDMaterial(C, activeEmptyTexture, Width, Height);
	// DrawTile sets CurX, CurY
	C.CurX = 0;
	C.CurY = 0;

	// want to render the usual full texture here,
	// only clipped to the point that the healthInjection
	// will finish
	oldClipX = C.ClipX;	
	if(healthInjectionAmount > 0)
	{
		injectionRatio = FClamp((healthInjectionAmount / maximumValue) + ratio, 0.0, 1.0);
		ClipToValue(C, healthInjectionRemainingMaterial, injectionRatio);
		// draw the empty bar
		RenderHUDMaterial(C, healthInjectionRemainingMaterial, Width, Height);
		// DrawTile sets CurX, CurY
		C.CurX = 0;
		C.CurY = 0;
	}

	// Clip to the current bar value
	ClipToValue(C, activeFullTexture, ratio);

	// draw the full bar, clipped to the ratio
	if(healthInjectionAmount > 0)
		// health injection pulsing thingy
		RenderHUDMaterial(C, healthInjectionMaterial, Width, Height);
	else if(ratio < lowHealthThreshold && healthInjectionAmount <= 0)
		// low health flashy warning alert thingy
		RenderHUDMaterial(C, lowHealthAlertMaterial, Width, Height);
	else
		// low health flashy warning alert thingy
		RenderHUDMaterial(C, activeFullTexture, Width, Height);
	
	// DrawTile sets CurX, CurY
	C.CurX = 0;
	C.CurY = 0;

	// return to the old clip
	C.ClipX = oldClipX;
}

defaultproperties
{
	lowHealthThreshold = 0.25
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: st 16.4.2014 10:20:44.000 - Creation time: st 23.5.2018 00:10:44.301 - Created with UnCodeX