Skip to content

Commit

Permalink
Add custom checks on the strategies if the object has the required specs
Browse files Browse the repository at this point in the history
  • Loading branch information
stijnwop committed Apr 4, 2018
1 parent 7337b16 commit c3876d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
6 changes: 1 addition & 5 deletions src/vehicles/HoseSystemFillArm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,9 @@ function HoseSystemFillArm:load(savegame)

self.fillArm = HoseSystemUtil.callStrategyFunction(self.fillArmStrategies, 'load', { self.xmlFile, HoseSystemFillArm.XML_KEY, self.fillArm })

if self.fillArm.needsTransfer ~= nill and not self.fillArm.needsTransfer and not SpecializationUtil.hasSpecialization(Fillable, self.specializations) then
HoseSystemUtil:log(HoseSystemUtil.ERROR, "Specialization HoseSystemFillArm needs the specialization Fillable")

if not HoseSystemUtil.callStrategyFunction(self.fillArmStrategies, 'prerequisitesPresent', { self }) then
self.fillArm = {}
self.fillArmStrategies = {}

return
end
end
end
Expand Down
13 changes: 13 additions & 0 deletions src/vehicles/strategies/HoseSystemArmStrategy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ HoseSystemArmStrategy = {}

local HoseSystemArmStrategy_mt = Class(HoseSystemArmStrategy)

---
-- @param object
--
function HoseSystemArmStrategy:prerequisitesPresent(object)
if not SpecializationUtil.hasSpecialization(Fillable, object.specializations) then
HoseSystemUtil:log(HoseSystemUtil.ERROR, "Strategy HoseSystemArmStrategy needs the specialization Fillable")

return false
end

return true
end

---
-- @param object
-- @param mt
Expand Down
13 changes: 13 additions & 0 deletions src/vehicles/strategies/HoseSystemDockArmStrategy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ HoseSystemDockArmStrategy = {}

local HoseSystemDockArmStrategy_mt = Class(HoseSystemDockArmStrategy)

---
-- @param object
--
function HoseSystemDockArmStrategy:prerequisitesPresent(object)
if not object.fillArm.needsTransfer and not SpecializationUtil.hasSpecialization(Fillable, object.specializations) then
HoseSystemUtil:log(HoseSystemUtil.ERROR, "Strategy HoseSystemDockArmStrategy needs the specialization Fillable")

return false
end

return true
end

---
-- @param object
-- @param mt
Expand Down

0 comments on commit c3876d5

Please sign in to comment.