flagbase.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // flagbase.h
  19. // Project: Postal
  20. //
  21. // History:
  22. //
  23. // 06/30/97 BRH Started this file to contain the base object for the
  24. // capture the flag mode. When the flag meets the base,
  25. // the game is complete.
  26. //
  27. // 07/12/97 BRH Added m_u16FlagID to match flags with bases.
  28. //
  29. // 08/11/97 BRH Added color variable which is loaded and saved.
  30. //
  31. ////////////////////////////////////////////////////////////////////////////////
  32. #ifndef FLAGBASE_H
  33. #define FLAGBASE_H
  34. #include "RSPiX.h"
  35. #include "realm.h"
  36. #include "Thing3d.h"
  37. // CFlagbasebase is the base where the flag goes in capture the flag challenge levels
  38. class CFlagbase : public CThing3d
  39. {
  40. //---------------------------------------------------------------------------
  41. // Types, enums, etc.
  42. //---------------------------------------------------------------------------
  43. protected:
  44. //---------------------------------------------------------------------------
  45. // Variables
  46. //---------------------------------------------------------------------------
  47. public:
  48. CAnim3D* m_panimCurBase; // current animation for the base
  49. U16 m_u16FlagID; // ID to match flag and base
  50. protected:
  51. CAnim3D m_animFlagWave; // animation for the flag waving
  52. U16 m_u16Color; // Color of base
  53. // Tracks file counter so we know when to load/save "common" data
  54. static short ms_sFileCount;
  55. // "Constant" values that we want to be able to tune using the editor
  56. static double ms_dInRange; // In range to the base
  57. //---------------------------------------------------------------------------
  58. // Constructor(s) / destructor
  59. //---------------------------------------------------------------------------
  60. protected:
  61. // Constructor
  62. CFlagbase(CRealm* pRealm)
  63. : CThing3d(pRealm, CFlagbaseID)
  64. {
  65. m_sSuspend = 0;
  66. m_dRot = 0;
  67. m_dX = m_dY = m_dZ = m_dVel = m_dAcc = 0;
  68. m_panimCur = NULL;
  69. m_sprite.m_pthing = this;
  70. m_u16FlagID = 1;
  71. m_u16Color = 0;
  72. }
  73. public:
  74. // Destructor
  75. ~CFlagbase()
  76. {
  77. // Remove sprite from scene (this is safe even if it was already removed!)
  78. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  79. m_pRealm->m_smashatorium.Remove(&m_smash);
  80. // Free resources
  81. FreeResources();
  82. }
  83. //---------------------------------------------------------------------------
  84. // Required static functions
  85. //---------------------------------------------------------------------------
  86. public:
  87. // Construct object
  88. static short Construct( // Returns 0 if successfull, non-zero otherwise
  89. CRealm* pRealm, // In: Pointer to realm this object belongs to
  90. CThing** ppNew) // Out: Pointer to new object
  91. {
  92. short sResult = 0;
  93. *ppNew = new CFlagbase(pRealm);
  94. if (*ppNew == 0)
  95. {
  96. sResult = -1;
  97. TRACE("CFlagbase::Construct(): Couldn't construct CFlagbase (that's a bad thing)\n");
  98. }
  99. return sResult;
  100. }
  101. //---------------------------------------------------------------------------
  102. // Required virtual functions (implimenting them as inlines doesn't pay!)
  103. //---------------------------------------------------------------------------
  104. public:
  105. // Load object (should call base class version!)
  106. short Load( // Returns 0 if successfull, non-zero otherwise
  107. RFile* pFile, // In: File to load from
  108. bool bEditMode, // In: True for edit mode, false otherwise
  109. short sFileCount, // In: File count (unique per file, never 0)
  110. ULONG ulFileVersion); // In: Version of file format to load.
  111. // Save object (should call base class version!)
  112. short Save( // Returns 0 if successfull, non-zero otherwise
  113. RFile* pFile, // In: File to save to
  114. short sFileCount); // In: File count (unique per file, never 0)
  115. // Startup object
  116. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  117. // Shutdown object
  118. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  119. // Update object
  120. void Update(void);
  121. // Called by editor to init new object at specified position
  122. short EditNew( // Returns 0 if successfull, non-zero otherwise
  123. short sX, // In: New x coord
  124. short sY, // In: New y coord
  125. short sZ); // In: New z coord
  126. // Called by editor to modify object
  127. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  128. // Called by editor to move object to specified position
  129. short EditMove( // Returns 0 if successfull, non-zero otherwise
  130. short sX, // In: New x coord
  131. short sY, // In: New y coord
  132. short sZ); // In: New z coord
  133. // Give Edit a rectangle around this object
  134. void EditRect(RRect* pRect);
  135. // Called by editor to get the hotspot of an object in 2D.
  136. // (virtual (Overridden here)).
  137. void EditHotSpot( // Returns nothiing.
  138. short* psX, // Out: X coord of 2D hotspot relative to
  139. // EditRect() pos.
  140. short* psY); // Out: Y coord of 2D hotspot relative to
  141. // EditRect() pos.
  142. //---------------------------------------------------------------------------
  143. // Internal functions
  144. //---------------------------------------------------------------------------
  145. protected:
  146. // Get all required resources
  147. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  148. // Free all resources
  149. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  150. // Initialize states, positions etc.
  151. short Init(void);
  152. // Update the animation radius based on the current frame
  153. void UpdateRadius(void);
  154. // Message handling functions ////////////////////////////////////////////
  155. // Handles an Explosion_Message.
  156. virtual // Override to implement additional functionality.
  157. // Call base class to get default functionality.
  158. void OnExplosionMsg( // Returns nothing.
  159. Explosion_Message* pexplosionmsg); // In: Message to handle.
  160. // Handles a Burn_Message.
  161. virtual // Override to implement additional functionality.
  162. // Call base class to get default functionality.
  163. void OnBurnMsg( // Returns nothing.
  164. Burn_Message* pburnmsg); // In: Message to handle.
  165. };
  166. #endif //FLAGBASE_H
  167. ////////////////////////////////////////////////////////////////////////////////
  168. // EOF
  169. ////////////////////////////////////////////////////////////////////////////////