Skip to content

Commit

Permalink
Fix internal state of HQs (#4169)
Browse files Browse the repository at this point in the history
  • Loading branch information
Garanas committed Aug 23, 2022
1 parent e7df7c0 commit 0e1620a
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions lua/defaultunits.lua
Original file line number Diff line number Diff line change
Expand Up @@ -741,8 +741,8 @@ FactoryUnit = Class(StructureUnit) {
OnDestroy = function(self)
StructureUnit.OnDestroy(self)

if self.Blueprint.CategoriesHash["RESEARCH"] then

if self.Blueprint.CategoriesHash["RESEARCH"] and self:GetFractionComplete() == 1.0 then
-- update internal state
self.Brain:RemoveHQ(self.factionCategory, self.layerCategory, self.techCategory)
self.Brain:SetHQSupportFactoryRestrictions(self.factionCategory, self.layerCategory)
Expand Down Expand Up @@ -783,13 +783,6 @@ FactoryUnit = Class(StructureUnit) {
OnStartBuild = function(self, unitBeingBuilt, order)
StructureUnit.OnStartBuild(self, unitBeingBuilt, order)

-- related to HQ systems
if self.Blueprint.CategoriesHash["RESEARCH"] then
if EntityCategoryContains(categories.RESEARCH, self) then
unitBeingBuilt.UpgradedHQFromTech = self.techCategory
end
end

self.BuildingUnit = true
if order ~= 'Upgrade' then
ChangeState(self, self.BuildingState)
Expand Down Expand Up @@ -823,11 +816,6 @@ FactoryUnit = Class(StructureUnit) {
StructureUnit.OnStopBeingBuilt(self, builder, layer)

if self.Blueprint.CategoriesHash["RESEARCH"] then
-- if we're an upgrade then remove the HQ we came from
if self.UpgradedHQFromTech then
self.Brain:RemoveHQ(self.factionCategory, self.layerCategory, self.UpgradedHQFromTech)
end

-- update internal state
self.Brain:AddHQ(self.factionCategory, self.layerCategory, self.techCategory)
self.Brain:SetHQSupportFactoryRestrictions(self.factionCategory, self.layerCategory)
Expand Down

0 comments on commit 0e1620a

Please sign in to comment.