forked from CorsixTH/CorsixTH
/
bench.lua
197 lines (182 loc) · 6.8 KB
/
bench.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
--[[ Copyright (c) 2009 Peter "Corsix" Cawley
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 object = {}
object.id = "bench"
object.class = "Bench"
object.thob = 4
object.name = _S.object.bench
object.tooltip = _S.tooltip.objects.bench
object.ticks = false
object.corridor_object = 2
object.build_preview_animation = 902
object.dynamic_info = true
object.idle_animations = {
north = 112,
east = 114,
}
object.walk_in_to_use = true
object.usage_animations = {
north = {
begin_use = {
["Standard Male Patient" ] = 96,
["Standard Female Patient" ] = 232,
["Slack Female Patient" ] = 232,
["Transparent Male Patient" ] = 1080,
["Slack Male Patient" ] = 1500,
["Invisible Patient" ] = 1812,
["Alternate Male Patient" ] = 2732,
["Transparent Female Patient"] = 3028,
["Elvis Patient" ] = 3642,
["Chewbacca Patient" ] = 3744,
["Alien Male Patient" ] = 96, -- TEMP
["Alien Female Patient" ] = 232, -- TEMP
},
in_use = {
["Standard Male Patient" ] = 146,
["Standard Female Patient" ] = 224,
["Slack Female Patient" ] = 224,
["Transparent Male Patient" ] = 1088,
["Slack Male Patient" ] = 1508,
["Invisible Patient" ] = 1820,
["Alternate Male Patient" ] = 2724,
["Transparent Female Patient"] = 3036,
["Chewbacca Patient" ] = 3760,
["Elvis Patient" ] = 4110,
["Alien Male Patient" ] = 146, -- TEMP
["Alien Female Patient" ] = 224, -- TEMP
},
finish_use = {
["Standard Male Patient" ] = 216,
["Standard Female Patient" ] = 240,
["Slack Female Patient" ] = 240,
["Transparent Male Patient" ] = 1096,
["Slack Male Patient" ] = 1516,
["Invisible Patient" ] = 1828,
["Alternate Male Patient" ] = 2740,
["Transparent Female Patient"] = 3044,
["Chewbacca Patient" ] = 3752,
["Elvis Patient" ] = 4102,
["Alien Male Patient" ] = 216, -- TEMP
["Alien Female Patient" ] = 240, -- TEMP
},
},
east = {
begin_use = {
["Standard Male Patient" ] = 98,
["Standard Female Patient" ] = 234,
["Transparent Male Patient" ] = 1082,
["Slack Female Patient" ] = 234,
["Slack Male Patient" ] = 1502,
["Invisible Patient" ] = 1814,
["Alternate Male Patient" ] = 2734,
["Transparent Female Patient"] = 3030,
["Elvis Patient" ] = 3644,
["Chewbacca Patient" ] = 3746,
["Alien Male Patient" ] = 98, -- TEMP
["Alien Female Patient" ] = 234, -- TEMP
},
in_use = {
["Standard Male Patient" ] = 148,
["Standard Female Patient" ] = 226,
["Slack Female Patient" ] = 226,
["Transparent Male Patient" ] = 1090,
["Slack Male Patient" ] = 1510,
["Invisible Patient" ] = 1822,
["Alternate Male Patient" ] = 2726,
["Transparent Female Patient"] = 3038,
["Chewbacca Patient" ] = 3762,
["Elvis Patient" ] = 4112,
["Alien Male Patient" ] = 148, -- TEMP
["Alien Female Patient" ] = 226, -- TEMP
},
finish_use = {
["Standard Male Patient" ] = 218,
["Standard Female Patient" ] = 242,
["Slack Female Patient" ] = 242,
["Transparent Male Patient" ] = 1098,
["Slack Male Patient" ] = 1518,
["Invisible Patient" ] = 1830,
["Alternate Male Patient" ] = 2742,
["Transparent Female Patient"] = 3046,
["Chewbacca Patient" ] = 3754,
["Elvis Patient" ] = 4104,
["Alien Male Patient" ] = 218, -- TEMP
["Alien Female Patient" ] = 242, -- TEMP
},
},
}
object.orientations = {
north = {
render_attach_position = { {0, 0}, {-1, 0}, {0, -1} },
footprint = { {0, 0, complete_cell = true}, {0, -1, only_passable = true, invisible = true, shareable = true} },
use_position = "passable",
},
east = {
footprint = { {0, 0, complete_cell = true}, {1, 0, only_passable = true, invisible = true, shareable = true} },
use_position = "passable",
},
south = {
footprint = { {0, 0, complete_cell = true}, {0, 1, only_passable = true, invisible = true, shareable = true} },
use_position = "passable",
},
west = {
footprint = { {0, 0, complete_cell = true}, {-1, 0, only_passable = true, invisible = true, shareable = true} },
use_position = "passable",
},
}
class "Bench" (Object)
---@type Bench
local Bench = _G["Bench"]
function Bench:Bench(...)
self:Object(...)
end
--Called when the patient sits up from a bench for whatever reason
--Maybe related to Humanoid:removedObject(object)
function Bench:removeUser(user)
if user then
local has_idle = false
for i, action in pairs(user.action_queue) do
if action.name == "idle" then
has_idle = true
end
end
-- patient must idle && action:isStanding() == true at this point
if has_idle == true then
user:notifyNewObject("bench")
end
end
return Object.removeUser(self, user)
end
--Called when the player picks up a bench
function Bench:onDestroy()
-- make sure that action:isStanding() will be true, see issue 404
if self.user then
for i, action in pairs(self.user.action_queue) do
if action.name == "queue" then
self.user.action_queue[i].current_bench_distance = nil
end
end
end
-- if patient is heading for the destroyed bench then do the same
-- things as if they were sitting on it
if self.reserved_for ~= nil then
self.reserved_for:handleRemovedObject(self)
self:removeUser(self.reserved_for)
end
Object.onDestroy(self)
end
return object