Flashes don't need a queue now that interface events exist.

This commit is contained in:
Mari the Deer 2023-09-29 23:58:46 +02:00
commit 19e460fc3a
5 changed files with 16 additions and 38 deletions

View file

@ -2,7 +2,10 @@
extend Class SWWMHandler
{
transient Array<QueuedFlash> flashes;
// interface event has to read from these
transient Actor flash_camera;
transient Color flash_color;
transient int flash_duration;
// heal/armor flashes need to be handled here so they don't stack
transient int hflash[MAXPLAYERS], aflash[MAXPLAYERS];
@ -24,34 +27,14 @@ extend Class SWWMHandler
{
// 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);
if ( !hnd ) return;
hnd.flash_camera = camera;
hnd.flash_color = c;
hnd.flash_duration = duration;
EventHandler.SendInterfaceEvent(consoleplayer,"swwmdoflash");
}
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();