Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/snippets/fix.6702.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6702) Fix being able to store unbuilt units inside carriers and place unbuilt units on the ground with the fatboy.
24 changes: 14 additions & 10 deletions lua/defaultcomponents.lua
Original file line number Diff line number Diff line change
Expand Up @@ -940,18 +940,22 @@ ExternalFactoryComponent = ClassSimple {
---@param self Unit | ExternalFactoryComponent
---@param unitBeingBuilt Unit
OnStopBuildWithStorage = function(self, unitBeingBuilt)
--local unitBeingBuilt = self.UnitBeingBuilt
unitBeingBuilt:DetachFrom(true)
self:DetachAll(self.BuildAttachBone)

if not self:TransportHasAvailableStorage() or self:GetStat('AutoDeploy', 0).Value == 1 then
unitBeingBuilt:ShowBone(0, true)
-- Unbuilt units can be in `OnStopBuild` when a `BuildMobile` order gets cancelled. They shouldn't be put into storage.
if unitBeingBuilt:GetFractionComplete() < 1 then
unitBeingBuilt:Destroy()
else
self:AddUnitToStorage(unitBeingBuilt)
ForkThread(self.ClearOrdersThread, self, unitBeingBuilt)
end
unitBeingBuilt:DetachFrom(true)
self:DetachAll(self.BuildAttachBone)

if not self:TransportHasAvailableStorage() or self:GetStat('AutoDeploy', 0).Value == 1 then
unitBeingBuilt:ShowBone(0, true)
else
self:AddUnitToStorage(unitBeingBuilt)
ForkThread(self.ClearOrdersThread, self, unitBeingBuilt)
end

self:RequestRefreshUI()
self:RequestRefreshUI()
end
ChangeState(self, self.IdleState)
end,

Expand Down
11 changes: 11 additions & 0 deletions units/UEL0401/UEL0401_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ UEL0401 = ClassUnit(TMobileFactoryUnit, ExternalFactoryComponent) {
---@param unitBeingBuilt Unit
OnStopBuild = function(self, unitBeingBuilt)
TMobileFactoryUnit.OnStopBuild(self, unitBeingBuilt)
-- Unbuilt units can be in `OnStopBuild` when a `BuildMobile` order gets cancelled.
if unitBeingBuilt:GetFractionComplete() < 1 then
unitBeingBuilt:Destroy()
end
self.BuildingUnit = false
end,

Expand Down Expand Up @@ -186,6 +190,13 @@ UEL0401 = ClassUnit(TMobileFactoryUnit, ExternalFactoryComponent) {
---@param unitBeingBuilt Unit
OnStopBuild = function(self, unitBeingBuilt)
TMobileFactoryUnit.OnStopBuild(self, unitBeingBuilt)
-- Unbuilt units can be in `OnStopBuild` when a `BuildMobile` order gets cancelled.
if unitBeingBuilt:GetFractionComplete() < 1 then
unitBeingBuilt:Destroy()
ChangeState(self, self.IdleState)
return
end

ChangeState(self, self.RollingOffState)
end,
},
Expand Down
Loading