Permalink
Browse files

Remove handyman task upon sweep action start

Litter not 'tickable' as in to interrupt Handyman tasks when Litter:remove on build over

Remove handyman tasks when already user_of litter
Corrected the assignment of the Litter.ticks to passed in object.
  • Loading branch information...
mugmuggy committed Nov 25, 2017
1 parent fe1a526 commit 0834c5f19cdae6267e384f7d1a2b5ee77a46021b
View
@@ -28,7 +28,7 @@ local runDebugger = dofile "run_debugger"
-- Increment each time a savegame break would occur
-- and add compatibility code in afterLoad functions
local SAVEGAME_VERSION = 120
local SAVEGAME_VERSION = 121
class "App"
@@ -900,6 +900,15 @@ function Staff:afterLoad(old, new)
end
end
if old < 121 then
if self.humanoid_class == "Handyman" and self.user_of and self.user_of.object_type.class == "Litter" then
local litter = self.user_of
local hospital = self.world:getHospital(litter.tile_x, litter.tile_y)
local taskIndex = hospital:getIndexOfTask(litter.tile_x, litter.tile_y, "cleaning", litter)
hospital:removeHandymanTask(taskIndex, "cleaning")
end
end
Humanoid.afterLoad(self, old, new)
end
@@ -57,6 +57,11 @@ end)
local function action_sweep_floor_start(action, humanoid)
action.must_happen = true
humanoid.user_of = action.litter
-- remove handyman task as soon as action starts - we should be committed to completing this task
local litter = action.litter
local hospital = litter.world:getHospital(litter.tile_x, litter.tile_y)
local taskIndex = hospital:getIndexOfTask(litter.tile_x, litter.tile_y, "cleaning", litter)
hospital:removeHandymanTask(taskIndex, "cleaning")
local anim = animation_numbers[1]
humanoid:setAnimation(anim)
humanoid:setTimer(humanoid.world:getAnimLength(anim), sweep)
@@ -56,6 +56,7 @@ local Litter = _G["Litter"]
function Litter:Litter(world, object_type, x, y, direction, etc)
local th = TH.animation()
self:Entity(th)
self.ticks = object_type.ticks
self.object_type = object_type
self.world = world
self:setTile(x, y)
@@ -149,6 +150,10 @@ function Litter:afterLoad(old, new)
hospital:removeHandymanTask(taskIndex, "cleaning")
end
end
if old < 121 then
self.ticks = object.ticks
end
end
return object

0 comments on commit 0834c5f

Please sign in to comment.