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

@ -220,7 +220,6 @@ Class SWWMHandler : EventHandler
}
}
OnelinerTick();
FlashTick();
ItemCountTrack();
CombatTrack();
OneHundredPercentCheck();
@ -258,7 +257,6 @@ Class SWWMHandler : EventHandler
override void PostUiTick()
{
OnelinerUITick();
FlashUITick();
VanillaBossUITick();
// corruption cards dialogue
if ( ccloaded && !gdat.ccstartonce && !cardmessaged && (gamestate == GS_LEVEL) )

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();

View file

@ -90,6 +90,11 @@ extend Class SWWMHandler
bar.ntagtic = level.totaltime;
bar.ntagcol = nametagcolor;
}
else if ( e.Name ~== "swwmdoflash" )
{
GenericFlash gf = new("GenericFlash").Setup(flash_camera,flash_color,flash_duration);
StatusBar.AttachMessage(gf,0,BaseStatusBar.HUDMSGLayer_UnderHUD);
}
}
override void NetworkProcess( ConsoleEvent e )

View file

@ -156,14 +156,6 @@ Class GenericFlash : HUDMessageBase
}
}
Class QueuedFlash
{
Color c;
int duration;
int tic;
Actor cam;
}
// Achievement notification
Class SWWMAchievementNotification : HUDMessageBase
{