transition.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/transition.cpp $*
  25. * *
  26. * $Author:: Byon_g $*
  27. * *
  28. * $Modtime:: 1/09/02 3:53p $*
  29. * *
  30. * $Revision:: 75 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. /*
  36. ** Includes
  37. */
  38. #include "transition.h"
  39. #include "soldier.h"
  40. #include "debug.h"
  41. #include "assets.h"
  42. #include "combat.h"
  43. #include "ccamera.h"
  44. #include "gameobjmanager.h" // hack???
  45. #include "scripts.h"
  46. #include "hanim.h"
  47. #include "slist.h"
  48. #include "vehicle.h"
  49. #include "phys3.h"
  50. #include "wwprofile.h"
  51. #include "diaglog.h"
  52. #include <string.h>
  53. #include <stdlib.h>
  54. #include "pathaction.h"
  55. /*
  56. **
  57. */
  58. const char * TransitionTypeNames[] = {
  59. "LADDER_EXIT_TOP",
  60. "LADDER_EXIT_BOTTOM",
  61. "LADDER_ENTER_TOP",
  62. "LADDER_ENTER_BOTTOM",
  63. "LEGACY_VEHICLE_ENTER_0",
  64. "LEGACY_VEHICLE_ENTER_1",
  65. "LEGACY_VEHICLE_EXIT_0",
  66. "LEGACY_VEHICLE_EXIT_1",
  67. "VEHICLE_ENTER",
  68. "VEHICLE_EXIT",
  69. };
  70. /*
  71. **
  72. */
  73. bool Is_Point_Inside( const Vector3 & pos, const Vector3 & min, const Vector3 & max )
  74. {
  75. return ( ( pos.X >= min.X ) && ( pos.X <= max.X ) &&
  76. ( pos.Y >= min.Y ) && ( pos.Y <= max.Y ) &&
  77. ( pos.Z >= min.Z ) && ( pos.Z <= max.Z ) );
  78. }
  79. /*
  80. ** Save and Load for TransitionDataClass
  81. */
  82. namespace TRANSITION_DATA_CLASS_SAVELOAD
  83. {
  84. enum {
  85. CHUNKID_VARIABLES = 0x11051106,
  86. MICROCHUNKID_TYPE = 1,
  87. MICROCHUNKID_ZONE,
  88. MICROCHUNKID_ANIMATION_NAME,
  89. MICROCHUNKID_ENDING_TM,
  90. MICROCHUNKID_LADDER_INDEX
  91. };
  92. }
  93. /*
  94. **
  95. */
  96. TransitionDataClass::TransitionDataClass( )
  97. : Type( LADDER_EXIT_TOP )
  98. {
  99. }
  100. /*
  101. **
  102. */
  103. const char * TransitionDataClass::Get_Type_Name( StyleType type )
  104. {
  105. WWASSERT( ((int)type) < Get_Num_Types() );
  106. return TransitionTypeNames[((int)type)];
  107. }
  108. /*
  109. **
  110. */
  111. bool TransitionDataClass::Save( ChunkSaveClass & csave )
  112. {
  113. using namespace TRANSITION_DATA_CLASS_SAVELOAD;
  114. csave.Begin_Chunk( CHUNKID_VARIABLES );
  115. WRITE_MICRO_CHUNK( csave, MICROCHUNKID_TYPE, Type );
  116. WRITE_MICRO_CHUNK( csave, MICROCHUNKID_ZONE, Zone );
  117. WRITE_MICRO_CHUNK( csave, MICROCHUNKID_ENDING_TM, EndingTM );
  118. WRITE_MICRO_CHUNK_WWSTRING( csave, MICROCHUNKID_ANIMATION_NAME, AnimationName );
  119. csave.End_Chunk();
  120. return true;
  121. }
  122. /*
  123. **
  124. */
  125. bool TransitionDataClass::Load( ChunkLoadClass & cload )
  126. {
  127. using namespace TRANSITION_DATA_CLASS_SAVELOAD;
  128. while (cload.Open_Chunk()) {
  129. switch(cload.Cur_Chunk_ID()) {
  130. case CHUNKID_VARIABLES:
  131. {
  132. while (cload.Open_Micro_Chunk()) {
  133. switch(cload.Cur_Micro_Chunk_ID()) {
  134. READ_MICRO_CHUNK( cload, MICROCHUNKID_TYPE, Type );
  135. READ_MICRO_CHUNK( cload, MICROCHUNKID_ZONE, Zone );
  136. READ_MICRO_CHUNK( cload, MICROCHUNKID_ENDING_TM, EndingTM );
  137. READ_MICRO_CHUNK_WWSTRING( cload, MICROCHUNKID_ANIMATION_NAME, AnimationName );
  138. default:
  139. Debug_Say(( "Unrecognized Transition Variable chunkID\n" ));
  140. break;
  141. }
  142. cload.Close_Micro_Chunk();
  143. }
  144. break;
  145. }
  146. default:
  147. Debug_Say(( "Unrecognized Transition chunkID\n" ));
  148. break;
  149. }
  150. cload.Close_Chunk();
  151. }
  152. switch ( Type ) {
  153. case LEGACY_VEHICLE_ENTER_0:
  154. case LEGACY_VEHICLE_ENTER_1:
  155. Type = VEHICLE_ENTER;
  156. break;
  157. case LEGACY_VEHICLE_EXIT_0:
  158. case LEGACY_VEHICLE_EXIT_1:
  159. Type = VEHICLE_EXIT;
  160. break;
  161. }
  162. return true;
  163. }
  164. /*
  165. ** TransitionCompletionDataStruct
  166. */
  167. namespace TRANSITION_COMPLETION_SAVE_LOAD
  168. {
  169. enum {
  170. CHUNKID_VARIABLES = 1105991816,
  171. CHUNKID_VEHICLE,
  172. MICROCHUNKID_TYPE = 1,
  173. };
  174. }
  175. bool TransitionCompletionDataStruct::Save( ChunkSaveClass & csave )
  176. {
  177. using namespace TRANSITION_COMPLETION_SAVE_LOAD;
  178. csave.Begin_Chunk( CHUNKID_VARIABLES );
  179. WRITE_MICRO_CHUNK( csave, MICROCHUNKID_TYPE, Type );
  180. csave.End_Chunk();
  181. csave.Begin_Chunk( CHUNKID_VEHICLE );
  182. Vehicle.Save( csave );
  183. csave.End_Chunk();
  184. return true;
  185. }
  186. bool TransitionCompletionDataStruct::Load( ChunkLoadClass & cload )
  187. {
  188. using namespace TRANSITION_COMPLETION_SAVE_LOAD;
  189. while (cload.Open_Chunk()) {
  190. switch(cload.Cur_Chunk_ID()) {
  191. case CHUNKID_VARIABLES:
  192. while (cload.Open_Micro_Chunk()) {
  193. switch(cload.Cur_Micro_Chunk_ID()) {
  194. READ_MICRO_CHUNK( cload, MICROCHUNKID_TYPE, Type );
  195. default:
  196. Debug_Say(( "Unrecognized TransitionCompletion Variable chunkID\n" ));
  197. break;
  198. }
  199. cload.Close_Micro_Chunk();
  200. }
  201. break;
  202. case CHUNKID_VEHICLE:
  203. Vehicle.Load( cload );
  204. break;
  205. default:
  206. Debug_Say(( "Unrecognized TransitionCompletion chunkID\n" ));
  207. break;
  208. }
  209. cload.Close_Chunk();
  210. }
  211. return true;
  212. }
  213. /*
  214. ** TransitionInstanceClass
  215. */
  216. TransitionInstanceClass::TransitionInstanceClass( const TransitionDataClass & data ) :
  217. Data( data ),
  218. EndingTM( 1 ),
  219. LadderIndex( -1 ),
  220. Zone( Vector3( 0,0,0 ), Vector3( 0,0,0 ) )
  221. {
  222. }
  223. TransitionInstanceClass::~TransitionInstanceClass( void )
  224. {
  225. }
  226. bool TransitionInstanceClass::Check( SoldierGameObj *obj, bool action_trigger )
  227. {
  228. Vector3 pos;
  229. obj->Get_Position( &pos );
  230. // make sure we are in the zone
  231. if ( CollisionMath::Overlap_Test( Zone, pos ) == CollisionMath::OUTSIDE ) {
  232. return false; // not inside
  233. }
  234. // ignore triggers when transitioning
  235. if ( obj->Is_State_Locked() ) {
  236. return false;
  237. }
  238. // Bail if not manually triggered and not ladder exit and
  239. if ( !action_trigger &&
  240. ( Get_Type() != TransitionDataClass::LADDER_EXIT_TOP ) &&
  241. ( Get_Type() != TransitionDataClass::LADDER_EXIT_BOTTOM ) ) {
  242. #if 0
  243. // no auto transitions or not human controlled
  244. if ( !CombatManager::Are_Transitions_Automatic() ||
  245. !obj->Is_Human_Controlled() )
  246. #endif
  247. {
  248. return false;
  249. }
  250. }
  251. bool condition = action_trigger;
  252. if ( action_trigger == false ) {
  253. const float MIN_VELOCITY = 0.1f;
  254. // Check for auto trigger
  255. Vector3 vel;
  256. obj->Get_Velocity( vel );
  257. if ( vel.Length() > MIN_VELOCITY ) {
  258. Vector3 end_direction;
  259. // make sure we meet the conditions
  260. switch ( Get_Type() ) {
  261. case TransitionDataClass::LADDER_ENTER_BOTTOM:
  262. end_direction = EndingTM.Get_X_Vector();
  263. end_direction.Normalize();
  264. break;
  265. case TransitionDataClass::LADDER_ENTER_TOP:
  266. end_direction = -EndingTM.Get_X_Vector();
  267. end_direction.Normalize();
  268. break;
  269. case TransitionDataClass::LADDER_EXIT_BOTTOM:
  270. end_direction = Vector3( 0, 0, -1 );
  271. break;
  272. case TransitionDataClass::LADDER_EXIT_TOP:
  273. end_direction = Vector3( 0, 0, 1 );
  274. break;
  275. case TransitionDataClass::VEHICLE_ENTER:
  276. case TransitionDataClass::VEHICLE_EXIT:
  277. vel.Z = 0; // don't consider vertical
  278. end_direction = EndingTM.Get_Translation() - Zone.Center;
  279. end_direction.Normalize();
  280. break;
  281. default:
  282. Debug_Say(( "Unrecognized Transition Type\n" ));
  283. condition = false;
  284. break;
  285. }
  286. // If still has length
  287. if ( vel.Length() > MIN_VELOCITY ) {
  288. vel.Normalize();
  289. float dotp = Vector3::Dot_Product( vel, end_direction );
  290. if ( dotp > 0.5f ) {
  291. condition = true;
  292. }
  293. }
  294. }
  295. }
  296. // make sure we meet the conditions
  297. switch ( Get_Type() ) {
  298. case TransitionDataClass::LADDER_EXIT_TOP:
  299. case TransitionDataClass::LADDER_EXIT_BOTTOM:
  300. if ( !obj->Is_On_Ladder() ) {
  301. condition = false;
  302. }
  303. break;
  304. case TransitionDataClass::LADDER_ENTER_TOP:
  305. case TransitionDataClass::LADDER_ENTER_BOTTOM:
  306. if ( !obj->Is_Upright() ) {
  307. condition = false;
  308. }
  309. break;
  310. case TransitionDataClass::VEHICLE_ENTER:
  311. if ( !obj->Is_Upright() && !obj->Is_Wounded() ) {
  312. // Added wounded because we couldn't enter vehicles in a tib field
  313. condition = false;
  314. }
  315. VehicleGameObj * p_vehicle;
  316. p_vehicle = (VehicleGameObj *) Vehicle.Get_Ptr();
  317. WWASSERT(p_vehicle != NULL);
  318. if (!obj->Is_Permitted_To_Enter_Vehicle() ||
  319. !p_vehicle->Is_Entry_Permitted(obj)) {
  320. condition = false;
  321. }
  322. // When entering a vehicle, ensure that there are no walls between us
  323. // Do this by casting a ray from our position to the vehicle position; only
  324. // checking against static geometry.
  325. {
  326. Vector3 p0,p1;
  327. p_vehicle->Get_Position(&p0);
  328. obj->Get_Position(&p1);
  329. CastResultStruct result;
  330. LineSegClass ray(p0,p1);
  331. int colgroup = obj->Peek_Physical_Object()->Get_Collision_Group();
  332. PhysRayCollisionTestClass raytest(ray,&result,colgroup,COLLISION_TYPE_PHYSICAL);
  333. raytest.CheckDynamicObjs = false;
  334. PhysicsSceneClass::Get_Instance()->Cast_Ray(raytest);
  335. if (result.Fraction < 1.0f) {
  336. condition = false;
  337. }
  338. }
  339. break;
  340. case TransitionDataClass::VEHICLE_EXIT:
  341. if ( !obj->Is_In_Vehicle() ) {
  342. condition = false;
  343. }
  344. break;
  345. default:
  346. Debug_Say(( "Unrecognized Transition Type\n" ));
  347. condition = false;
  348. break;
  349. }
  350. if ( !condition ) {
  351. return false;
  352. }
  353. //
  354. // Check to ensure the object can teleport to the ending location
  355. //
  356. Matrix3D dummy_tm;
  357. MoveablePhysClass *move_phys = obj->Peek_Physical_Object()->As_MoveablePhysClass();
  358. switch ( Get_Type() ) {
  359. case TransitionDataClass::LADDER_ENTER_TOP:
  360. case TransitionDataClass::LADDER_ENTER_BOTTOM:
  361. {
  362. //
  363. // Its not legal to get on a ladder when someone else is on the ladder.
  364. // Try to detect this case.
  365. //
  366. if( obj == COMBAT_STAR && LadderIndex >= 0 ) {
  367. ScriptableGameObj *occupant = PathActionClass::Get_Ladder_Occupant( LadderIndex );
  368. if( occupant != NULL && occupant != obj ) {
  369. condition = false;
  370. }
  371. }
  372. break;
  373. }
  374. case TransitionDataClass::LADDER_EXIT_TOP:
  375. case TransitionDataClass::LADDER_EXIT_BOTTOM:
  376. //
  377. // When exiting a Ladder, we just have to check for a dynamic object blocking our
  378. // exit point. (the third parameter to Can_Teleport_And_Stand is true...)
  379. //
  380. /*if ( move_phys != NULL &&
  381. move_phys->Can_Teleport(EndingTM, true) == false)
  382. {
  383. condition = false;
  384. }*/
  385. break;
  386. case TransitionDataClass::VEHICLE_EXIT:
  387. //
  388. // When exiting a vehicle, we perform two steps:
  389. // - ignore our vehicle and sweep the character to the exit transform
  390. // - un-ignore the vehicle and do a teleport test.
  391. //
  392. if (move_phys != NULL) {
  393. bool can_move_to;
  394. VehicleGameObj * vgobj = Get_Vehicle();
  395. PhysClass * pobj = vgobj->Peek_Physical_Object();
  396. pobj->Inc_Ignore_Counter();
  397. can_move_to = move_phys->Can_Move_To(EndingTM);
  398. pobj->Dec_Ignore_Counter();
  399. if ( (can_move_to == false) ||
  400. (move_phys->Can_Teleport_And_Stand(EndingTM,&dummy_tm) == false) )
  401. {
  402. condition = false;
  403. }
  404. }
  405. break;
  406. }
  407. if ( !condition ) {
  408. return false;
  409. }
  410. Start( obj );
  411. return true;
  412. }
  413. void TransitionInstanceClass::Start( SoldierGameObj *obj )
  414. {
  415. // Debug_Say(( "Starting Animation\n" ));
  416. // if this is the camera's target...
  417. if ( COMBAT_STAR == obj ) {
  418. // Get duration
  419. #if 0
  420. HAnimClass * animation = WW3DAssetManager::Get_Instance()->Get_HAnim( Data.Get_Animation_Name() );
  421. if ( animation ) {
  422. float anim_duration = animation->Get_Num_Frames() / animation->Get_Frame_Rate();
  423. animation->Release_Ref();
  424. // COMBAT_CAMERA->Set_Lerp_Time( anim_duration * 1.3f );
  425. COMBAT_CAMERA->Set_Lerp_Time( anim_duration );
  426. }
  427. #else
  428. COMBAT_CAMERA->Set_Lerp_Time( 1.0f );
  429. #endif
  430. }
  431. // set the object ending position & orientation
  432. #ifdef WWDEBUG
  433. Vector3 pos = EndingTM.Get_Translation();
  434. if (!pos.Is_Valid()) {
  435. WWDEBUG_SAY(("Transition EndingTM has invalid position: %f, %f, %f\r\n",pos.X,pos.Y,pos.Z));
  436. }
  437. #endif
  438. obj->Set_Transform( EndingTM );
  439. if ( obj->Peek_Physical_Object() != NULL && obj->Peek_Physical_Object()->As_Phys3Class() != NULL ) {
  440. obj->Peek_Physical_Object()->As_Phys3Class()->Set_Velocity( Vector3(0,0,0) );
  441. }
  442. // make the completion data
  443. TransitionCompletionDataStruct * completion_data = new TransitionCompletionDataStruct;
  444. completion_data->Type = Data.Get_Type();
  445. completion_data->Vehicle = Vehicle;
  446. //
  447. // Mark ladders as being used/free as necessary
  448. //
  449. switch ( Get_Type() ) {
  450. case TransitionDataClass::LADDER_ENTER_TOP:
  451. case TransitionDataClass::LADDER_ENTER_BOTTOM:
  452. {
  453. //
  454. // Mark this ladder as being "in use" so no one else tries to get on it
  455. //
  456. if( obj == COMBAT_STAR && LadderIndex >= 0 ) {
  457. PathActionClass::Set_Ladder_Occupant( LadderIndex, obj );
  458. }
  459. break;
  460. }
  461. case TransitionDataClass::LADDER_EXIT_TOP:
  462. case TransitionDataClass::LADDER_EXIT_BOTTOM:
  463. {
  464. //
  465. // Free this ladder so other's can use it
  466. //
  467. if( obj == COMBAT_STAR && LadderIndex >= 0 ) {
  468. PathActionClass::Set_Ladder_Occupant( LadderIndex, NULL );
  469. }
  470. break;
  471. }
  472. }
  473. #if 0
  474. obj->Start_Transition_Animation( Data.Get_Animation_Name(), completion_data );
  475. VehicleGameObj * vehicle = Get_Vehicle();
  476. // If vehicle entry/exit, allow it to animate as well
  477. switch ( Get_Type() ) {
  478. case TransitionDataClass::VEHICLE_ENTER:
  479. {
  480. if ( vehicle ) {
  481. vehicle->Passenger_Entering();
  482. }
  483. break;
  484. }
  485. case TransitionDataClass::VEHICLE_EXIT:
  486. {
  487. WWASSERT( vehicle );
  488. // obj->Set_Vehicle_State( SoldierGameObj::EXITING_VEHICLE, vehicle );
  489. vehicle->Passenger_Exiting();
  490. break;
  491. }
  492. default:
  493. break;
  494. }
  495. #else
  496. End( obj, completion_data );
  497. #endif
  498. }
  499. void TransitionInstanceClass::End( SoldierGameObj *obj,
  500. TransitionCompletionDataStruct * completion_data )
  501. {
  502. VehicleGameObj * vehicle = (VehicleGameObj *)completion_data->Vehicle.Get_Ptr();
  503. switch ( completion_data->Type ) {
  504. case TransitionDataClass::LADDER_EXIT_TOP:
  505. case TransitionDataClass::LADDER_EXIT_BOTTOM:
  506. obj->Exit_Ladder();
  507. if ( obj == COMBAT_STAR ) {
  508. Vector3 pos;
  509. obj->Get_Position( &pos );
  510. DIAG_LOG(( "LAEX", "%1.2f; %1.2f; %1.2f", pos.X, pos.Y, pos.Z ));
  511. }
  512. break;
  513. case TransitionDataClass::LADDER_ENTER_TOP:
  514. case TransitionDataClass::LADDER_ENTER_BOTTOM:
  515. obj->Enter_Ladder( completion_data->Type == TransitionDataClass::LADDER_ENTER_TOP );
  516. if ( obj == COMBAT_STAR ) {
  517. Vector3 pos;
  518. obj->Get_Position( &pos );
  519. DIAG_LOG(( "LAEN", "%1.2f; %1.2f; %1.2f", pos.X, pos.Y, pos.Z ));
  520. }
  521. break;
  522. case TransitionDataClass::VEHICLE_ENTER:
  523. {
  524. if ( vehicle != NULL ) {
  525. vehicle->Add_Occupant( obj );
  526. }
  527. break;
  528. }
  529. case TransitionDataClass::VEHICLE_EXIT:
  530. {
  531. if ( vehicle != NULL ) {
  532. vehicle->Remove_Occupant( obj );
  533. } else {
  534. obj->Exit_Vehicle();
  535. }
  536. break;
  537. }
  538. default:
  539. Debug_Say(( "Unrecognized Transition Type\n" ));
  540. break;
  541. }
  542. // Delete the data (soldier better not use it)
  543. delete completion_data;
  544. }
  545. void TransitionInstanceClass::Set_Parent_Transform( const Matrix3D & tm )
  546. {
  547. Matrix3D::Multiply( tm, Data.Get_Ending_TM(), &EndingTM );
  548. OBBoxClass::Transform( tm, Data.Get_Zone(), &Zone );
  549. }
  550. /*
  551. ** TransitionManager
  552. */
  553. SList<TransitionInstanceClass> Transitions;
  554. SList<TransitionInstanceClass> TransitionsDestroy;
  555. void TransitionManager::Add( TransitionInstanceClass * transition )
  556. {
  557. Transitions.Add_Tail( transition );
  558. }
  559. void TransitionManager::Destroy( TransitionInstanceClass * transition )
  560. {
  561. TransitionsDestroy.Add_Tail( transition );
  562. }
  563. void TransitionManager::Reset( void )
  564. {
  565. Destroy_Pending();
  566. while ( Transitions.Get_Count() ) {
  567. delete Transitions.Remove_Head();
  568. }
  569. }
  570. void TransitionManager::Destroy_Pending( void )
  571. {
  572. while ( TransitionsDestroy.Get_Count() ) {
  573. TransitionInstanceClass * trans = TransitionsDestroy.Remove_Head();
  574. Transitions.Remove( trans );
  575. delete trans;
  576. }
  577. }
  578. bool TransitionManager::Check( SoldierGameObj *obj, bool action_trigger )
  579. {
  580. WWPROFILE( "Transition Check" );
  581. SLNode<TransitionInstanceClass> *ti_node;
  582. for ( ti_node = Transitions.Head(); ti_node; ti_node = ti_node->Next()) {
  583. if ( ti_node->Data()->Check( obj, action_trigger ) ) {
  584. Destroy_Pending();
  585. return true;
  586. }
  587. }
  588. return false;
  589. }
  590. void TransitionManager::Build_Ladder_List (DynamicVectorClass<TransitionInstanceClass *> &list)
  591. {
  592. SLNode<TransitionInstanceClass> *ti_node = NULL;
  593. for ( ti_node = Transitions.Head(); ti_node; ti_node = ti_node->Next()) {
  594. //
  595. // Is this a ladder transition?
  596. //
  597. TransitionDataClass::StyleType type = ti_node->Data()->Get_Type ();
  598. if ( type == TransitionDataClass::LADDER_EXIT_TOP || type == TransitionDataClass::LADDER_EXIT_BOTTOM ||
  599. type == TransitionDataClass::LADDER_ENTER_TOP || type == TransitionDataClass::LADDER_ENTER_BOTTOM)
  600. {
  601. list.Add( ti_node->Data () );
  602. }
  603. }
  604. return ;
  605. }