mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-08-09 15:49:52 +00:00
Changed a bunch of enums in Entity.h
This simplifies a few things. First, the values of DamageType are now continous, with the benefit that they can now be stored in a std::bitset. Second, this repairs entity_getNearestEntity(..., ET_AVATAR) or DT_ENEMY as param, because these were 0, but the game expected -1 as universal value. This way, any entity was returned when querying for ET_AVATAR or DT_ENEMY. Now, 0 is the universal/NONE value, which should avoid mistakes like this.
This commit is contained in:
parent
b242d80c75
commit
8b67ece907
3 changed files with 71 additions and 72 deletions
|
@ -1690,15 +1690,12 @@ void Entity::moveOutOfWall()
|
|||
|
||||
void Entity::clearDamageTargets()
|
||||
{
|
||||
disabledDamageTypes.clear();
|
||||
disabledDamageTypes.reset();
|
||||
}
|
||||
|
||||
void Entity::setDamageTarget(DamageType dt, bool v)
|
||||
{
|
||||
if (v)
|
||||
disabledDamageTypes.erase(dt);
|
||||
else
|
||||
disabledDamageTypes.insert(dt);
|
||||
disabledDamageTypes.set(dt, !v);
|
||||
}
|
||||
|
||||
void Entity::setEatType(EatType et, const std::string &file)
|
||||
|
@ -1719,17 +1716,17 @@ void Entity::setAllDamageTargets(bool v)
|
|||
else
|
||||
{
|
||||
for (int i = DT_ENEMY; i < DT_ENEMY_REALMAX; i++)
|
||||
disabledDamageTypes.insert(DamageType(i));
|
||||
disabledDamageTypes.set(DamageType(i));
|
||||
for (int i = DT_AVATAR; i < DT_AVATAR_REALMAX; i++)
|
||||
disabledDamageTypes.insert(DamageType(i));
|
||||
disabledDamageTypes.set(DamageType(i));
|
||||
for (int i = DT_AVATAR_MAX; i < DT_REALMAX; i++)
|
||||
disabledDamageTypes.insert(DamageType(i));
|
||||
disabledDamageTypes.set(DamageType(i));
|
||||
}
|
||||
}
|
||||
|
||||
bool Entity::isDamageTarget(DamageType dt)
|
||||
{
|
||||
return disabledDamageTypes.find(dt) == disabledDamageTypes.end();
|
||||
return disabledDamageTypes.test(dt);
|
||||
}
|
||||
|
||||
float Entity::getHealthPerc()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue