-
Notifications
You must be signed in to change notification settings - Fork 354
/
dna_fixer.lua
89 lines (75 loc) · 3.38 KB
/
dna_fixer.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--[[ Copyright (c) 2011 Manuel "Roujin" Wolf
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. --]]
local room = {}
room.id = "dna_fixer"
room.vip_must_visit = true
room.level_config_id = 23
room.class = "DNAFixerRoom"
room.name = _S.rooms_short.dna_fixer
room.long_name = _S.rooms_long.dna_fixer
room.tooltip = _S.tooltip.rooms.dna_fixer
room.objects_additional = { "extinguisher", "radiator", "plant", "bin" }
room.objects_needed = { dna_fixer = 1, console = 1 }
room.build_preview_animation = 5070
room.categories = {
clinics = 6,
}
room.minimum_size = 5
room.wall_type = "blue"
room.floor_tile = 17
room.swing_doors = true
room.required_staff = {
Researcher = 1,
}
room.maximum_staff = room.required_staff
room.call_sound = "reqd015.wav"
room.handyman_call_sound = "maint006.wav"
class "DNAFixerRoom" (Room)
---@type DNAFixerRoom
local DNAFixerRoom = _G["DNAFixerRoom"]
function DNAFixerRoom:DNAFixerRoom(...)
self:Room(...)
end
function DNAFixerRoom:commandEnteringPatient(patient)
local staff = self.staff_member
local dna_fixer, pat_x, pat_y = self.world:findObjectNear(patient, "dna_fixer")
local console, stf_x, stf_y = self.world:findObjectNear(staff, "console")
local --[[persistable:dna_fixer_shared_loop_callback]] function loop_callback()
-- If the other humanoid has already started to idle we move on
if staff:getCurrentAction().name == "idle" and patient:getCurrentAction().name == "idle" then
-- We need to change to another type before starting, to be able
-- to have different animations depending on gender.
patient:setType(patient.change_into)
local fixer_after_use = --[[persistable:dna_fixer_after_use]] function()
self:dealtWithPatient(patient)
staff:setNextAction(MeanderAction())
end
patient:setNextAction(UseObjectAction(dna_fixer):setProlongedUsage(false)
:setAfterUse(fixer_after_use))
staff:setNextAction(UseObjectAction(console))
end
end
-- As soon as one starts to idle the callback is called to see if the other one is already idling.
patient:walkTo(pat_x, pat_y)
patient:queueAction(IdleAction():setDirection(dna_fixer.direction == "north" and "north" or "west")
:setLoopCallback(loop_callback))
staff:walkTo(stf_x, stf_y)
staff:queueAction(IdleAction():setDirection(console.direction == "north" and "north" or "west")
:setLoopCallback(loop_callback))
return Room.commandEnteringPatient(self, patient)
end
return room