Skip to content

Commit

Permalink
Fix inconsistencies in the state management (FAForever#5328)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas authored Aug 17, 2023
1 parent a7b20ef commit e39bbba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/sim/Unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -516,14 +516,15 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) {

---@param self Unit
OnPaused = function(self)

if self:IsUnitState('Building') or self:IsUnitState('Upgrading') or self:IsUnitState('Repairing') then
self:SetActiveConsumptionInactive()
self:StopUnitAmbientSound('ConstructLoop')
end

-- When paused we reclaim at a speed of 0, with thanks to:
-- - https://github.com/FAForever/FA-Binary-Patches/pull/19
if self:IsUnitState('Reclaiming') then
if self.EntityBeingReclaimed and (not IsDestroyed(self.EntityBeingReclaimed)) then
self:StopReclaimEffects(self.EntityBeingReclaimed)
self:StopUnitAmbientSound('ReclaimLoop')
self:PlayUnitSound('StopReclaim')
Expand All @@ -539,7 +540,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) {

-- When paused we reclaim at a speed of 0, with thanks to:
-- - https://github.com/FAForever/FA-Binary-Patches/pull/19
if self.EntityBeingReclaimed then
if self.EntityBeingReclaimed and (not IsDestroyed(self.EntityBeingReclaimed)) then
self:StartReclaimEffects(self.EntityBeingReclaimed)
self:PlayUnitSound('StartReclaim')
self:PlayUnitAmbientSound('ReclaimLoop')
Expand Down Expand Up @@ -778,7 +779,6 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) {
---@param self Unit
---@param target Unit | Prop
OnStartReclaim = function(self, target)

-- When paused we reclaim at a speed of 0, with thanks to:
-- - https://github.com/FAForever/FA-Binary-Patches/pull/19
if not self:IsPaused() then
Expand Down Expand Up @@ -827,6 +827,7 @@ Unit = ClassUnit(moho.unit_methods, IntelComponent, VeterancyComponent) {
self:StopUnitAmbientSound('ReclaimLoop')
self:PlayUnitSound('StopReclaim')
self:SetUnitState('Reclaiming', false)
self.EntityBeingReclaimed = nil

if target.IsProp then
target:UpdateReclaimLeft()
Expand Down

0 comments on commit e39bbba

Please sign in to comment.