Major code refactoring. SWWMHandler could still use some more, though.
This commit is contained in:
parent
0eec40e723
commit
c5abe83831
94 changed files with 17859 additions and 17678 deletions
70
zscript/handler/swwm_handler_flash.zsc
Normal file
70
zscript/handler/swwm_handler_flash.zsc
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
// screen flashes
|
||||
|
||||
extend Class SWWMHandler
|
||||
{
|
||||
transient Array<QueuedFlash> flashes;
|
||||
// heal/armor flashes need to be handled here so they don't stack
|
||||
transient int hflash[MAXPLAYERS], aflash[MAXPLAYERS];
|
||||
|
||||
static void HealthFlash( int p )
|
||||
{
|
||||
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
|
||||
if ( !hnd || (p == -1) ) return;
|
||||
hnd.hflash[p] = gametic+5;
|
||||
}
|
||||
|
||||
static void ArmorFlash( int p )
|
||||
{
|
||||
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
|
||||
if ( !hnd || (p == -1) ) return;
|
||||
hnd.aflash[p] = gametic+5;
|
||||
}
|
||||
|
||||
static void DoFlash( Actor camera, Color c, int duration )
|
||||
{
|
||||
// don't flash when paused
|
||||
if ( menuactive && (menuactive != Menu.OnNoPause) ) return;
|
||||
QueuedFlash qf = new("QueuedFlash");
|
||||
qf.duration = duration;
|
||||
qf.c = c;
|
||||
qf.tic = gametic;
|
||||
qf.cam = camera;
|
||||
let hnd = SWWMHandler(EventHandler.Find("SWWMHandler"));
|
||||
if ( !hnd ) return; // not supposed to happen
|
||||
hnd.flashes.push(qf);
|
||||
}
|
||||
|
||||
private void FlashTick()
|
||||
{
|
||||
for ( int i=0; i<flashes.size(); i++ )
|
||||
{
|
||||
if ( flashes[i].tic >= gametic ) continue;
|
||||
flashes.Delete(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
private ui void FlashUITick()
|
||||
{
|
||||
for ( int i=0; i<flashes.size(); i++ )
|
||||
{
|
||||
if ( flashes[i].tic < gametic ) continue;
|
||||
GenericFlash gf = new("GenericFlash").Setup(flashes[i].cam,flashes[i].c,flashes[i].duration);
|
||||
StatusBar.AttachMessage(gf,0,BaseStatusBar.HUDMSGLayer_UnderHUD);
|
||||
}
|
||||
}
|
||||
private ui void FlashRender( RenderEvent e )
|
||||
{
|
||||
int camplayer = players[consoleplayer].Camera.PlayerNumber();
|
||||
if ( camplayer == -1 ) return;
|
||||
if ( gametic < hflash[camplayer] )
|
||||
{
|
||||
double fstr = (hflash[camplayer]-(gametic+e.FracTic))/5.;
|
||||
Screen.Dim(Color(64,128,255),.1875*fstr,0,0,Screen.GetWidth(),Screen.GetHeight());
|
||||
}
|
||||
if ( gametic < aflash[camplayer] )
|
||||
{
|
||||
double fstr = (aflash[camplayer]-(gametic+e.FracTic))/5.;
|
||||
Screen.Dim(Color(96,255,64),.1875*fstr,0,0,Screen.GetWidth(),Screen.GetHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue