| 1 |
--[[ Copyright (c) 2010 Manuel "Roujin" Wolf |
| 2 |
|
| 3 |
Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 4 |
this software and associated documentation files (the "Software"), to deal in |
| 5 |
the Software without restriction, including without limitation the rights to |
| 6 |
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies |
| 7 |
of the Software, and to permit persons to whom the Software is furnished to do |
| 8 |
so, subject to the following conditions: |
| 9 |
|
| 10 |
The above copyright notice and this permission notice shall be included in all |
| 11 |
copies or substantial portions of the Software. |
| 12 |
|
| 13 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 |
SOFTWARE. --]] |
| 20 |
|
| 21 |
local room = {} |
| 22 |
room.id = "decontamination" |
| 23 |
room.vip_must_visit = false |
| 24 |
room.level_config_id = 30 |
| 25 |
room.class = "DecontaminationRoom" |
| 26 |
room.name = _S.rooms_short.decontamination |
| 27 |
room.long_name = _S.rooms_long.decontamination |
| 28 |
room.tooltip = _S.tooltip.rooms.decontamination |
| 29 |
room.objects_additional = { "extinguisher", "radiator", "plant", "bin" } |
| 30 |
room.objects_needed = { shower = 1, console = 1 } |
| 31 |
room.build_preview_animation = 5100 |
| 32 |
room.categories = { |
| 33 |
clinics = 8, |
| 34 |
} |
| 35 |
room.minimum_size = 5 |
| 36 |
room.wall_type = "blue" |
| 37 |
room.floor_tile = 19 |
| 38 |
room.required_staff = { |
| 39 |
Doctor = 1, |
| 40 |
} |
| 41 |
room.maximum_staff = room.required_staff |
| 42 |
room.call_sound = "reqd024.wav" |
| 43 |
room.handyman_call_sound = "maint012.wav" |
| 44 |
|
| 45 |
class "DecontaminationRoom" (Room) |
| 46 |
|
| 47 |
---@type DecontaminationRoom |
| 48 |
local DecontaminationRoom = _G["DecontaminationRoom"] |
| 49 |
|
| 50 |
function DecontaminationRoom:DecontaminationRoom(...) |
| 51 |
self:Room(...) |
| 52 |
end |
| 53 |
|
| 54 |
function DecontaminationRoom:commandEnteringStaff(staff) |
| 55 |
self.staff_member = staff |
| 56 |
staff:setNextAction(MeanderAction()) |
| 57 |
return Room.commandEnteringStaff(self, staff) |
| 58 |
end |
| 59 |
|
| 60 |
function DecontaminationRoom:commandEnteringPatient(patient) |
| 61 |
local staff = self.staff_member |
| 62 |
local shower, pat_x, pat_y = self.world:findObjectNear(patient, "shower") |
| 63 |
local console, stf_x, stf_y = self.world:findObjectNear(staff, "console") |
| 64 |
|
| 65 |
local --[[persistable:decontamination_shared_loop_callback]] function loop_callback() |
| 66 |
if staff:getCurrentAction().shower_ready and patient:getCurrentAction().shower_ready then |
| 67 |
staff:finishAction() |
| 68 |
patient:finishAction() |
| 69 |
end |
| 70 |
end |
| 71 |
|
| 72 |
staff:walkTo(stf_x, stf_y) |
| 73 |
|
| 74 |
local idle_action = IdleAction():setDirection(console.direction == "north" and "west" or "north") |
| 75 |
:setLoopCallback(loop_callback) |
| 76 |
idle_action.shower_ready = true |
| 77 |
staff:queueAction(idle_action) |
| 78 |
staff:queueAction(UseObjectAction(console)) |
| 79 |
|
| 80 |
patient:walkTo(pat_x, pat_y) |
| 81 |
|
| 82 |
idle_action = IdleAction():setDirection(shower.direction == "north" and "north" or "west") |
| 83 |
:setLoopCallback(loop_callback) |
| 84 |
idle_action.shower_ready = true |
| 85 |
patient:queueAction(idle_action) |
| 86 |
|
| 87 |
local prolonged = true |
| 88 |
local length = math.random() * 3 - staff.profile.skill |
| 89 |
if length < 1 then |
| 90 |
prolonged = false -- Really short usage |
| 91 |
else |
| 92 |
length = length - 1 |
| 93 |
end |
| 94 |
|
| 95 |
local shower_loop_callback = --[[persistable:shower_loop_callback]] function(action) |
| 96 |
length = length - 1 |
| 97 |
if length <= 0 then |
| 98 |
action.prolonged_usage = false |
| 99 |
end |
| 100 |
end |
| 101 |
|
| 102 |
local shower_after_use = --[[persistable:shower_after_use]] function() |
| 103 |
if not self.staff_member then |
| 104 |
return |
| 105 |
end |
| 106 |
self.staff_member:setNextAction(MeanderAction()) |
| 107 |
if not patient.going_home then |
| 108 |
self:dealtWithPatient(patient) |
| 109 |
end |
| 110 |
end |
| 111 |
|
| 112 |
patient:queueAction(UseObjectAction(shower):setProlongedUsage(prolonged) |
| 113 |
:setLoopCallback(shower_loop_callback):setAfterUse(shower_after_use)) |
| 114 |
|
| 115 |
return Room.commandEnteringPatient(self, patient) |
| 116 |
end |
| 117 |
|
| 118 |
function DecontaminationRoom:onHumanoidLeave(humanoid) |
| 119 |
if self.staff_member == humanoid then |
| 120 |
self.staff_member = nil |
| 121 |
end |
| 122 |
Room.onHumanoidLeave(self, humanoid) |
| 123 |
end |
| 124 |
|
| 125 |
return room |