| 1 |
--[[ Copyright (c) 2011 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 = "dna_fixer" |
| 23 |
room.vip_must_visit = true |
| 24 |
room.level_config_id = 23 |
| 25 |
room.class = "DNAFixerRoom" |
| 26 |
room.name = _S.rooms_short.dna_fixer |
| 27 |
room.long_name = _S.rooms_long.dna_fixer |
| 28 |
room.tooltip = _S.tooltip.rooms.dna_fixer |
| 29 |
room.objects_additional = { "extinguisher", "radiator", "plant", "bin" } |
| 30 |
room.objects_needed = { dna_fixer = 1, console = 1 } |
| 31 |
room.build_preview_animation = 5070 |
| 32 |
room.categories = { |
| 33 |
clinics = 6, |
| 34 |
} |
| 35 |
room.minimum_size = 5 |
| 36 |
room.wall_type = "blue" |
| 37 |
room.floor_tile = 17 |
| 38 |
room.swing_doors = true |
| 39 |
room.required_staff = { |
| 40 |
Researcher = 1, |
| 41 |
} |
| 42 |
room.maximum_staff = room.required_staff |
| 43 |
room.call_sound = "reqd015.wav" |
| 44 |
room.handyman_call_sound = "maint006.wav" |
| 45 |
|
| 46 |
class "DNAFixerRoom" (Room) |
| 47 |
|
| 48 |
---@type DNAFixerRoom |
| 49 |
local DNAFixerRoom = _G["DNAFixerRoom"] |
| 50 |
|
| 51 |
function DNAFixerRoom:DNAFixerRoom(...) |
| 52 |
self:Room(...) |
| 53 |
end |
| 54 |
|
| 55 |
function DNAFixerRoom:commandEnteringPatient(patient) |
| 56 |
local staff = self.staff_member |
| 57 |
local dna_fixer, pat_x, pat_y = self.world:findObjectNear(patient, "dna_fixer") |
| 58 |
local console, stf_x, stf_y = self.world:findObjectNear(staff, "console") |
| 59 |
|
| 60 |
local --[[persistable:dna_fixer_shared_loop_callback]] function loop_callback() |
| 61 |
-- If the other humanoid has already started to idle we move on |
| 62 |
if staff:getCurrentAction().name == "idle" and patient:getCurrentAction().name == "idle" then |
| 63 |
-- We need to change to another type before starting, to be able |
| 64 |
-- to have different animations depending on gender. |
| 65 |
patient:setType(patient.change_into) |
| 66 |
|
| 67 |
local fixer_after_use = --[[persistable:dna_fixer_after_use]] function() |
| 68 |
self:dealtWithPatient(patient) |
| 69 |
staff:setNextAction(MeanderAction()) |
| 70 |
end |
| 71 |
|
| 72 |
patient:setNextAction(UseObjectAction(dna_fixer):setProlongedUsage(false) |
| 73 |
:setAfterUse(fixer_after_use)) |
| 74 |
staff:setNextAction(UseObjectAction(console)) |
| 75 |
end |
| 76 |
end |
| 77 |
-- As soon as one starts to idle the callback is called to see if the other one is already idling. |
| 78 |
patient:walkTo(pat_x, pat_y) |
| 79 |
patient:queueAction(IdleAction():setDirection(dna_fixer.direction == "north" and "north" or "west") |
| 80 |
:setLoopCallback(loop_callback)) |
| 81 |
|
| 82 |
staff:walkTo(stf_x, stf_y) |
| 83 |
staff:queueAction(IdleAction():setDirection(console.direction == "north" and "north" or "west") |
| 84 |
:setLoopCallback(loop_callback)) |
| 85 |
|
| 86 |
return Room.commandEnteringPatient(self, patient) |
| 87 |
end |
| 88 |
|
| 89 |
return room |