Debian Codegraph @

CorsixTH/Lua/entities/humanoids/staff/receptionist.lua

raw
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 corsixth.require("announcer")
22 corsixth.require("entities.humanoids.staff")
23
24 local AnnouncementPriority = _G["AnnouncementPriority"]
25
26 --! A Doctor, Nurse, Receptionist, Handyman, or Surgeon
27 class "Receptionist" (Staff)
28
29 ---@type Receptionist
30 local Receptionist = _G["Receptionist"]
31
32 --!param ... Arguments to base class constructor.
33 function Receptionist:Receptionist(...)
34 self:Staff(...)
35 self.leave_sounds = {"sack007.wav", "sack008.wav"}
36 self.leave_priority = AnnouncementPriority.Critical -- must always be played even without receptionist
37 end
38
39 function Receptionist:tickDay()
40 if not Staff.tickDay(self) then
41 return false
42 end
43 self:needsWorkStation()
44 end
45
46 function Receptionist:isTiring()
47 return false
48 end
49
50 function Receptionist:isResting()
51 return false
52 end
53
54 function Receptionist:setProfile(profile)
55 Staff.setProfile(self, profile)
56 self.attributes["fatigue"] = nil
57 end
58
59 function Receptionist:needsWorkStation()
60 if self.hospital then
61 self.hospital:msgNeedFirstReceptionDesk()
62 end
63 end
64
65 -- Receptionists do not need rest
66 function Receptionist:checkIfNeedRest()
67 return
68 end
69
70 function Receptionist:onPlaceInCorridor()
71 Staff.onPlaceInCorridor(self)
72
73 local world = self.world
74 world:findObjectNear(self, "reception_desk", nil, true, function(x, y)
75 local obj = world:getObject(x, y, "reception_desk")
76 return obj and obj:occupy(self)
77 end)
78 self.hospital:buildReceptionDesksCache() -- Rebuild cache of staffed desks
79 end
80
81
82 -- Helper function to decide if Staff fulfills a criterion
83 -- (one of "Doctor", "Nurse", "Psychiatrist", "Surgeon", "Researcher" and "Handyman", "Receptionist", "Junior", "Consultant")
84 function Receptionist:fulfillsCriterion(criterion)
85 return criterion == "Receptionist"
86 end
87
88 function Receptionist:getDrawingLayer()
89 local direction = self.last_move_direction
90 if direction == "west" or direction == "north" then
91 return DrawingLayers.ReceptionistFacingAway
92 end
93 return DrawingLayers.ReceptionistFacingUser
94 end
95
96 function Receptionist:onPickup()
97 Staff.onPickup(self)
98 self.hospital:buildReceptionDesksCache() -- Rebuild cache of staffed desks
99 end
100
101 function Receptionist:fire()
102 Staff.fire(self)
103 self.hospital:buildReceptionDesksCache() -- Rebuild cache of staffed desks
104 end
105
106 function Receptionist:afterLoad(old, new)
107 if old < 163 then
108 self.leave_sounds = {"sack007.wav", "sack008.wav"}
109 self.leave_priority = AnnouncementPriority.Critical -- must always be played even without receptionist
110 end
111 Staff.afterLoad(self, old, new)
112 end