124 {
125
131
133
134 m_abilities.Insert(
new AbilityRecord(
WeaponActions.MECHANISM, GetWeaponSpecificCommand(
WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED)));
135
138
142
143
144
145
146
147
156
157
158 WeaponStateBase Mech_C00 =
new WeaponCharging(
this, NULL,
WeaponActions.MECHANISM, GetWeaponSpecificCommand(
WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
159 WeaponStateBase Mech_C01 =
new WeaponCharging(
this, NULL,
WeaponActions.MECHANISM, GetWeaponSpecificCommand(
WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
160 WeaponStateBase Mech_C10 =
new WeaponCharging(
this, NULL,
WeaponActions.MECHANISM, GetWeaponSpecificCommand(
WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
161 WeaponStateBase Mech_C11 =
new WeaponCharging(
this, NULL,
WeaponActions.MECHANISM, GetWeaponSpecificCommand(
WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
162 WeaponStateBase Mech_CF0 =
new WeaponCharging(
this, NULL,
WeaponActions.MECHANISM, GetWeaponSpecificCommand(
WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
163 WeaponStateBase Mech_CF1 =
new WeaponCharging(
this, NULL,
WeaponActions.MECHANISM, GetWeaponSpecificCommand(
WeaponActions.MECHANISM, WeaponActionMechanismTypes.MECHANISM_CLOSED));
164
173
174
177
180
181
186
191
196
201
202
203
204
217
218 m_fsm = new WeaponFSM();
219
220
221
225
227 m_fsm.AddTransition(
new WeaponTransition( Mech_C10, _fin_,
C00, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
229 m_fsm.AddTransition(
new WeaponTransition( Mech_C10, _abt_,
C00, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
231
233 m_fsm.AddTransition(
new WeaponTransition( Mech_CF0, _fin_,
CF0, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
235 m_fsm.AddTransition(
new WeaponTransition( Mech_CF0, _abt_,
CF0, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
237
239 m_fsm.AddTransition(
new WeaponTransition( Mech_C11, _fin_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
241 m_fsm.AddTransition(
new WeaponTransition( Mech_C11, _abt_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
243
245 m_fsm.AddTransition(
new WeaponTransition( Mech_C01, _fin_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
247 m_fsm.AddTransition(
new WeaponTransition( Mech_C01, _abt_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
249
251 m_fsm.AddTransition(
new WeaponTransition( Mech_CF1, _fin_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
252 m_fsm.AddTransition(
new WeaponTransition( Mech_CF1, _fin_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
254 m_fsm.AddTransition(
new WeaponTransition( Mech_CF1, _abt_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
255 m_fsm.AddTransition(
new WeaponTransition( Mech_CF1, _abt_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
257
258
263
268
273
278
283
288
293
298
303
308
309
310
312 m_fsm.AddTransition(
new WeaponTransition( Chamber_C00, _fin_,
C00, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
314 m_fsm.AddTransition(
new WeaponTransition( Chamber_C00, _abt_,
C00, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
316
318 m_fsm.AddTransition(
new WeaponTransition( Chamber_C01, _fin_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
320 m_fsm.AddTransition(
new WeaponTransition( Chamber_C01, _abt_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
322
324 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF0, _fin_,
CF0, NULL,
new WeaponGuardCurrentChamberFiredOut(
this) ));
325 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF0, _fin_,
C00, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
327 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF0, _abt_,
CF0, NULL,
new WeaponGuardCurrentChamberFiredOut(
this) ));
328 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF0, _abt_,
C00, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
330
332 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF1, _fin_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this) ));
333 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF1, _fin_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
335 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF1, _abt_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this) ));
336 m_fsm.AddTransition(
new WeaponTransition( Chamber_CF1, _abt_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this) ));
338
339
340 m_fsm.AddTransition(
new WeaponTransition(
C00, __A__, Attach_C00, NULL,
new WeaponGuardCanAttachMag(
this)));
341 m_fsm.AddTransition(
new WeaponTransition( Attach_C00, _fin_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
342 m_fsm.AddTransition(
new WeaponTransition( Attach_C00, _fin_,
C01, NULL,
new WeaponGuardHasMag(
this)));
344 m_fsm.AddTransition(
new WeaponTransition( Attach_C00, _abt_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
345 m_fsm.AddTransition(
new WeaponTransition( Attach_C00, _abt_,
C01, NULL,
new WeaponGuardHasMag(
this)));
347
348 m_fsm.AddTransition(
new WeaponTransition(
C10, __A__, Attach_C10, NULL,
new WeaponGuardCanAttachMag(
this)));
349 m_fsm.AddTransition(
new WeaponTransition( Attach_C10, _fin_,
C11, NULL,
new WeaponGuardHasMag(
this)));
351 m_fsm.AddTransition(
new WeaponTransition( Attach_C10, _abt_,
C11, NULL,
new WeaponGuardHasMag(
this)));
353
354
355 m_fsm.AddTransition(
new WeaponTransition(
CF0, __A__, Attach_CF0, NULL,
new WeaponGuardCanAttachMag(
this)));
356 m_fsm.AddTransition(
new WeaponTransition( Attach_CF0, _fin_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
357 m_fsm.AddTransition(
new WeaponTransition( Attach_CF0, _fin_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
358 m_fsm.AddTransition(
new WeaponTransition( Attach_CF0, _fin_,
C01, NULL,
new WeaponGuardHasMag(
this)));
360 m_fsm.AddTransition(
new WeaponTransition( Attach_CF0, _abt_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
361 m_fsm.AddTransition(
new WeaponTransition( Attach_CF0, _abt_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
362 m_fsm.AddTransition(
new WeaponTransition( Attach_CF0, _abt_,
C01, NULL,
new WeaponGuardHasMag(
this)));
364
365
366 m_fsm.AddTransition(
new WeaponTransition(
JF0, __A__, Attach_JF0, NULL,
new WeaponGuardCanAttachMag(
this)));
367 m_fsm.AddTransition(
new WeaponTransition( Attach_JF0, _fin_,
JF1, NULL,
new WeaponGuardHasMag(
this)));
369 m_fsm.AddTransition(
new WeaponTransition( Attach_JF0, _abt_,
JF1, NULL,
new WeaponGuardHasMag(
this)));
371
372
373 m_fsm.AddTransition(
new WeaponTransition(
C11, __S__, Reload_C11, NULL,
new WeaponGuardCanSwapMag(
this)));
374 m_fsm.AddTransition(
new WeaponTransition( Reload_C11, _fin_,
C11, NULL,
new WeaponGuardHasMag(
this)));
376 m_fsm.AddTransition(
new WeaponTransition( Reload_C11, _abt_,
C11, NULL,
new WeaponGuardHasMag(
this)));
378
379 m_fsm.AddTransition(
new WeaponTransition(
C01, __S__, Reload_C01, NULL,
new WeaponGuardCanSwapMag(
this)));
380 m_fsm.AddTransition(
new WeaponTransition( Reload_C01, _fin_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
381 m_fsm.AddTransition(
new WeaponTransition( Reload_C01, _fin_,
C01, NULL,
new WeaponGuardHasMag(
this)));
383 m_fsm.AddTransition(
new WeaponTransition( Reload_C01, _abt_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
384 m_fsm.AddTransition(
new WeaponTransition( Reload_C01, _abt_,
C01, NULL,
new WeaponGuardHasMag(
this)));
386
387 m_fsm.AddTransition(
new WeaponTransition(
CF1, __S__, Reload_CF1, NULL,
new WeaponGuardCanSwapMag(
this)));
388 m_fsm.AddTransition(
new WeaponTransition( Reload_CF1, _fin_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
389 m_fsm.AddTransition(
new WeaponTransition( Reload_CF1, _fin_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
390 m_fsm.AddTransition(
new WeaponTransition( Reload_CF1, _fin_,
C01, NULL,
new WeaponGuardHasMag(
this)));
392 m_fsm.AddTransition(
new WeaponTransition( Reload_CF1, _abt_,
CF1, NULL,
new WeaponGuardCurrentChamberFiredOut(
this)));
393 m_fsm.AddTransition(
new WeaponTransition( Reload_CF1, _abt_,
C11, NULL,
new WeaponGuardCurrentChamberFull(
this)));
394 m_fsm.AddTransition(
new WeaponTransition( Reload_CF1, _abt_,
C01, NULL,
new WeaponGuardHasMag(
this)));
396
397 m_fsm.AddTransition(
new WeaponTransition(
JF1, __S__, Reload_JF1, NULL,
new WeaponGuardCanSwapMag(
this)));
398 m_fsm.AddTransition(
new WeaponTransition( Reload_JF1, _fin_,
JF1, NULL,
new WeaponGuardHasMag(
this)));
400 m_fsm.AddTransition(
new WeaponTransition( Reload_JF1, _abt_,
JF1, NULL,
new WeaponGuardHasMag(
this)));
402
403
404
405 m_fsm.AddTransition(
new WeaponTransition(
C11, __D__, Detach_C11, NULL,
new WeaponGuardCanDetachMag(
this)));
407 m_fsm.AddTransition(
new WeaponTransition( Detach_C11, _abt_,
C11, NULL,
new WeaponGuardHasMag(
this)));
409
410
411 m_fsm.AddTransition(
new WeaponTransition(
C01, __D__, Detach_C01, NULL,
new WeaponGuardCanDetachMag(
this)));
412 m_fsm.AddTransition(
new WeaponTransition( Detach_C01, _fin_,
C01, NULL,
new WeaponGuardHasMag(
this)));
414 m_fsm.AddTransition(
new WeaponTransition( Detach_C01, _abt_,
C01, NULL,
new WeaponGuardHasMag(
this)));
416
417 m_fsm.AddTransition(
new WeaponTransition(
CF1, __D__, Detach_CF1, NULL,
new WeaponGuardCanDetachMag(
this)));
418 m_fsm.AddTransition(
new WeaponTransition( Detach_CF1, _fin_,
CF1, NULL,
new WeaponGuardHasMag(
this)));
420 m_fsm.AddTransition(
new WeaponTransition( Detach_CF1, _abt_,
CF1, NULL,
new WeaponGuardHasMag(
this)));
422
423 m_fsm.AddTransition(
new WeaponTransition(
JF1, __D__, Detach_JF1, NULL,
new WeaponGuardCanDetachMag(
this)));
424 m_fsm.AddTransition(
new WeaponTransition( Detach_JF1, _fin_,
JF1, NULL,
new WeaponGuardHasMag(
this)));
426 m_fsm.AddTransition(
new WeaponTransition( Detach_JF1, _abt_,
JF1, NULL,
new WeaponGuardHasMag(
this)));
428
429
431 m_fsm.AddTransition(
new WeaponTransition( Unjam_JF0, _fin_,
JF0, NULL,
new WeaponGuardJammed(
this)));
433 m_fsm.AddTransition(
new WeaponTransition( Unjam_JF0, _abt_,
JF0, NULL,
new WeaponGuardJammed(
this)));
435
437 m_fsm.AddTransition(
new WeaponTransition( Unjam_JF1, _fin_,
JF1, NULL,
new WeaponGuardJammed(
this)));
438 m_fsm.AddTransition(
new WeaponTransition( Unjam_JF1, _fin_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
440 m_fsm.AddTransition(
new WeaponTransition( Unjam_JF1, _abt_,
JF1, NULL,
new WeaponGuardJammed(
this)));
441 m_fsm.AddTransition(
new WeaponTransition( Unjam_JF1, _abt_,
C01, NULL,
new WeaponGuardCurrentChamberEmpty(
this)));
443
444 SetInitialState(
C00);
445
446 SelectionBulletHide();
447 HideMagazine();
448
449 m_fsm.Start();
450
451 }
enum FSMTransition WeaponTransition
enum FSMTransition WeaponEventBase
ref WeaponStableState C10
ref WeaponStableState CF1
ref WeaponStableState JF1
ref WeaponStableState CF0
ref WeaponStableState JF0
ref WeaponStableState C00
ref WeaponStableState C11
ref WeaponStableState C01
WeaponActionChamberingTypes
WeaponActionUnjammingTypes