| 1 |
--[[ Copyright (c) 2009 Manuel König |
| 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 = "x_ray" |
| 23 |
room.vip_must_visit = false |
| 24 |
room.level_config_id = 16 |
| 25 |
room.class = "XRayRoom" |
| 26 |
room.name = _S.rooms_short.x_ray |
| 27 |
room.long_name = _S.rooms_long.x_ray |
| 28 |
room.tooltip = _S.tooltip.rooms.x_ray |
| 29 |
room.objects_additional = { "extinguisher", "radiator", "plant", "bin" } |
| 30 |
room.objects_needed = { x_ray = 1, radiation_shield = 1 } |
| 31 |
room.build_preview_animation = 5076 |
| 32 |
room.categories = { |
| 33 |
diagnosis = 7, |
| 34 |
} |
| 35 |
room.minimum_size = 6 |
| 36 |
room.wall_type = "yellow" |
| 37 |
room.floor_tile = 19 |
| 38 |
room.required_staff = { |
| 39 |
Doctor = 1, |
| 40 |
} |
| 41 |
room.maximum_staff = room.required_staff |
| 42 |
room.call_sound = "reqd013.wav" |
| 43 |
room.handyman_call_sound = "maint005.wav" |
| 44 |
|
| 45 |
class "XRayRoom" (Room) |
| 46 |
|
| 47 |
---@type XRayRoom |
| 48 |
local XRayRoom = _G["XRayRoom"] |
| 49 |
|
| 50 |
function XRayRoom:XRayRoom(...) |
| 51 |
self:Room(...) |
| 52 |
end |
| 53 |
|
| 54 |
function XRayRoom:commandEnteringPatient(patient) |
| 55 |
local staff = self.staff_member |
| 56 |
local x_ray, pat_x, pat_y = self.world:findObjectNear(patient, "x_ray") |
| 57 |
local console, stf_x, stf_y = self.world:findObjectNear(staff, "radiation_shield") |
| 58 |
|
| 59 |
local --[[persistable:x_ray_shared_loop_callback]] function loop_callback() |
| 60 |
if staff:getCurrentAction().name == "idle" and patient:getCurrentAction().name == "idle" then |
| 61 |
|
| 62 |
local length = math.random(2, 4) * (2 - staff.profile.skill) |
| 63 |
local loop_callback_xray = --[[persistable:x_ray_loop_callback]] function(action) |
| 64 |
if length <= 0 then |
| 65 |
action.prolonged_usage = false |
| 66 |
end |
| 67 |
length = length - 1 |
| 68 |
end |
| 69 |
|
| 70 |
local after_use_xray = --[[persistable:x_ray_after_use]] function() |
| 71 |
staff:setNextAction(MeanderAction()) |
| 72 |
self:dealtWithPatient(patient) |
| 73 |
end |
| 74 |
|
| 75 |
patient:setNextAction(UseObjectAction(x_ray):setLoopCallback(loop_callback_xray) |
| 76 |
:setAfterUse(after_use_xray)) |
| 77 |
staff:setNextAction(UseObjectAction(console)) |
| 78 |
end |
| 79 |
end |
| 80 |
|
| 81 |
patient:walkTo(pat_x, pat_y) |
| 82 |
patient:queueAction(IdleAction():setDirection(x_ray.direction == "north" and "east" or "south") |
| 83 |
:setLoopCallback(loop_callback)) |
| 84 |
|
| 85 |
staff:walkTo(stf_x, stf_y) |
| 86 |
staff:queueAction(IdleAction():setDirection(console.direction == "north" and "east" or "south") |
| 87 |
:setLoopCallback(loop_callback)) |
| 88 |
|
| 89 |
return Room.commandEnteringPatient(self, patient) |
| 90 |
end |
| 91 |
|
| 92 |
return room |