buildingaggregate.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. *** 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 ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Combat *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/buildingaggregate.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Byon_g $*
  29. * *
  30. * $Modtime:: 11/21/01 2:47p $*
  31. * *
  32. * $Revision:: 8 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #if defined(_MSC_VER)
  38. #pragma once
  39. #endif
  40. #ifndef BUILDINGAGGREGATE_H
  41. #define BUILDINGAGGREGATE_H
  42. #include "always.h"
  43. #include "staticanimphys.h"
  44. #include "buildingstate.h"
  45. class BuildingAggregateDefClass;
  46. /**
  47. ** BuildingAggregateClass (BAG)
  48. ** This class implements the behavior of a "building aggregate". Building aggregates are animated
  49. ** static objects which display segments of their animation depending on the state of the building.
  50. */
  51. class BuildingAggregateClass : public StaticAnimPhysClass
  52. {
  53. public:
  54. // Constructor and Destructor
  55. BuildingAggregateClass( void );
  56. virtual ~BuildingAggregateClass( void );
  57. // Definitions
  58. void Init( const BuildingAggregateDefClass & definition );
  59. const BuildingAggregateDefClass * Get_BuildingAggregateDef( void ) const { WWASSERT( Definition ); return (BuildingAggregateDefClass *)Definition; }
  60. // State changing
  61. int Get_Current_State(void);
  62. void Set_Current_State(int new_state,bool force_update = false);
  63. bool Is_MCT(void);
  64. // Save / Load
  65. virtual bool Save( ChunkSaveClass & csave );
  66. virtual bool Load( ChunkLoadClass & cload );
  67. virtual void Save_State( ChunkSaveClass & csave );
  68. virtual void Load_State( ChunkLoadClass & cload );
  69. virtual void On_Post_Load( void );
  70. virtual const PersistFactoryClass & Get_Factory( void ) const;
  71. protected:
  72. bool Is_Power_On(int state);
  73. int CurrentState;
  74. };
  75. /**
  76. ** BuildingAggregateDefClass (BAGDef!)
  77. ** The data contained in this class defines the behavior of a "building aggregate". Building
  78. ** aggregates are animated static objects which display segments of their animation depending
  79. ** on the state of the building.
  80. ** Obviously, this is a very special case object; designed specifically to provide a set of
  81. ** features needed by the building logic in Renegade.
  82. */
  83. class BuildingAggregateDefClass : public StaticAnimPhysDefClass
  84. {
  85. public:
  86. BuildingAggregateDefClass(void);
  87. virtual uint32 Get_Class_ID( void ) const;
  88. virtual const char * Get_Type_Name(void) { return "BuildingAggregateDef"; }
  89. virtual bool Is_Type(const char *);
  90. virtual PersistClass * Create( void ) const ;
  91. virtual bool Save( ChunkSaveClass &csave );
  92. virtual bool Load( ChunkLoadClass &cload );
  93. virtual const PersistFactoryClass & Get_Factory( void ) const;
  94. DECLARE_EDITABLE( BuildingAggregateDefClass, StaticAnimPhysDefClass );
  95. protected:
  96. bool Save_State_Animation_Data(ChunkSaveClass & csave,int state_index);
  97. bool Load_State_Animation_Data(ChunkLoadClass & cload,int state_index);
  98. /*
  99. ** Animation Logic Setting
  100. ** ANIM_LOGIC_LINEAR - Frame0 is used for each state, if the damage state changes, the animation
  101. ** is played to the new state's Frame0. If the power state changes, we pop to the same relative
  102. ** position in the alternate power state.
  103. ** ANIM_LOGIC_LOOP - In this mode, each state has a pair of frames which it loops between. Whenever
  104. ** the state changes, we pop to the same relative position in the new loop. In addition, certain
  105. ** states can have animation disabled; this will cause the object to freeze on the appropriate frame
  106. ** right after the state change.
  107. */
  108. enum
  109. {
  110. ANIM_LOGIC_LINEAR = 0,
  111. ANIM_LOGIC_LOOP,
  112. ANIM_LOGIC_SEQUENCE,
  113. };
  114. int AnimLogicMode;
  115. bool IsMCT;
  116. /*
  117. ** Animation controls for each state. In LOOP mode, we use Frame0 and Frame1 to define a loop. In
  118. ** Linear mode, only Frame0 is used.
  119. */
  120. int Frame0[BuildingStateClass::STATE_COUNT];
  121. int Frame1[BuildingStateClass::STATE_COUNT];
  122. bool AnimationEnabled[BuildingStateClass::STATE_COUNT];
  123. friend class BuildingAggregateClass;
  124. };
  125. #endif //BUILDINGAGGREGATE_H