| 1 |
--[[ Copyright (c) 2009 Peter "Corsix" Cawley |
| 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 object = {} |
| 22 |
object.id = "bench" |
| 23 |
object.class = "Bench" |
| 24 |
object.thob = 4 |
| 25 |
object.name = _S.object.bench |
| 26 |
object.tooltip = _S.tooltip.objects.bench |
| 27 |
object.ticks = false |
| 28 |
object.corridor_object = 2 |
| 29 |
object.build_preview_animation = 902 |
| 30 |
object.dynamic_info = true |
| 31 |
object.idle_animations = { |
| 32 |
north = 112, |
| 33 |
east = 114, |
| 34 |
} |
| 35 |
object.walk_in_to_use = true |
| 36 |
object.usage_animations = { |
| 37 |
north = { |
| 38 |
begin_use = { |
| 39 |
["Standard Male Patient" ] = 96, |
| 40 |
["Standard Female Patient" ] = 232, |
| 41 |
["Slack Female Patient" ] = 232, |
| 42 |
["Transparent Male Patient" ] = 1080, |
| 43 |
["Slack Male Patient" ] = 1500, |
| 44 |
["Invisible Patient" ] = 1812, |
| 45 |
["Alternate Male Patient" ] = 2732, |
| 46 |
["Transparent Female Patient"] = 3028, |
| 47 |
["Elvis Patient" ] = 3642, |
| 48 |
["Chewbacca Patient" ] = 3744, |
| 49 |
["Alien Male Patient" ] = 96, -- TEMP |
| 50 |
["Alien Female Patient" ] = 232, -- TEMP |
| 51 |
}, |
| 52 |
in_use = { |
| 53 |
["Standard Male Patient" ] = 146, |
| 54 |
["Standard Female Patient" ] = 224, |
| 55 |
["Slack Female Patient" ] = 224, |
| 56 |
["Transparent Male Patient" ] = 1088, |
| 57 |
["Slack Male Patient" ] = 1508, |
| 58 |
["Invisible Patient" ] = 1820, |
| 59 |
["Alternate Male Patient" ] = 2724, |
| 60 |
["Transparent Female Patient"] = 3036, |
| 61 |
["Chewbacca Patient" ] = 3760, |
| 62 |
["Elvis Patient" ] = 4110, |
| 63 |
["Alien Male Patient" ] = 146, -- TEMP |
| 64 |
["Alien Female Patient" ] = 224, -- TEMP |
| 65 |
}, |
| 66 |
finish_use = { |
| 67 |
["Standard Male Patient" ] = 216, |
| 68 |
["Standard Female Patient" ] = 240, |
| 69 |
["Slack Female Patient" ] = 240, |
| 70 |
["Transparent Male Patient" ] = 1096, |
| 71 |
["Slack Male Patient" ] = 1516, |
| 72 |
["Invisible Patient" ] = 1828, |
| 73 |
["Alternate Male Patient" ] = 2740, |
| 74 |
["Transparent Female Patient"] = 3044, |
| 75 |
["Chewbacca Patient" ] = 3752, |
| 76 |
["Elvis Patient" ] = 4102, |
| 77 |
["Alien Male Patient" ] = 216, -- TEMP |
| 78 |
["Alien Female Patient" ] = 240, -- TEMP |
| 79 |
}, |
| 80 |
}, |
| 81 |
east = { |
| 82 |
begin_use = { |
| 83 |
["Standard Male Patient" ] = 98, |
| 84 |
["Standard Female Patient" ] = 234, |
| 85 |
["Transparent Male Patient" ] = 1082, |
| 86 |
["Slack Female Patient" ] = 234, |
| 87 |
["Slack Male Patient" ] = 1502, |
| 88 |
["Invisible Patient" ] = 1814, |
| 89 |
["Alternate Male Patient" ] = 2734, |
| 90 |
["Transparent Female Patient"] = 3030, |
| 91 |
["Elvis Patient" ] = 3644, |
| 92 |
["Chewbacca Patient" ] = 3746, |
| 93 |
["Alien Male Patient" ] = 98, -- TEMP |
| 94 |
["Alien Female Patient" ] = 234, -- TEMP |
| 95 |
}, |
| 96 |
in_use = { |
| 97 |
["Standard Male Patient" ] = 148, |
| 98 |
["Standard Female Patient" ] = 226, |
| 99 |
["Slack Female Patient" ] = 226, |
| 100 |
["Transparent Male Patient" ] = 1090, |
| 101 |
["Slack Male Patient" ] = 1510, |
| 102 |
["Invisible Patient" ] = 1822, |
| 103 |
["Alternate Male Patient" ] = 2726, |
| 104 |
["Transparent Female Patient"] = 3038, |
| 105 |
["Chewbacca Patient" ] = 3762, |
| 106 |
["Elvis Patient" ] = 4112, |
| 107 |
["Alien Male Patient" ] = 148, -- TEMP |
| 108 |
["Alien Female Patient" ] = 226, -- TEMP |
| 109 |
}, |
| 110 |
finish_use = { |
| 111 |
["Standard Male Patient" ] = 218, |
| 112 |
["Standard Female Patient" ] = 242, |
| 113 |
["Slack Female Patient" ] = 242, |
| 114 |
["Transparent Male Patient" ] = 1098, |
| 115 |
["Slack Male Patient" ] = 1518, |
| 116 |
["Invisible Patient" ] = 1830, |
| 117 |
["Alternate Male Patient" ] = 2742, |
| 118 |
["Transparent Female Patient"] = 3046, |
| 119 |
["Chewbacca Patient" ] = 3754, |
| 120 |
["Elvis Patient" ] = 4104, |
| 121 |
["Alien Male Patient" ] = 218, -- TEMP |
| 122 |
["Alien Female Patient" ] = 242, -- TEMP |
| 123 |
}, |
| 124 |
}, |
| 125 |
} |
| 126 |
object.orientations = { |
| 127 |
north = { |
| 128 |
render_attach_position = { {0, 0}, {-1, 0}, {0, -1} }, |
| 129 |
footprint = { {0, 0, complete_cell = true}, {0, -1, only_passable = true, invisible = true, shareable = true} }, |
| 130 |
use_position = "passable", |
| 131 |
}, |
| 132 |
east = { |
| 133 |
footprint = { {0, 0, complete_cell = true}, {1, 0, only_passable = true, invisible = true, shareable = true} }, |
| 134 |
use_position = "passable", |
| 135 |
}, |
| 136 |
south = { |
| 137 |
footprint = { {0, 0, complete_cell = true}, {0, 1, only_passable = true, invisible = true, shareable = true} }, |
| 138 |
use_position = "passable", |
| 139 |
}, |
| 140 |
west = { |
| 141 |
footprint = { {0, 0, complete_cell = true}, {-1, 0, only_passable = true, invisible = true, shareable = true} }, |
| 142 |
use_position = "passable", |
| 143 |
}, |
| 144 |
} |
| 145 |
|
| 146 |
class "Bench" (Object) |
| 147 |
|
| 148 |
---@type Bench |
| 149 |
local Bench = _G["Bench"] |
| 150 |
|
| 151 |
function Bench:Bench(...) |
| 152 |
self:Object(...) |
| 153 |
end |
| 154 |
|
| 155 |
--Called when the patient sits up from a bench for whatever reason |
| 156 |
--Maybe related to Humanoid:removedObject(object) |
| 157 |
function Bench:removeUser(user) |
| 158 |
if user then |
| 159 |
local has_idle = false |
| 160 |
for _, action in pairs(user.action_queue) do |
| 161 |
if action.name == "idle" then |
| 162 |
has_idle = true |
| 163 |
end |
| 164 |
end |
| 165 |
|
| 166 |
-- patient must idle && action:isStanding() == true at this point |
| 167 |
if has_idle == true then |
| 168 |
user:notifyNewObject("bench") |
| 169 |
end |
| 170 |
end |
| 171 |
|
| 172 |
return Object.removeUser(self, user) |
| 173 |
end |
| 174 |
|
| 175 |
function Bench:resetUsageAndReservaton() |
| 176 |
-- make sure that action:isStanding() will be true, see issue 404 |
| 177 |
if self.user then |
| 178 |
for i, action in pairs(self.user.action_queue) do |
| 179 |
if action.name == "queue" then |
| 180 |
self.user.action_queue[i].current_bench_distance = nil |
| 181 |
end |
| 182 |
end |
| 183 |
end |
| 184 |
|
| 185 |
-- if patient is heading to a bench that is not serving then do the same |
| 186 |
-- things as if they were sitting on it |
| 187 |
if self.reserved_for ~= nil then |
| 188 |
self.reserved_for:handleRemovedObject(self) |
| 189 |
self:removeUser(self.reserved_for) |
| 190 |
end |
| 191 |
Object.resetUsageAndReservaton(self) |
| 192 |
end |
| 193 |
|
| 194 |
--! This function is automatically called after loading a game and serves for compatibility. |
| 195 |
function Bench:afterLoad(old, new) |
| 196 |
if old < 119 then |
| 197 |
self.footprint = object.orientations[self.direction].footprint |
| 198 |
end |
| 199 |
Object.afterLoad(self, old, new) |
| 200 |
end |
| 201 |
|
| 202 |
return object |