Skip to content

Commit

Permalink
Add support for sandbox production points.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoPi1998 authored and stijnwop committed Dec 16, 2023
1 parent dc35782 commit abf5288
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ ManureSystemPlaceableProductionPoint = {}

---@return boolean
function ManureSystemPlaceableProductionPoint.prerequisitesPresent(specializations)
if pdlc_pumpsAndHosesPack ~= nil and SpecializationUtil.hasSpecialization(pdlc_pumpsAndHosesPack.SandboxPlaceableProductionPoint, specializations) then
return true
end

return SpecializationUtil.hasSpecialization(PlaceableProductionPoint, specializations)
end

Expand All @@ -33,7 +37,7 @@ end

---@return void
function ManureSystemPlaceableProductionPoint:onPostLoad(savegame)
local productionPoint = self.spec_productionPoint.productionPoint
local productionPoint = ManureSystemPlaceableProductionPoint.getProductionPoint(self)
if productionPoint ~= nil then
if self:addManureSystemStorage(productionPoint.storage) then
productionPoint.storage.canFarmAccess = function(_, farmId)
Expand Down Expand Up @@ -61,8 +65,21 @@ end

---@return void
function ManureSystemPlaceableProductionPoint:onPreDelete()
local productionPoint = self.spec_productionPoint.productionPoint
local productionPoint = ManureSystemPlaceableProductionPoint.getProductionPoint(self)
if productionPoint ~= nil then
self:removeManureSystemStorage(productionPoint.storage)
end
end

---@return table | nil
function ManureSystemPlaceableProductionPoint.getProductionPoint(self)
if self.spec_productionPoint ~= nil then
return self.spec_productionPoint.productionPoint
end

if self.spec_sandboxPlaceableProductionPoint ~= nil then
return self.spec_sandboxPlaceableProductionPoint.productionPoint
end

return nil
end

0 comments on commit abf5288

Please sign in to comment.