ladder.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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. // Ladder.H
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 06/02/97 JMI Started.
  23. //
  24. //////////////////////////////////////////////////////////////////////////////
  25. //
  26. // This CThing-derived class will represent ladders that the CDudes, and
  27. // perhaps other characters, can use to climb to heights they cannot step up
  28. // to.
  29. //
  30. //////////////////////////////////////////////////////////////////////////////
  31. #ifndef LADDER_H
  32. #define LADDER_H
  33. #include "RSPiX.h"
  34. #include "realm.h"
  35. #include "character.h"
  36. class CLadder : public CThing
  37. {
  38. //---------------------------------------------------------------------------
  39. // Types, enums, etc.
  40. //---------------------------------------------------------------------------
  41. public:
  42. //---------------------------------------------------------------------------
  43. // Variables
  44. //---------------------------------------------------------------------------
  45. public:
  46. double m_dX;
  47. double m_dY;
  48. double m_dZ;
  49. short m_sLen; // Length of ladder.
  50. short m_sHeight; // Height of ladder.
  51. short m_sRotY; // Rotation around Y axis (i.e.,
  52. // direction on X/Z plane).
  53. short m_sSuspend; // Suspend flag
  54. CSmash m_smashTop; // Collision smash for the top of the
  55. // ladder.
  56. CSmash m_smashBottom; // Collision smash for the bottom of the
  57. // ladder.
  58. CSprite2 m_sprite; // Sprite.
  59. CCharacter* m_pcharLadderBoy; // Character currently using the
  60. // ladder.
  61. protected:
  62. //---------------------------------------------------------------------------
  63. // Static Variables
  64. //---------------------------------------------------------------------------
  65. public:
  66. //---------------------------------------------------------------------------
  67. // Constructor(s) / destructor
  68. //---------------------------------------------------------------------------
  69. public:
  70. // Constructor
  71. CLadder(CRealm* pRealm)
  72. : CThing(pRealm, CLadderID)
  73. {
  74. m_sSuspend = 0;
  75. m_sprite.m_pthing = this;
  76. m_smashTop.m_pThing = this;
  77. m_smashBottom.m_pThing = this;
  78. m_sLen = 0;
  79. m_sHeight = 0;
  80. m_sRotY = 0;
  81. m_pcharLadderBoy = NULL;
  82. }
  83. public:
  84. // Destructor
  85. ~CLadder()
  86. {
  87. // Remove sprite from scene (this is safe even if it was already removed!)
  88. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  89. // Free resources
  90. FreeResources();
  91. // Remove collision thinger.
  92. m_pRealm->m_smashatorium.Remove(&m_smashTop);
  93. m_pRealm->m_smashatorium.Remove(&m_smashBottom);
  94. }
  95. //---------------------------------------------------------------------------
  96. // Required static functions
  97. //---------------------------------------------------------------------------
  98. public:
  99. // Construct object
  100. static short Construct( // Returns 0 if successfull, non-zero otherwise
  101. CRealm* pRealm, // In: Pointer to realm this object belongs to
  102. CThing** ppNew) // Out: Pointer to new object
  103. {
  104. short sResult = 0;
  105. *ppNew = new CLadder(pRealm);
  106. if (*ppNew == 0)
  107. {
  108. sResult = -1;
  109. TRACE("CLadder::Construct(): Couldn't construct CLadder (that's a bad thing)\n");
  110. }
  111. return sResult;
  112. }
  113. //---------------------------------------------------------------------------
  114. // Required virtual functions (implementing them as inlines doesn't pay!)
  115. //---------------------------------------------------------------------------
  116. public:
  117. // Load object (should call base class version!)
  118. short Load( // Returns 0 if successfull, non-zero otherwise
  119. RFile* pFile, // In: File to load from
  120. bool bEditMode, // In: True for edit mode, false otherwise
  121. short sFileCount, // In: File count (unique per file, never 0)
  122. ULONG ulFileVersion); // In: Version of file format to load.
  123. // Save object (should call base class version!)
  124. short Save( // Returns 0 if successfull, non-zero otherwise
  125. RFile* pFile, // In: File to save to
  126. short sFileCount); // In: File count (unique per file, never 0)
  127. // Startup object
  128. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  129. // Shutdown object
  130. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  131. // Suspend object
  132. void Suspend(void);
  133. // Resume object
  134. void Resume(void);
  135. // Update object
  136. void Update(void);
  137. // Render object
  138. void Render(void);
  139. // Called by editor to init new object at specified position
  140. short EditNew( // Returns 0 if successfull, non-zero otherwise
  141. short sX, // In: New x coord
  142. short sY, // In: New y coord
  143. short sZ); // In: New z coord
  144. // Called by editor to modify object
  145. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  146. // Called by editor to move object to specified position
  147. short EditMove( // Returns 0 if successfull, non-zero otherwise
  148. short sX, // In: New x coord
  149. short sY, // In: New y coord
  150. short sZ); // In: New z coord
  151. // Called by editor to get the clickable pos/area of an object in 2D.
  152. virtual // Overridden here.
  153. void EditRect( // Returns nothiing.
  154. RRect* prc); // Out: Clickable pos/area of object.
  155. // Called by editor to get the hotspot of an object in 2D.
  156. virtual // Overridden here.
  157. void EditHotSpot( // Returns nothiing.
  158. short* psX, // Out: X coord of 2D hotspot relative to
  159. // EditRect() pos.
  160. short* psY); // Out: Y coord of 2D hotspot relative to
  161. // EditRect() pos.
  162. // Called by editor to update object
  163. void EditUpdate(void);
  164. // Called by editor to render object
  165. void EditRender(void);
  166. //---------------------------------------------------------------------------
  167. // Handy external functions
  168. //---------------------------------------------------------------------------
  169. public:
  170. // Call to try to get on the ladder.
  171. // This function will return false if there is already someone on the
  172. // ladder.
  173. // If you call this function and it returns true, you MUST call GetOff()
  174. // once done so other characters can use the ladder.
  175. bool GetOn( // Returns true, if able to get on,
  176. // false otherwise.
  177. CCharacter* pchar); // In: Character attempting to get onto ladder.
  178. // Call when you get off the ladder.
  179. // Only call this function, if you have made a successful call to GetOn()
  180. // and have not, since, made a call to this function.
  181. void GetOff(void); // Returns nothing.
  182. // Get the next position on the ladder.
  183. void GetNextPos( // Returns nothing.
  184. double* pdX, // In: Current x position.
  185. // Out: New x position.
  186. double* pdY, // In: Current y position.
  187. // Out: New y position.
  188. double* pdZ, // In: Current z position.
  189. // Out: New z position.
  190. double dDistance); // In: Distance to travel. Positive is up.
  191. //---------------------------------------------------------------------------
  192. // Internal functions
  193. //---------------------------------------------------------------------------
  194. protected:
  195. // Get all required resources
  196. short GetResources(void); // Returns 0, if successfull, non-zero otherwise
  197. // Free all resources
  198. short FreeResources(void); // Returns 0, if successfull, non-zero otherwise
  199. // Initialize object.
  200. short Init(void); // Returns 0, on success.
  201. };
  202. #endif // LADDER_H
  203. ////////////////////////////////////////////////////////////////////////////////
  204. // EOF
  205. ////////////////////////////////////////////////////////////////////////////////