Rework remove floating to use EntityList (#13895)

This commit is contained in:
Duncan 2021-01-22 14:36:55 +00:00 committed by GitHub
parent bc20efb3df
commit 1a11456f36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 18 deletions

View File

@ -827,29 +827,24 @@ void litter_remove_at(const CoordsXYZ& litterPos)
uint16_t remove_floating_sprites()
{
uint16_t removed = 0;
for (uint16_t i = 0; i < MAX_SPRITES; i++)
for (auto* balloon : EntityList<Balloon>(EntityListId::Misc))
{
auto* entity = GetEntity(i);
if (entity->Is<Balloon>())
sprite_remove(balloon);
removed++;
}
for (auto* duck : EntityList<Duck>(EntityListId::Misc))
{
if (duck->IsFlying())
{
sprite_remove(entity);
removed++;
}
else if (entity->Is<Duck>())
{
auto* duck = entity->As<Duck>();
if (duck->IsFlying())
{
duck->Remove();
removed++;
}
}
else if (entity->Is<MoneyEffect>())
{
sprite_remove(entity);
sprite_remove(duck);
removed++;
}
}
for (auto* money : EntityList<MoneyEffect>(EntityListId::Misc))
{
sprite_remove(money);
removed++;
}
return removed;
}