/=============================================================================
// HUDTestMut is jsut a sample of how to get your SpawnNotify Class spawned.
// This will be the Mutator you select from the Mutator Menu, so make sure
// you .int file references this, not the HUDMut.
//
// Andrew "drunken master" Scholer - ascholer@mediaone.net
//=============================================================================
class HUDTestMut expands Mutator;
function PreBeginPlay()
{
spawn(class'asHUDTest.asHUDNotify');
}
defaultproperties
{
}
//=============================================================================
// HUDMut is the mutator you will spawn for each actor to handle
// the PostRender calls. Note that if there is another HUDMutator
// attached to it it passes on the function call, allowing the
// other mutator to do its work also.
//
// Obviously, to coexist well with other HUDMutators, it might be a good
// idea to make you draw location adjustable. If you display some status
// indicators, try creating Mod Menu configurable choices between
// displaying on the right, left or top of screen. That way user can set up
// a few different HUD modifying mutators and know they won't overwrite
// each other on screen.
//
// Andrew "drunken master" Scholer - ascholer@mediaone.net
//=============================================================================
class HUDMut expands Mutator;
simulated function PostRender(canvas Canvas)
{
//Do your cool stuff here instrad of this test code.
Canvas.SetPos(50,50);
Canvas.DrawText("This is a test");
//If there is someone chained to this Mutator, call them
// NextMutator is a variable of the Mutator class and will be set
// up by the AddMutator call below.
if ( NextMutator != None ) //next mutator is already defined
{
NextMutator.PostRender(Canvas);
}
}
defaultproperties
{
}
/=============================================================================
// SpawnNotify - Actor spawn notification.
// NB - This happens on the client AND server for replicated actors.
//
// As many of you may have noticed, trying to get at MyHUD for clients in
// a network game through ModifyPlayer dosen't work. Instead you have to
// use a SpawnNotify actor. Once spawned, this guy sits around and intercepts
// all spawn hotifications of a given class (Selected in default properties).
// Note the simulated function call - this guy works on both server and clients.
//
// I added code to allow HUDmutators to chain off one another. This depends
// on your HUDMutator class having a variable HUDMutator (see HUDMut). If
// you really don't want to play nice, just can the else statement below.
// Then only the first mutator in gets to use it's HUD.
//
// Andrew "drunken master" Scholer - ascholer@mediaone.net
//=============================================================================
class asHUDNotify expands SpawnNotify;
//Called automatically anytime the class you specified in default properites
// is spawned (also called if a subclass of that class is spawned).
//Great way to catch things to modify or replace them - just make sure to use
// if statements to avoid infinite recursion if you replace something by
// spawning a new subclass.
simulated event Actor SpawnNotification( Actor A )
{
local Mutator tempActor;
if ( HUD(A).HUDMutator == none ) {
//If there aren't any HUDMutators attached to the HUD, attach
// your mutator.
HUD(A).HUDMutator = spawn(class'asHUDTest.HUDMut',A);
}
else
{
//If there is a HUDMutator attached to the HUD already, call
// AddMutator on that hud, passing it a newly spawned mutator
// of your own. Note that the AddMutator function will
// automatically seek the end of the mutator chain. (If the
// one you try to add yourself to has a NextMutator, the
// function call is passed to that mutator.)
HUD(A).HUDMutator.AddMutator(spawn(class'asHUDTest.HUDMut',A));
}
//Have to return the original actor (the HUD). If we had
// completely replaced it we would return the replacement.
return A;
}
defaultproperties
{
//This selects what class to intercept spawns for.
ActorClass=class'Engine.HUD'
}