Skip to content

Commit

Permalink
Add guards when clearing up buildmanagers
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Sep 16, 2023
1 parent 0fece7d commit 0883d0c
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions lua/aibrain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1141,16 +1141,33 @@ AIBrain = Class(AIBrainHQComponent, AIBrainStatisticsComponent, AIBrainJammerCom
end
-- removing AI BuilderManagers
if self.BuilderManagers then
for k, v in self.BuilderManagers do
v.EngineerManager:SetEnabled(false)
v.FactoryManager:SetEnabled(false)
v.PlatoonFormManager:SetEnabled(false)
v.EngineerManager:Destroy()
v.FactoryManager:Destroy()
v.PlatoonFormManager:Destroy()
if v.StrategyManager then
v.StrategyManager:SetEnabled(false)
v.StrategyManager:Destroy()
for k, manager in self.BuilderManagers do
if manager.EngineerManager then
manager.EngineerManager:SetEnabled(false)
end

if manager.FactoryManager then
manager.FactoryManager:SetEnabled(false)
end

if manager.PlatoonFormManager then
manager.PlatoonFormManager:SetEnabled(false)
end

if manager.EngineerManager then
manager.EngineerManager:Destroy()
end

if manager.FactoryManager then
manager.FactoryManager:Destroy()
end

if manager.PlatoonFormManager then
manager.PlatoonFormManager:Destroy()
end
if manager.StrategyManager then
manager.StrategyManager:SetEnabled(false)
manager.StrategyManager:Destroy()
end
self.BuilderManagers[k].EngineerManager = nil
self.BuilderManagers[k].FactoryManager = nil
Expand Down

0 comments on commit 0883d0c

Please sign in to comment.