Skip to content

Commit

Permalink
Add RemoveModifierClean()
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystalflxme committed Oct 20, 2023
1 parent b56b5a6 commit 82e63d9
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/rogueproperty/src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,18 @@ function RogueProperty:_addModifier(id: string, priority: number, map: (value: V
self:_recompute()
end

function RogueProperty:_removeModifier(id: string, callback: (() -> ())?)
for index, modifier in self._modifiers do
if modifier[1] == id then
table.remove(self._modifiers, index)
if callback then
callback()
end
return
end
end
end

function RogueProperty:SetBaseValue(value: Value)
self._baseValue = value
self:_recompute()
Expand Down Expand Up @@ -113,13 +125,13 @@ function RogueProperty:CreateOverrideModifier(id: string, value: Value, priority
end

function RogueProperty:RemoveModifier(id: string)
for index, modifier in self._modifiers do
if modifier[1] == id then
table.remove(self._modifiers, index)
self:_recompute()
return
end
end
self:_removeModifier(id, function()
self:_recompute()
end)
end

function RogueProperty:RemoveModifierClean(id: string)
self:_removeModifier(id)
end

function RogueProperty:ClearModifiers()
Expand Down

0 comments on commit 82e63d9

Please sign in to comment.