Skyscraper 2.0
elevatorcar.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Elevator Car Object
3 The Skyscraper Project - Version 2.0
4 Copyright (C)2004-2024 Ryan Thoryk
5 https://www.skyscrapersim.net
6 https://sourceforge.net/projects/skyscraper/
7 Contact - ryan@skyscrapersim.net
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22*/
23
24#ifndef _SBS_ELEVATORCAR_H
25#define _SBS_ELEVATORCAR_H
26
27#include "doorsystem.h"
28
29namespace SBS {
30
32{
33 friend class Elevator;
34public:
35
36 int Number; //car number
37 std::string Name; //car name
38 std::vector<int> ServicedFloors; //list of floors this car services
39 int NumDoors; //number of elevator doors
40 Real Height; //car height
42 bool Fan; //fan enabled status
43 Vector3 MusicPosition; //music emitter position, relative of elevator center
44 std::vector<int> DisplayFloors; //list of floors to only display when updating floor indicators
45 bool ControlPressActive; //true if a control associated with this elevator has just been pressed
46 bool IsEnabled; //true if car is enabled
47 std::string UpStartSound; //car up start/speedup sound
48 std::string DownStartSound; //car down start/speedup sound
49 std::string UpMoveSound; //car up move sound
50 std::string DownMoveSound; //car down move sound
51 std::string UpStopSound; //car up stop/slowdown sound
52 std::string DownStopSound; //car down stop/slowdown sound
53 std::string IdleSound; //car idle/fan sound
54 std::string AlarmSound; //alarm sound (loop)
55 std::string AlarmSoundStop; //alarm stopping sound
56 std::string BeepSound; //floor beep sound (played when changing floors)
57 std::string FloorSound; //prefix of sounds played when reaching a certain floor; usually used for voices
58 std::string UpMessageSound; //sound to play with message of elevator's direction if going up
59 std::string DownMessageSound; //sound to play with message of elevator's direction if going down
60 std::string OpenMessageSound; //sound to play with message of elevator's doors are opening
61 std::string CloseMessageSound; //sound to play with message of elevator's doors are closing
62 std::string MusicUp; //car up music sound to play
63 std::string MusicDown; //car down music sound to play
64 std::string EmergencyStopSound; //car emergency stop sound
65 bool AlarmActive; //true if alarm is active
66 bool UseFloorBeeps; //true if floor beeps should be used
67 bool UseFloorSounds; //true if floor sounds should be used
68 bool UseDirMessageSounds; //true if direction message sounds should be used
69 bool UseDoorMessageSounds; //true if door message sounds should be used
70 bool MessageOnMove; //true if directional messages should be played when the elevator starts moving, otherwise when the doors open
71 bool MessageOnStart; //this determines if the directional messages should be played at the start or end of the door open sequence
72 bool MessageOnClose; //this determines if the directional messages should be played when the doors are closing
73 bool MusicOn; //music enabled status
74 bool MusicOnMove; //true if music should only play during move
75 bool MusicAlwaysOn; //true if music should always be played, and the on/off state should be volume-based
76 bool AutoEnable; //true if interior objects should automatically be enabled/disabled
77 Real CameraOffset; //camera vertical offset
78 int StartingFloor; //car starting floor
79 bool Created; //has car been created with the CreateCar function?
80 int Offset; //floor number offset from the primary elevator
81 bool GotoFloor; //true if car is heading to a floor
82 int LateDirection; //temporary call direction used for NotifyLate option
83
84 ElevatorCar(Elevator *parent, int number);
86 bool CreateCar(int floor);
87 Elevator* GetElevator();
88 void Report(const std::string &message);
89 bool ReportError(const std::string &message);
90 Wall* AddWall(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real height1, Real height2, Real voffset1, Real voffset2, Real tw, Real th);
91 Wall* AddFloor(const std::string &name, const std::string &texture, Real thickness, Real x1, Real z1, Real x2, Real z2, Real voffset1, Real voffset2, bool reverse_axis, bool texture_direction, Real tw, Real th, bool legacy_behavior = false);
92 FloorIndicator* AddFloorIndicator(const std::string &texture_prefix, const std::string &blank_texture, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset);
93 Indicator* AddKeypadIndicator(const std::string& sound, const std::string& texture_prefix, const std::string& blank_texture, const std::string& direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real timer_duration);
94 ButtonPanel* CreateButtonPanel(const std::string &texture, int rows, int columns, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real spacingX, Real spacingY, Real tw, Real th);
95 void DumpServicedFloors();
96 bool AddServicedFloor(int number, bool create_shaft_door = true);
97 void RemoveServicedFloor(int number, bool remove_shaft_door = true);
98 bool IsServicedFloor(int floor, bool report = true);
99 int GetFloorIndex(int floor);
100 int GetServicedFloorCount();
101 int GetServicedFloor(int index);
102 bool CheckServicedFloors();
103 void Alarm();
104 void OpenHatch();
105 void OnInit();
106 void Loop();
107 void Enabled(bool value);
108 void EnableObjects(bool value);
109 void UpdateFloorIndicators();
110 int GetTopFloor();
111 int GetBottomFloor();
112 void AddDirectionalIndicators(bool relative, bool active_direction, bool single, bool vertical, const std::string &BackTexture, const std::string &uptexture, const std::string &uptexture_lit, const std::string &downtexture, const std::string &downtexture_lit, Real CenterX, Real CenterZ, Real voffset, const std::string &direction, Real BackWidth, Real BackHeight, bool ShowBack, Real tw, Real th);
113 DirectionalIndicator* AddDirectionalIndicator(bool active_direction, bool single, bool vertical, const std::string &BackTexture, const std::string &uptexture, const std::string &uptexture_lit, const std::string &downtexture, const std::string &downtexture_lit, Real CenterX, Real CenterZ, Real voffset, const std::string &direction, Real BackWidth, Real BackHeight, bool ShowBack, Real tw, Real th);
114 void SetDirectionalIndicators(int floor, bool UpLight, bool DownLight);
115 void UpdateDirectionalIndicators();
116 void EnableDirectionalIndicators(bool value);
117 ElevatorDoor* GetDoor(int number);
118 bool OpenDoorsEmergency(int number = 0, int whichdoors = 1, int floor = 0, bool hold = false);
119 void CloseDoorsEmergency(int number = 0, int whichdoors = 1, int floor = 0, bool hold = false);
120 bool OpenDoors(int number = 0, int whichdoors = 1, int floor = 0, bool manual = false, bool hold = false);
121 void CloseDoors(int number = 0, int whichdoors = 1, int floor = 0, bool manual = false, bool hold = false);
122 void StopDoors(int number = 0);
123 void HoldDoors(int number = 0, bool sensor = false);
124 void ShaftDoorsEnabled(int number, int floor, bool value);
125 void ShaftDoorsEnabledRange(int number, int floor, int range);
126 bool AreDoorsOpen(int number = 0);
127 bool AreShaftDoorsOpen(int number, int floor);
128 bool AreShaftDoorsClosed(bool skip_current_floor = false);
129 void ResetDoors(int number = 0, bool sensor = false);
130 bool DoorsStopped(int number = 0);
131 DoorWrapper* AddDoors(int number, const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real width, Real height, bool direction, Real tw, Real th);
132 bool AddShaftDoors(int number, const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real voffset, Real tw, Real th);
133 DoorWrapper* AddShaftDoor(int floor, int number, const std::string &lefttexture, const std::string &righttexture, Real tw, Real th);
134 DoorWrapper* AddShaftDoor(int floor, int number, const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real voffset, Real tw, Real th);
135 void Chime(int number, int floor, bool direction, bool early = false);
136 void EnableDoors(bool value);
137 bool AddFloorSigns(int door_number, bool relative, const std::string &texture_prefix, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset);
138 int AreDoorsMoving(int number = 0, bool car_doors = true, bool shaft_doors = true);
139 bool AreDoorsOpening(int number = 0, bool car_doors = true, bool shaft_doors = true);
140 bool AreDoorsClosing(int number = 0, bool car_doors = true, bool shaft_doors = true);
141 void SetShaftDoors(int number, Real thickness, Real CenterX, Real CenterZ);
142 bool DoorExists(int number);
143 bool ShaftDoorsExist(int number, int floor, bool include_nonserviced = false);
144 Sound* AddSound(const std::string &name, const std::string &filename, Vector3 position, bool loop = true, Real volume = 1.0, int speed = 100, Real min_distance = 1.0, Real max_distance = -1.0, Real doppler_level = 0.0, Real cone_inside_angle = 360, Real cone_outside_angle = 360, Real cone_outside_volume = 1.0, Vector3 direction = Vector3(0, 0, 0));
145 Reverb* AddReverb(const std::string &name, const std::string &type, const Vector3 &position, Real min_distance, Real max_distance);
146 DoorWrapper* AddDoorComponent(int number, const std::string &name, const std::string &texture, const std::string &sidetexture, Real thickness, const std::string &direction, Real OpenSpeed, Real CloseSpeed, Real x1, Real z1, Real x2, Real z2, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th);
147 DoorWrapper* AddShaftDoorComponent(int number, int floor, const std::string &name, const std::string &texture, const std::string &sidetexture, Real thickness, const std::string &direction, Real OpenSpeed, Real CloseSpeed, Real x1, Real z1, Real x2, Real z2, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th);
148 void AddShaftDoorsComponent(int number, const std::string &name, const std::string &texture, const std::string &sidetexture, Real thickness, const std::string &direction, Real OpenSpeed, Real CloseSpeed, Real x1, Real z1, Real x2, Real z2, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th);
149 DoorWrapper* FinishDoors(int number, bool DoorWalls = true, bool TrackWalls = true);
150 DoorWrapper* FinishShaftDoor(int number, int floor, bool DoorWalls = true, bool TrackWalls = true);
151 bool FinishShaftDoors(int number, bool DoorWalls = true, bool TrackWalls = true);
152 ButtonPanel* GetPanel(int index);
153 Control* GetFloorButton(int floor);
154 Door* AddDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool open_state, const std::string &texture, const std::string &side_texture, Real thickness, const std::string &face_direction, const std::string &open_direction, bool rotate, Real open_speed, Real close_speed, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, Real tw, Real th, Real side_tw, Real side_th);
155 Door* CreateDoor(std::string name, const std::string &open_sound, const std::string &close_sound, bool rotate);
156 Door* GetDoor(const std::string &name);
157 Door* GetStdDoor(int number);
158 void RemovePanel(ButtonPanel* panel);
159 void RemoveDirectionalIndicator(DirectionalIndicator *indicator);
160 void RemoveElevatorDoor(ElevatorDoor *door);
161 void RemoveFloorIndicator(FloorIndicator *indicator);
162 void RemoveDoor(Door *door);
163 void RemoveSound(Sound *sound);
164 void RemoveReverb();
165 void RemoveLight(Light *light);
166 void RemoveModel(Model *model);
167 void RemovePrimitive(Primitive *prim);
168 void RemoveCustomObject(CustomObject *object);
169 void RemoveControl(Control *control);
170 void RemoveTrigger(Trigger *trigger);
171 bool IsNudgeModeActive(int number = 0);
172 void EnableNudgeMode(bool value, int number = 0);
173 Light* AddLight(const std::string &name, int type);
174 Light* GetLight(const std::string &name);
175 Model* AddModel(const std::string &name, const std::string &filename, bool center, Vector3 position, Vector3 rotation, Real max_render_distance = 0, Real scale_multiplier = 1, bool enable_physics = false, Real restitution = 0, Real friction = 0, Real mass = 0);
176 void AddModel(Model *model);
177 Primitive* AddPrimitive(const std::string &name);
178 void AddPrimitive(Primitive *primitive);
179 CustomObject* AddCustomObject(const std::string &name, const Vector3 &position, const Vector3 &rotation, Real max_render_distance = 0, Real scale_multiplier = 1);
180 void AddCustomObject(CustomObject *object);
181 void AddDisplayFloor(int floor);
182 Control* AddControl(const std::string &name, const std::string &sound, const std::string &direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset, int selection_position, std::vector<std::string> &action_names, std::vector<std::string> &textures);
183 Trigger* AddTrigger(const std::string &name, const std::string &sound_file, Vector3 &area_min, Vector3 &area_max, std::vector<std::string> &action_names);
184 bool ReplaceTexture(const std::string &oldtexture, const std::string &newtexture);
185 std::vector<Sound*> GetSound(const std::string &name);
186 Reverb* GetReverb();
187 void ResetLights();
188 void ChangeLight(int floor, bool value);
189 void EnableSensor(bool value, int number = 0);
190 bool GetSensorStatus(int number = 0);
191 std::string GetFloorDisplay();
192 bool GetHoldStatus(int number = 0);
193 void ResetNudgeTimer(bool start = true, int number = 0);
194 void ResetDoorState(int number = 0);
195 Model* GetModel(std::string name);
196 Primitive* GetPrimitive(std::string name);
197 CustomObject* GetCustomObject(std::string name);
198 void SetBeepSound(const std::string &filename);
199 void SetFloorSound(const std::string &prefix);
200 void SetMessageSound(bool type, bool direction, const std::string &filename);
201 void SetMusic(const std::string &filename);
202 bool PlayFloorBeep();
203 bool PlayFloorSound();
204 bool PlayMessageSound(bool type);
205 Real SetHeight();
206 bool IsInCar(const Vector3 &position, bool camera = false);
207 bool Check(Vector3 &position);
208 void StopCarSound();
209 int GetFloor();
210 bool OnTopFloor();
211 bool OnBottomFloor();
212 bool InCar();
213 int GetNearestServicedFloor();
214 Real GetDestinationAltitude(int floor);
215 Real GetDestinationOffset(int floor);
216 void SetFloor(int floor, bool move_parent = true);
217 bool IsLeveled();
218 bool IsOnFloor(int floor, bool leveled = true);
219 void NotifyArrival(int floor, bool early = false, int direction = 0);
220 bool IndependentServiceActive();
221 bool IndependentServiceOnOtherCar();
222 int FirePhase2Active();
223 bool FirePhase2OnOtherCar();
224 void SetControls(const std::string &action_name);
225 void FlashIndicators(bool value);
226 CameraTexture* AddCameraTexture(const std::string &name, int quality, Real fov, const Vector3 &position, bool use_rotation, const Vector3 &rotation);
227 void RemoveCameraTexture(CameraTexture* camtex);
228 bool RespondingToCall(int floor, int direction);
229 int RespondingToCall(int floor);
230 bool AddElevatorIDSigns(int door_number, bool relative, const std::string& texture_prefix, const std::string& direction, Real CenterX, Real CenterZ, Real width, Real height, Real voffset);
231
232 MeshObject* Mesh; //car mesh object
233
234 //for keypad
235 std::vector<std::string> InvalidInput;
236 bool Input(const std::string& text);
237 void ProcessCache();
239
240private:
241
243
244 //functions
245 void PlayStartingSounds();
246 void PlayStoppingSounds(bool emergency = false);
247 void PlayMovingSounds();
248
249 //sound objects
254 std::vector<Sound*> sounds; //generic sounds
257 Reverb *reverb; //reverb object
258
259 //interior directional indicators
260 std::vector<DirectionalIndicator*> DirIndicatorArray;
261
262 //doors and shaft doors
263 std::vector<ElevatorDoor*> DoorArray;
264
265 //floor indicators
266 std::vector<FloorIndicator*> FloorIndicatorArray;
267
268 //button panel array
269 std::vector<ButtonPanel*> PanelArray; //elevator button panel objects
270
271 //standard door array
272 std::vector<Door*> StdDoorArray; //pointer array to standard door objects
273
274 //light array
275 std::vector<Light*> lights;
276
277 //Models
278 std::vector<Model*> ModelArray;
279
280 //Primitives
281 std::vector<Primitive*> PrimArray;
282
283 //custom objects
284 std::vector<CustomObject*> CustomObjectArray;
285
286 //Controls
287 std::vector<Control*> ControlArray;
288
289 //Triggers
290 std::vector<Trigger*> TriggerArray;
291
292 //CameraTextures
293 std::vector<CameraTexture*> CameraTextureArray;
294
295 //internal simulation data
296 int CurrentFloor; //current car floor
297
298 //misc internals
299 bool DirMessageSound; //true if a directional message sound is queued, to prevent repeats
300 bool DoorMessageSound; //true if a door message sound is queued, to prevent repeats
303 bool FirstRun; //used for setting first-run items in the run loop
307
308 //internal data for door open/close hold feature
313
314 //cache objects for IsInCar()
318
319 //for keypad
320 std::string InputCache;
321 void UpdateKeypadIndicator(const std::string& text, bool play_sound = true);
323 void KeypadError(bool type = 0);
324 bool GetFloorFromID(const std::string& floor, int& result);
325 void Requested(int floor);
326
327 class KeypadTimer; //internal timer class
328
329 //keypad timer object
331};
332
333}
334
335#endif
ElevatorDoor * lastdoor_result
std::string UpMoveSound
Definition elevatorcar.h:49
std::string DownMoveSound
Definition elevatorcar.h:50
std::vector< CameraTexture * > CameraTextureArray
std::vector< Door * > StdDoorArray
std::string MusicDown
Definition elevatorcar.h:63
std::vector< int > DisplayFloors
Definition elevatorcar.h:44
std::string InputCache
std::string AlarmSound
Definition elevatorcar.h:54
std::string UpStartSound
Definition elevatorcar.h:47
std::vector< int > ServicedFloors
Definition elevatorcar.h:38
bool UseDoorMessageSounds
Definition elevatorcar.h:69
std::string MusicUp
Definition elevatorcar.h:62
std::string OpenMessageSound
Definition elevatorcar.h:60
std::vector< Primitive * > PrimArray
std::string CloseMessageSound
Definition elevatorcar.h:61
Vector3 MusicPosition
Definition elevatorcar.h:43
std::vector< Light * > lights
Elevator * parent
std::vector< CustomObject * > CustomObjectArray
std::vector< DirectionalIndicator * > DirIndicatorArray
std::vector< Trigger * > TriggerArray
std::vector< std::string > InvalidInput
std::string FloorSound
Definition elevatorcar.h:57
std::string EmergencyStopSound
Definition elevatorcar.h:64
std::vector< Control * > ControlArray
std::vector< Sound * > sounds
std::string UpMessageSound
Definition elevatorcar.h:58
MeshObject * Mesh
std::string UpStopSound
Definition elevatorcar.h:51
std::vector< ButtonPanel * > PanelArray
std::vector< Model * > ModelArray
std::string AlarmSoundStop
Definition elevatorcar.h:55
std::string DownMessageSound
Definition elevatorcar.h:59
std::string DownStopSound
Definition elevatorcar.h:52
Indicator * indicator
KeypadTimer * keypad_timer
std::string DownStartSound
Definition elevatorcar.h:48
std::string IdleSound
Definition elevatorcar.h:53
std::string BeepSound
Definition elevatorcar.h:56
std::string Name
Definition elevatorcar.h:37
std::vector< ElevatorDoor * > DoorArray
std::vector< FloorIndicator * > FloorIndicatorArray
void SetMusic(const std::string &filename)
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
#define SBSIMPEXP
Definition globals.h:53