remove missing persistent effects
This commit is contained in:
parent
dc77061840
commit
21f9ab763e
@ -650,22 +650,26 @@ void StatusController::updateAnimators(float dt) {
|
|||||||
|
|
||||||
void StatusController::updatePersistentUniqueEffects() {
|
void StatusController::updatePersistentUniqueEffects() {
|
||||||
Set<UniqueStatusEffect> activePersistentUniqueEffects;
|
Set<UniqueStatusEffect> activePersistentUniqueEffects;
|
||||||
for (auto const& categoryPair : m_persistentEffects)
|
for (auto & categoryPair : m_persistentEffects) {
|
||||||
activePersistentUniqueEffects.addAll(categoryPair.second.uniqueEffects);
|
for (auto & uniqueEffectName : categoryPair.second.uniqueEffects) {
|
||||||
|
// It is important to note here that if a unique effect exists, it *may*
|
||||||
for (auto const& uniqueEffectName : activePersistentUniqueEffects) {
|
// not come from a persistent effect, it *may* be from an ephemeral effect.
|
||||||
// It is important to note here that if a unique effect exists, it *may*
|
// Here, when a persistent effect overrides an ephemeral effect, it is
|
||||||
// not come from a persistent effect, it *may* be from an ephemeral effect.
|
// clearing the duration making it into a solely persistent effect. This
|
||||||
// Here, when a persistent effect overrides an ephemeral effect, it is
|
// means that by applying a persistent effect and then clearing it, you can
|
||||||
// clearing the duration making it into a solely persistent effect. This
|
// remove an ephemeral effect.
|
||||||
// means that by applying a persistent effect and then clearing it, you can
|
if (auto existingEffect = m_uniqueEffects.ptr(uniqueEffectName)) {
|
||||||
// remove an ephemeral effect.
|
m_uniqueEffectMetadata.getNetElement(existingEffect->metadataId)->duration.reset();
|
||||||
if (auto existingEffect = m_uniqueEffects.ptr(uniqueEffectName))
|
activePersistentUniqueEffects.add(uniqueEffectName);
|
||||||
m_uniqueEffectMetadata.getNetElement(existingEffect->metadataId)->duration.reset();
|
}
|
||||||
else
|
// we want to make sure the effect it's applying actually exists
|
||||||
addUniqueEffect(uniqueEffectName, {}, {});
|
// if not then it should be removed from the list
|
||||||
|
else if (addUniqueEffect(uniqueEffectName, {}, {}))
|
||||||
|
activePersistentUniqueEffects.add(uniqueEffectName);
|
||||||
|
else
|
||||||
|
categoryPair.second.uniqueEffects.remove(uniqueEffectName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Again, here we are using "durationless" to mean "persistent"
|
// Again, here we are using "durationless" to mean "persistent"
|
||||||
for (auto const& key : m_uniqueEffects.keys()) {
|
for (auto const& key : m_uniqueEffects.keys()) {
|
||||||
auto metadata = m_uniqueEffectMetadata.getNetElement(m_uniqueEffects[key].metadataId);
|
auto metadata = m_uniqueEffectMetadata.getNetElement(m_uniqueEffects[key].metadataId);
|
||||||
@ -678,13 +682,13 @@ float StatusController::defaultUniqueEffectDuration(UniqueStatusEffect const& ef
|
|||||||
return Root::singleton().statusEffectDatabase()->uniqueEffectConfig(effect).defaultDuration;
|
return Root::singleton().statusEffectDatabase()->uniqueEffectConfig(effect).defaultDuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusController::addUniqueEffect(
|
bool StatusController::addUniqueEffect(
|
||||||
UniqueStatusEffect const& effect, Maybe<float> duration, Maybe<EntityId> sourceEntityId) {
|
UniqueStatusEffect const& effect, Maybe<float> duration, Maybe<EntityId> sourceEntityId) {
|
||||||
auto statusEffectDatabase = Root::singleton().statusEffectDatabase();
|
auto statusEffectDatabase = Root::singleton().statusEffectDatabase();
|
||||||
if (statusEffectDatabase->isUniqueEffect(effect)) {
|
if (statusEffectDatabase->isUniqueEffect(effect)) {
|
||||||
auto effectConfig = statusEffectDatabase->uniqueEffectConfig(effect);
|
auto effectConfig = statusEffectDatabase->uniqueEffectConfig(effect);
|
||||||
if ((duration && statPositive("statusImmunity")) || (effectConfig.blockingStat && statPositive(*effectConfig.blockingStat)))
|
if ((duration && statPositive("statusImmunity")) || (effectConfig.blockingStat && statPositive(*effectConfig.blockingStat)))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
auto& uniqueEffect = m_uniqueEffects[effect];
|
auto& uniqueEffect = m_uniqueEffects[effect];
|
||||||
uniqueEffect.effectConfig = effectConfig;
|
uniqueEffect.effectConfig = effectConfig;
|
||||||
@ -701,8 +705,11 @@ void StatusController::addUniqueEffect(
|
|||||||
|
|
||||||
if (m_parentEntity)
|
if (m_parentEntity)
|
||||||
initUniqueEffectScript(uniqueEffect);
|
initUniqueEffectScript(uniqueEffect);
|
||||||
|
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
Logger::warn("Unique status effect '{}' not found in status effect database", effect);
|
Logger::warn("Unique status effect '{}' not found in status effect database", effect);
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ private:
|
|||||||
void updatePersistentUniqueEffects();
|
void updatePersistentUniqueEffects();
|
||||||
|
|
||||||
float defaultUniqueEffectDuration(UniqueStatusEffect const& name) const;
|
float defaultUniqueEffectDuration(UniqueStatusEffect const& name) const;
|
||||||
void addUniqueEffect(UniqueStatusEffect const& effect, Maybe<float> duration, Maybe<EntityId> sourceEntityId);
|
bool addUniqueEffect(UniqueStatusEffect const& effect, Maybe<float> duration, Maybe<EntityId> sourceEntityId);
|
||||||
void removeUniqueEffect(UniqueStatusEffect const& name);
|
void removeUniqueEffect(UniqueStatusEffect const& name);
|
||||||
|
|
||||||
void initPrimaryScript();
|
void initPrimaryScript();
|
||||||
|
Loading…
Reference in New Issue
Block a user