| 288 | } |
| 289 | |
| 290 | void StatusController::addEphemeralEffects( |
| 291 | List<EphemeralStatusEffect> const& effectList, Maybe<EntityId> sourceEntityId) { |
| 292 | for (auto const& effect : effectList) { |
| 293 | if (auto existingEffect = m_uniqueEffects.ptr(effect.uniqueEffect)) { |
| 294 | auto metadata = m_uniqueEffectMetadata.getNetElement(existingEffect->metadataId); |
| 295 | |
| 296 | // If the effect exists and does not have a null duration, then refresh |
| 297 | // the |
| 298 | // duration to the max |
| 299 | if (metadata->duration) { |
| 300 | auto newDuration = effect.duration.value(defaultUniqueEffectDuration(effect.uniqueEffect)); |
| 301 | if (newDuration > *metadata->duration) { |
| 302 | // Only overwrite the sourceEntityId if the duration is *extended* |
| 303 | metadata->sourceEntityId.set(sourceEntityId); |
| 304 | metadata->duration = newDuration; |
| 305 | } |
| 306 | metadata->maxDuration.set(max(metadata->maxDuration.get(), newDuration)); |
| 307 | } |
| 308 | } else { |
| 309 | addUniqueEffect( |
| 310 | effect.uniqueEffect, effect.duration.value(defaultUniqueEffectDuration(effect.uniqueEffect)), sourceEntityId); |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | bool StatusController::removeEphemeralEffect(UniqueStatusEffect const& effect) { |
| 316 | if (auto uniqueEffect = m_uniqueEffects.ptr(effect)) { |
no test coverage detected