Skyscraper 2.0
elevatordoor.h
Go to the documentation of this file.
1/*
2 Scalable Building Simulator - Elevator Door 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_ELEVATORDOOR_H
25#define _SBS_ELEVATORDOOR_H
26
27namespace SBS {
28
29struct DoorWrapper;
30struct DoorComponent;
31
33{
34public:
35 int Number; //door instance number
36 Elevator *elev; //pointer to associated elevator object
37 ElevatorCar *car; //pointer to associated elevator car object
38 Real OpenSpeed; //door opening/closing speed (for backwards-compatibility only)
39 bool DoorDirection; //if direction is false, doors are on the left/right side
40 int DoorTimer; //door autoclose timer value, in milliseconds
41 int QuickClose; //door quick close autotimer value, in milliseconds
42 Real NudgeTimer; //wait time in seconds before enabling nudge mode
43 std::string OpenSound; //door open sound
44 std::string CloseSound; //door close sound
45 std::string UpChimeSound; //elevator up chime sound
46 std::string DownChimeSound; //elevator down chime sound
47 std::string EarlyUpChimeSound; //elevator early up chime sound
48 std::string EarlyDownChimeSound; //elevator early down chime sound
49 std::string NudgeSound; //nudge mode sound
50 std::string SensorSound; //door sensor sound
51 int OpenDoor; //1=open doors, -1=close doors, 2=open manual, -2=close manual
52 Real ShaftDoorThickness; //thickness of shaft doors (used with AddShaftDoor command) - deprecated
53 Vector3 ShaftDoorOrigin; //shaft door origin (deprecated)
54 Real ManualSpeed; //manual speed multiplier
55 Real SlowSpeed; //slow speed multiplier, mainly for nudge mode
58
59 ElevatorDoor(int number, ElevatorCar* car);
61 void OpenDoorsEmergency(int whichdoors = 1, int floor = 0);
62 void CloseDoorsEmergency(int whichdoors = 1, int floor = 0);
63 void OpenDoors(int whichdoors = 1, int floor = 0, bool manual = false);
64 void CloseDoors(int whichdoors = 1, int floor = 0, bool manual = false);
65 void StopDoors();
66 void Hold(bool sensor = false);
67 void ShaftDoorsEnabled(int floor, bool value);
68 void ShaftDoorsEnabledRange(int floor, int range);
69 bool AreDoorsOpen();
70 bool AreShaftDoorsOpen(int floor);
71 bool AreShaftDoorsClosed(bool skip_current_floor = false);
72 void Reset(bool sensor = false);
73 bool DoorsStopped();
74 DoorWrapper* AddDoors(const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real width, Real height, bool direction, Real tw, Real th);
75 bool AddShaftDoors(const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real voffset, Real tw, Real th);
76 DoorWrapper* AddShaftDoor(int floor, const std::string &lefttexture, const std::string &righttexture, Real tw, Real th);
77 DoorWrapper* AddShaftDoor(int floor, const std::string &lefttexture, const std::string &righttexture, Real thickness, Real CenterX, Real CenterZ, Real voffset, Real tw, Real th);
78 void Chime(int floor, bool direction);
79 void EarlyChime(int floor, bool direction);
80 void Loop();
81 void MoveSound(const Vector3 &position, bool relative_x, bool relative_y, bool relative_z);
82 void Enabled(bool value);
83 bool IsEnabled();
84 void SetShaftDoors(Real thickness, Real CenterX, Real CenterZ);
85 bool ShaftDoorsExist(int floor, bool include_nonserviced = false);
86 int GetWhichDoors();
87 DoorComponent* AddDoorComponent(DoorWrapper *wrapper, const std::string &name, const std::string &meshname, 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);
88 DoorWrapper* AddDoorComponent(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);
89 DoorWrapper* AddShaftDoorComponent(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);
90 void AddShaftDoorsComponent(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);
91 DoorWrapper* FinishDoors(DoorWrapper *wrapper, int floor, bool ShaftDoor, bool DoorWalls = true, bool TrackWalls = true);
92 DoorWrapper* FinishDoors(bool DoorWalls = true, bool TrackWalls = true);
93 DoorWrapper* FinishShaftDoor(int floor, bool DoorWalls = true, bool TrackWalls = true);
94 bool FinishShaftDoors(bool DoorWalls = true, bool TrackWalls = true);
95 DoorWrapper* GetDoorWrapper();
96 DoorWrapper* GetShaftDoorWrapper(int floor);
97 bool TimerIsRunning();
98 void EnableNudgeMode(bool value);
99 bool GetNudgeStatus();
100 int GetManualIndex(int floor);
101 Real GetShaftDoorAltitude(int floor);
102 void CheckSensor();
103 void CreateSensor(Vector3 &area_min, Vector3 &area_max);
104 bool AreDoorsMoving(int doors = 0, bool car_doors = true, bool shaft_doors = true);
105 void EnableSensor(bool value, bool persistent = true);
106 bool GetSensorStatus(bool persistent = true);
107 bool IsSensorBlocked();
108 bool GetHoldStatus();
109 void ResetNudgeTimer(bool start = true);
110 bool AllowNudgeMode();
111 std::string GetNumberText();
112 void ResetState();
113 void RemoveShaftDoor(DoorWrapper *door);
114 void AddServicedFloor(int floor);
115 void RemoveServicedFloor(int floor);
116 bool GetDoorChanged();
117 bool GetPreviousOpen();
118
119private:
120
121 //elevator doors
123
124 //Internal door simulation data
125 int WhichDoors; //which doors are in use; 1 for both, 2 for elevator doors, 3 for shaft doors
126 int ShaftDoorFloor; //floor the active shaft doors are on; only used if WhichDoors is 3
127 std::vector<DoorWrapper*> ShaftDoors; //shaft doors
128 std::vector<int> ManualFloors; //list of floors that use manual shaft doors
129
130 void MoveDoors(bool open, bool manual);
131 int GetIndex(int floor);
132
133 class Timer; //internal timer class
134
135 //autoclose timer object
137
138 //nudge mode timer
140
141 //sound objects
146
147 //door internals
149 int index;
152 bool quick_close; //used if user presses close button while doors are opening; results in a faster timer length
158 bool sensor_enabled; //enable door sensor (active state)
159 bool sensor_status; //persistent sensor on/off state
160
161 //door sensor
165};
166
167}
168
169#endif
std::string OpenSound
std::vector< DoorWrapper * > ShaftDoors
std::string DownChimeSound
DoorWrapper * Doors
ElevatorCar * car
std::string SensorSound
std::string EarlyUpChimeSound
std::string UpChimeSound
std::vector< int > ManualFloors
Vector3 ShaftDoorOrigin
std::string EarlyDownChimeSound
std::string NudgeSound
std::string CloseSound
Ogre::Vector3 Vector3
Definition globals.h:58
Ogre::Real Real
Definition globals.h:57
#define SBSIMPEXP
Definition globals.h:53