Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/CEffector.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3 - (show annotations) (download) (as text)
Tue Nov 23 14:34:03 2010 UTC (13 years, 5 months ago) by okadu
File MIME type: text/x-c++src
File size: 8854 byte(s)
[okadu] Version 2.13
1 #include "stdafx.h"
2 #include "CModelPlugin.h"
3 #include "CStation.h"
4 #include "CRailWay.h"
5
6 // 外部グローバル
7 extern CScene *g_Scene;
8
9 // 内部グローバル
10 CHeadlight g_TempHeadlight;
11 CParticle g_TempParticle;
12 CSoundEffector g_TempSoundEffector;
13
14 /*
15 * コンストラクタ
16 */
17 CEffectorContainer::CEffectorContainer(){
18 m_Effector = NULL;
19 }
20
21 /*
22 * コピーコンストラクタ
23 */
24 CEffectorContainer::CEffectorContainer(
25 const CEffectorContainer &src // コピー元
26 ){
27 m_Effector = src.m_Effector->Duplicate();
28 }
29
30 /*
31 * デストラクタ
32 */
33 CEffectorContainer::~CEffectorContainer(){
34 DELETE_V(m_Effector);
35 }
36
37 /*
38 * 読込
39 */
40 char *CEffectorContainer::Read(
41 char *str, // 対象文字列
42 CModelPlugin *mpi // モデルプラグイン
43 ){
44 char *tmp;
45 bool is_station = !strcmp(mpi->DirName(), "Station");
46 DELETE_V(m_Effector);
47 CHeadlightApplier headlightapplier;
48 CParticleApplier particleapplier;
49 CSoundApplier soundapplier;
50 CEffectorRailConnector effectorrailconnector;
51 CEffectorRailBrancher effectorrailbrancher;
52 CEffectorRailDisconnector effectorraildisconnector;
53 CEffectorSwitchApplier effectorswitchapplier;
54 if(tmp = headlightapplier.Read(str, mpi)){
55 str = tmp;
56 m_Effector = new CHeadlightApplier(headlightapplier);
57 }else if(tmp = particleapplier.Read(str, mpi)){
58 str = tmp;
59 m_Effector = new CParticleApplier(particleapplier);
60 }else if(tmp = soundapplier.Read(str, mpi)){
61 str = tmp;
62 m_Effector = new CSoundApplier(soundapplier);
63 }else if(is_station && (tmp = effectorrailconnector.Read(str, mpi))){
64 str = tmp;
65 m_Effector = new CEffectorRailConnector(effectorrailconnector);
66 }else if(is_station && (tmp = effectorrailbrancher.Read(str, mpi))){
67 str = tmp;
68 m_Effector = new CEffectorRailBrancher(effectorrailbrancher);
69 }else if(is_station && (tmp = effectorraildisconnector.Read(str, mpi))){
70 str = tmp;
71 m_Effector = new CEffectorRailDisconnector(effectorraildisconnector);
72 }else if(tmp = effectorswitchapplier.Read(str, mpi)){
73 str = tmp;
74 m_Effector = new CEffectorSwitchApplier(effectorswitchapplier);
75 }else{
76 str = NULL;
77 }
78 return str;
79 }
80
81 ////////////////////////////////////////////////////////////////////////////////
82 ////////////////////////////////////////////////////////////////////////////////
83
84 /*
85 * 読込
86 */
87 char *CHeadlightApplier::Read(
88 char *str, // 対象文字列
89 CModelPlugin *mpi // モデルプラグイン
90 ){
91 if(!(str = g_TempHeadlight.Read(str, mpi))) return NULL;
92 m_Headlight = mpi->AddHeadlight(g_TempHeadlight);
93 return str;
94 }
95
96 /*
97 * データ読込
98 */
99 void CHeadlightApplier::LoadDataEffector(
100 CModelPlugin *mpi // 呼び出し元
101 ){
102 m_Headlight->LoadData();
103 }
104
105 /*
106 * 変更子適用
107 */
108 void CHeadlightApplier::ApplyEffector(
109 CScene *scene // シーン
110 ){
111 if(!g_PreSimulationFlag && (!scene || scene==g_Scene)) m_Headlight->Register();
112 }
113
114 ////////////////////////////////////////////////////////////////////////////////
115 ////////////////////////////////////////////////////////////////////////////////
116
117 /*
118 * 読込
119 */
120 char *CParticleApplier::Read(
121 char *str, // 対象文字列
122 CModelPlugin *mpi // モデルプラグイン
123 ){
124 if(!(str = g_TempParticle.Read(str, mpi))) return NULL;
125 m_Particle = mpi->AddParticle(g_TempParticle);
126 return str;
127 }
128
129 /*
130 * データ読込
131 */
132 void CParticleApplier::LoadDataEffector(
133 CModelPlugin *mpi // 呼び出し元
134 ){
135 m_Particle->LoadData();
136 }
137
138 /*
139 * 変更子適用
140 */
141 void CParticleApplier::ApplyEffector(
142 CScene *scene // シーン
143 ){
144 if(g_PreSimulationFlag) m_Particle->Register(scene);
145 }
146
147 ////////////////////////////////////////////////////////////////////////////////
148 ////////////////////////////////////////////////////////////////////////////////
149
150 /*
151 * 読込
152 */
153 char *CSoundApplier::Read(
154 char *str, // 対象文字列
155 CModelPlugin *mpi // モデルプラグイン
156 ){
157 if(!(str = g_TempSoundEffector.Read(str, mpi))) return NULL;
158 m_SoundEffector = mpi->AddSoundEffector(g_TempSoundEffector);
159 return str;
160 }
161
162 /*
163 * 変更子適用
164 */
165 void CSoundApplier::ApplyEffector(
166 CScene *scene // シーン
167 ){
168 if(!g_PreSimulationFlag) m_SoundEffector->Register(scene);
169 }
170
171 ////////////////////////////////////////////////////////////////////////////////
172 ////////////////////////////////////////////////////////////////////////////////
173
174 void CEffectorRailConnectorBase::CalculatePlatformID(){
175 if(m_RailEnd1>=0){
176 m_PlatformID1 = m_RailEnd1/2;
177 m_PlatformEnd1 = m_RailEnd1%2;
178 }
179 if(m_RailEnd2>=0){
180 m_PlatformID2 = m_RailEnd2/2;
181 m_PlatformEnd2 = m_RailEnd2%2;
182 }
183 }
184
185 /*
186 * 変更子適用
187 */
188 void CEffectorRailConnectorBase::ApplyEffector(
189 CScene *scene // シーン
190 ){
191 if(m_RailEnd1<0 || m_RailEnd2<0) return;
192 if(g_PreSimulationFlag){
193 CStation *station = (CStation *)CModelInst::GetCurrentInst();
194 int pn = station->GetPlatformCount();
195 if(m_PlatformID1>=pn || m_PlatformID2>=pn) return;
196 CPlatformInst *pf1 = station->GetPlatformInst(m_PlatformID1);
197 CPlatformInst *pf2 = station->GetPlatformInst(m_PlatformID2);
198 CRailWay *rail1 = m_PlatformEnd1 ? pf1->GetRailWayBack() : pf1->GetRailWayFront();
199 CRailWay *rail2 = m_PlatformEnd2 ? pf2->GetRailWayBack() : pf2->GetRailWayFront();
200 if(!rail1 || !rail2) return;//ErrorDialog("INTERNAL ERROR: RAIL CONNECTOR FAILED.");
201 ApplyEffectorRailConnectorBase(scene, rail1, rail2);
202 }
203 }
204
205 ////////////////////////////////////////////////////////////////////////////////
206 ////////////////////////////////////////////////////////////////////////////////
207
208 void CEffectorRailDisconnectorBase::CalculatePlatformID(){
209 if(m_RailEnd>=0){
210 m_PlatformID = m_RailEnd/2;
211 m_PlatformEnd = m_RailEnd%2;
212 }
213 }
214
215 /*
216 * 変更子適用
217 */
218 void CEffectorRailDisconnectorBase::ApplyEffector(
219 CScene *scene // シーン
220 ){
221 if(m_RailEnd<0) return;
222 if(g_PreSimulationFlag){
223 CStation *station = (CStation *)CModelInst::GetCurrentInst();
224 int pn = station->GetPlatformCount();
225 if(m_PlatformID>=pn) return;
226 CPlatformInst *pf = station->GetPlatformInst(m_PlatformID);
227 CRailWay *rail = m_PlatformEnd ? pf->GetRailWayBack() : pf->GetRailWayFront();
228 if(!rail) return;//ErrorDialog("INTERNAL ERROR: RAIL DISCONNECTOR FAILED.");
229 ApplyEffectorRailDisconnectorBase(scene, rail);
230 }
231 }
232
233 ////////////////////////////////////////////////////////////////////////////////
234 ////////////////////////////////////////////////////////////////////////////////
235
236 /*
237 * 読込
238 */
239 char *CEffectorRailConnector::Read(
240 char *str, // 対象文字列
241 CModelPlugin *mpi // 呼び出し元
242 ){
243 char *eee;
244 if(!(str = Assignment(str, "ConnectRail"))) return NULL;
245 if(!(str = ConstInteger(eee = str, &m_RailEnd1))) throw CSynErr(eee);
246 if(!(str = Character2(eee = str, ','))) throw CSynErr(eee);
247 if(!(str = ConstInteger(eee = str, &m_RailEnd2))) throw CSynErr(eee);
248 if(!(str = Character2(eee = str, ';'))) throw CSynErr(eee);
249 CalculatePlatformID();
250 return str;
251 }
252
253 /*
254 * 変更子適用
255 */
256 void CEffectorRailConnector::ApplyEffectorRailConnectorBase(
257 CScene *scene, // シーン
258 CRailWay *rail1, // レール1
259 CRailWay *rail2 // レール2
260 ){
261 rail1->ConnectRailWay(m_PlatformEnd1, rail2, m_PlatformEnd2, scene);
262 }
263
264 ////////////////////////////////////////////////////////////////////////////////
265 ////////////////////////////////////////////////////////////////////////////////
266
267 /*
268 * 読込
269 */
270 char *CEffectorRailBrancher::Read(
271 char *str, // 対象文字列
272 CModelPlugin *mpi // 呼び出し元
273 ){
274 char *eee;
275 if(!(str = Assignment(str, "BranchRail"))) return NULL;
276 if(!(str = ConstInteger(eee = str, &m_RailEnd1))) throw CSynErr(eee);
277 if(!(str = Character2(eee = str, ','))) throw CSynErr(eee);
278 if(!(str = ConstInteger(eee = str, &m_RailEnd2))) throw CSynErr(eee);
279 if(!(str = Character2(eee = str, ';'))) throw CSynErr(eee);
280 CalculatePlatformID();
281 return str;
282 }
283
284 /*
285 * 変更子適用
286 */
287 void CEffectorRailBrancher::ApplyEffectorRailConnectorBase(
288 CScene *scene, // シーン
289 CRailWay *rail1, // レール1
290 CRailWay *rail2 // レール2
291 ){
292 rail1->BranchRailWay(m_PlatformEnd1, rail2, m_PlatformEnd2, scene);
293 }
294
295 ////////////////////////////////////////////////////////////////////////////////
296 ////////////////////////////////////////////////////////////////////////////////
297
298 /*
299 * 読込
300 */
301 char *CEffectorRailDisconnector::Read(
302 char *str, // 対象文字列
303 CModelPlugin *mpi // 呼び出し元
304 ){
305 char *eee;
306 if(!(str = Assignment(str, "DisconnectRail"))) return NULL;
307 if(!(str = ConstInteger(eee = str, &m_RailEnd))) throw CSynErr(eee);
308 if(!(str = Character2(eee = str, ';'))) throw CSynErr(eee);
309 CalculatePlatformID();
310 return str;
311 }
312
313 /*
314 * 変更子適用
315 */
316 void CEffectorRailDisconnector::ApplyEffectorRailDisconnectorBase(
317 CScene *scene, // シーン
318 CRailWay *rail // レール
319 ){
320 rail->DisconnectRailWay(m_PlatformEnd, scene);
321 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26