mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 20:41:46 +00:00
K_DropPowerUps: refactor to use more lambdas
This commit is contained in:
parent
d4b0ee21ab
commit
5d4ec59a33
1 changed files with 7 additions and 14 deletions
|
|
@ -82,28 +82,21 @@ void K_GivePowerUp(player_t* player, kartitems_t powerup, tic_t time)
|
||||||
|
|
||||||
void K_DropPowerUps(player_t* player)
|
void K_DropPowerUps(player_t* player)
|
||||||
{
|
{
|
||||||
auto simple_drop = [player](kartitems_t powerup, auto& timer)
|
auto drop = [player](kartitems_t powerup, auto callback)
|
||||||
{
|
{
|
||||||
tic_t remaining = K_PowerUpRemaining(player, powerup);
|
tic_t remaining = K_PowerUpRemaining(player, powerup);
|
||||||
|
|
||||||
if (remaining)
|
if (remaining)
|
||||||
{
|
{
|
||||||
K_DropPaperItem(player, powerup, remaining);
|
K_DropPaperItem(player, powerup, remaining);
|
||||||
timer = 0;
|
callback();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
simple_drop(POWERUP_SMONITOR, player->powerup.superTimer);
|
auto& powerup = player->powerup;
|
||||||
simple_drop(POWERUP_BARRIER, player->powerup.barrierTimer);
|
|
||||||
simple_drop(POWERUP_BADGE, player->powerup.rhythmBadgeTimer);
|
|
||||||
|
|
||||||
if (K_PowerUpRemaining(player, POWERUP_SUPERFLICKY))
|
drop(POWERUP_SMONITOR, [&] { powerup.superTimer = 0; });
|
||||||
{
|
drop(POWERUP_BARRIER, [&] { powerup.barrierTimer = 0; });
|
||||||
mobj_t* swarm = player->powerup.flickyController;
|
drop(POWERUP_BADGE, [&] { powerup.rhythmBadgeTimer = 0; });
|
||||||
|
drop(POWERUP_SUPERFLICKY, [&] { Obj_EndSuperFlickySwarm(powerup.flickyController); });
|
||||||
// Be sure to measure the remaining time before ending the power-up
|
|
||||||
K_DropPaperItem(player, POWERUP_SUPERFLICKY, Obj_SuperFlickySwarmTime(swarm));
|
|
||||||
|
|
||||||
Obj_EndSuperFlickySwarm(swarm);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue