missionMarker.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _MISSIONMARKER_H_
  23. #define _MISSIONMARKER_H_
  24. #ifndef _BITSTREAM_H_
  25. #include "core/stream/bitStream.h"
  26. #endif
  27. #ifndef _SIMBASE_H_
  28. #include "console/simBase.h"
  29. #endif
  30. #ifndef _SHAPEBASE_H_
  31. #include "T3D/shapeBase.h"
  32. #endif
  33. #ifndef _MATHIO_H_
  34. #include "math/mathIO.h"
  35. #endif
  36. #ifndef _COLOR_H_
  37. #include "core/color.h"
  38. #endif
  39. class MissionMarkerData : public ShapeBaseData
  40. {
  41. private:
  42. typedef ShapeBaseData Parent;
  43. public:
  44. DECLARE_CONOBJECT(MissionMarkerData);
  45. };
  46. //------------------------------------------------------------------------------
  47. // Class: MissionMarker
  48. //------------------------------------------------------------------------------
  49. class MissionMarker : public ShapeBase
  50. {
  51. private:
  52. typedef ShapeBase Parent;
  53. protected:
  54. enum MaskBits {
  55. PositionMask = Parent::NextFreeMask,
  56. NextFreeMask = Parent::NextFreeMask << 1
  57. };
  58. MissionMarkerData * mDataBlock;
  59. bool mAddedToScene;
  60. public:
  61. MissionMarker();
  62. // GameBase
  63. bool onNewDataBlock( GameBaseData *dptr, bool reload );
  64. // SceneObject
  65. void setTransform(const MatrixF &mat);
  66. // SimObject
  67. bool onAdd();
  68. void onRemove();
  69. void onEditorEnable();
  70. void onEditorDisable();
  71. void inspectPostApply();
  72. // NetObject
  73. U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream);
  74. void unpackUpdate(NetConnection *conn, BitStream *stream);
  75. DECLARE_CONOBJECT(MissionMarker);
  76. static void initPersistFields();
  77. };
  78. //------------------------------------------------------------------------------
  79. // Class: WayPoint
  80. //------------------------------------------------------------------------------
  81. class WayPoint;
  82. class WayPoint : public MissionMarker
  83. {
  84. private:
  85. typedef MissionMarker Parent;
  86. public:
  87. enum WayPointMasks {
  88. UpdateNameMask = Parent::NextFreeMask,
  89. UpdateTeamMask = Parent::NextFreeMask << 1,
  90. UpdateHiddenMask = Parent::NextFreeMask << 2,
  91. NextFreeMask = Parent::NextFreeMask << 3
  92. };
  93. WayPoint();
  94. // ShapeBase: only ever added to scene if in the editor
  95. void setHidden(bool hidden);
  96. // SimObject
  97. bool onAdd();
  98. void inspectPostApply();
  99. // NetObject
  100. U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
  101. void unpackUpdate(NetConnection *conn, BitStream *stream);
  102. // field data
  103. StringTableEntry mName;
  104. static void initPersistFields();
  105. DECLARE_CONOBJECT(WayPoint);
  106. };
  107. //------------------------------------------------------------------------------
  108. // Class: SpawnSphere
  109. //------------------------------------------------------------------------------
  110. class SpawnSphere : public MissionMarker
  111. {
  112. private:
  113. typedef MissionMarker Parent;
  114. public:
  115. SpawnSphere();
  116. // SimObject
  117. bool onAdd();
  118. void inspectPostApply();
  119. // NetObject
  120. enum SpawnSphereMasks
  121. {
  122. UpdateSphereMask = Parent::NextFreeMask,
  123. NextFreeMask = Parent::NextFreeMask << 1
  124. };
  125. U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream);
  126. void unpackUpdate(NetConnection *conn, BitStream *stream);
  127. // ProcessObject
  128. void advanceTime( F32 timeDelta );
  129. void processTick( const Move *move );
  130. // Spawn info
  131. String mSpawnClass;
  132. String mSpawnDataBlock;
  133. String mSpawnName;
  134. String mSpawnProperties;
  135. String mSpawnScript;
  136. bool mAutoSpawn;
  137. bool mSpawnTransform;
  138. // Radius/weight info
  139. F32 mRadius;
  140. F32 mSphereWeight;
  141. F32 mIndoorWeight;
  142. F32 mOutdoorWeight;
  143. SimObject* spawnObject(String additionalProps = String::EmptyString);
  144. static void initPersistFields();
  145. DECLARE_CONOBJECT(SpawnSphere);
  146. DECLARE_CALLBACK( void, onAdd, ( U32 objectId ) );
  147. };
  148. //------------------------------------------------------------------------------
  149. // Class: CameraBookmark
  150. //------------------------------------------------------------------------------
  151. class CameraBookmark : public MissionMarker
  152. {
  153. private:
  154. typedef MissionMarker Parent;
  155. public:
  156. enum WayPointMasks {
  157. UpdateNameMask = Parent::NextFreeMask,
  158. NextFreeMask = Parent::NextFreeMask << 1
  159. };
  160. CameraBookmark();
  161. // SimObject
  162. virtual bool onAdd();
  163. virtual void onRemove();
  164. virtual void onGroupAdd();
  165. virtual void onGroupRemove();
  166. void inspectPostApply();
  167. // NetObject
  168. U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
  169. void unpackUpdate(NetConnection *conn, BitStream *stream);
  170. // field data
  171. StringTableEntry mName;
  172. static void initPersistFields();
  173. DECLARE_CONOBJECT(CameraBookmark);
  174. /*DECLARE_CALLBACK( void, onAdd, () );
  175. DECLARE_CALLBACK( void, onRemove, () );
  176. DECLARE_CALLBACK( void, onGroupAdd, () );
  177. DECLARE_CALLBACK( void, onGroupRemove, () );
  178. DECLARE_CALLBACK( void, onInspectPostApply, () );*/
  179. };
  180. #endif // _MISSIONMARKER_H_