Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifiers replaced by stacking should not trigger a ModifierRemoved event #113

Closed
unleashurgeek opened this issue Jun 30, 2023 · 0 comments · Fixed by #135
Closed

Modifiers replaced by stacking should not trigger a ModifierRemoved event #113

unleashurgeek opened this issue Jun 30, 2023 · 0 comments · Fixed by #135

Comments

@unleashurgeek
Copy link
Member

In the current sim implementation, ReplaceBySource and Replace stacking behaviors will trigger a ModifierRemoved event and call the OnRemove listener when being replaced (IE: another application is occurring). This results in any removal behavior being triggered:

func (mgr *Manager) replaceBySource(target key.TargetID, instance *ModifierInstance) (*ModifierInstance, bool) {
for i, mod := range mgr.targets[target] {
if mod.name == instance.name && mod.source == instance.source {
// replace means this added instance is the new instance (can have new param values)
instance.count = stackCount(instance, mod.count)
mgr.targets[target][i] = instance
mgr.emitRemove(target, []*ModifierInstance{mod})
return instance, true
}
}
// no match, add this instance as a new modifier
mgr.targets[target] = append(mgr.targets[target], instance)
return instance, true
}
func (mgr *Manager) replace(target key.TargetID, instance *ModifierInstance) (*ModifierInstance, bool) {
for i, mod := range mgr.targets[target] {
if mod.name == instance.name {
// replace means this added instance is the new instance (can have new param values)
instance.count = stackCount(instance, mod.count)
mgr.targets[target][i] = instance
mgr.emitRemove(target, []*ModifierInstance{mod})
return instance, true
}
}
// no match, add this instance as a new modifier
mgr.targets[target] = append(mgr.targets[target], instance)
return instance, true
}

This does not match the game behavior. In-game, these replace stacking/refresh scenarios do not cause a removal to be triggered. These emitRemove calls should be removed from these stacking behaviors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant