This repository has been archived by the owner on Feb 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy pathDOOR.CPP
202 lines (185 loc) · 11.8 KB
/
DOOR.CPP
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
198
199
200
201
202
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\door.cpv 1.4 16 Oct 1995 16:49:16 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : DOOR.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : 06/11/95 *
* *
* Last Update : June 14, 1995 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* DoorClass::AI -- Handles the door processing logic. *
* DoorClass::Close_Door -- Try to close the unit's door. *
* DoorClass::DoorClass -- Constructor for the DoorClass object. *
* DoorClass::Door_Stage -- Fetches the current door animation frame. *
* DoorClass::Open_Door -- Opens the door for this unit. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
/***********************************************************************************************
* DoorClass::DoorClass -- Constructor for the DoorClass object. *
* *
* This constructor sets the door to an initial closed state. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/14/1995 JLB : Created. *
*=============================================================================================*/
DoorClass::DoorClass(void)
{
State = IS_CLOSED;
IsToRedraw = false;
Stages = 0;
}
/***********************************************************************************************
* DoorClass::AI -- Handles the door processing logic. *
* *
* This routine should be called every game frame. It handles the door closing and opening *
* logic. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/13/1995 JLB : Created. *
*=============================================================================================*/
void DoorClass::AI(void)
{
if (Control.Graphic_Logic()) {
if (Control.Fetch_Stage() >= Stages) {
Control.Set_Rate(0);
switch (State) {
case IS_OPENING:
State = IS_OPEN;
break;
case IS_CLOSING:
State = IS_CLOSED;
break;
}
}
IsToRedraw = true;
}
}
/***********************************************************************************************
* DoorClass::Open_Door -- Opens the door for this unit. *
* *
* This routine will perform the door open operation for this unit. It will control vehicle *
* rotation if necessary. *
* *
* INPUT: rate -- The animation rate (delay) to use for the door animation logic. *
* *
* stages -- The number of animations stages that this door must pass through. *
* *
* OUTPUT: Was action initiated to open the door? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/08/1995 JLB : Created. *
*=============================================================================================*/
bool DoorClass::Open_Door(int rate, int stages)
{
switch (State) {
case IS_CLOSED:
case IS_CLOSING:
State = IS_OPENING;
Stages = stages-1;
Control.Set_Stage(0);
Control.Set_Rate(rate);
return(true);
}
return(false);
}
/***********************************************************************************************
* DoorClass::Close_Door -- Try to close the unit's door. *
* *
* This routine will attempt to close the unit's door. If the door is already closed or *
* in the process of closing, then no action is performed. *
* *
* INPUT: rate -- The animation rate (delay) to use for the door animation logic. *
* *
* stages -- The number of animations stages that this door must pass through. *
* *
* OUTPUT: Action was initiated to close the door? *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 05/08/1995 JLB : Created. *
*=============================================================================================*/
bool DoorClass::Close_Door(int rate, int stages)
{
switch (State) {
case IS_OPEN:
case IS_OPENING:
State = IS_CLOSING;
Stages = stages-1;
Control.Set_Stage(0);
Control.Set_Rate(rate);
return(true);
}
return(false);
}
/***********************************************************************************************
* DoorClass::Door_Stage -- Fetches the current door animation frame. *
* *
* Use this routine to fetch the current door animation frame number. Frame zero is the *
* closed frame and frame 'N' is the open frame. If the door is in the process of opening *
* or closing, the appropriate frame number is used. 'N' is defined as the number of *
* stages in the animation minus 1 (e.g., a four frame animation will return a door stage *
* number between 0 and 3, inclusive). *
* *
* INPUT: none *
* *
* OUTPUT: Returns with the door animation frame number. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/14/1995 JLB : Created. *
*=============================================================================================*/
int DoorClass::Door_Stage(void) const
{
switch (State) {
case IS_CLOSING:
return((Stages-1) - Control.Fetch_Stage());
case IS_CLOSED:
return(0);
case IS_OPENING:
return(Control.Fetch_Stage());
case IS_OPEN:
return(Stages-1);
}
return(0);
}