missionMarker.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 ) override;
  64. // SceneObject
  65. void setTransform(const MatrixF &mat) override;
  66. // SimObject
  67. bool onAdd() override;
  68. void onRemove() override;
  69. void onEditorEnable() override;
  70. void onEditorDisable() override;
  71. void inspectPostApply() override;
  72. // NetObject
  73. U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream) override;
  74. void unpackUpdate(NetConnection *conn, BitStream *stream) override;
  75. DECLARE_CONOBJECT(MissionMarker);
  76. DECLARE_CATEGORY("Markers");
  77. static void initPersistFields();
  78. };
  79. //------------------------------------------------------------------------------
  80. // Class: WayPoint
  81. //------------------------------------------------------------------------------
  82. class WayPoint;
  83. class WayPoint : public MissionMarker
  84. {
  85. private:
  86. typedef MissionMarker Parent;
  87. public:
  88. enum WayPointMasks {
  89. UpdateNameMask = Parent::NextFreeMask,
  90. UpdateTeamMask = Parent::NextFreeMask << 1,
  91. UpdateHiddenMask = Parent::NextFreeMask << 2,
  92. NextFreeMask = Parent::NextFreeMask << 3
  93. };
  94. WayPoint();
  95. // ShapeBase: only ever added to scene if in the editor
  96. void setHidden(bool hidden) override;
  97. // SimObject
  98. bool onAdd() override;
  99. void inspectPostApply() override;
  100. // NetObject
  101. U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream) override;
  102. void unpackUpdate(NetConnection *conn, BitStream *stream) override;
  103. // field data
  104. StringTableEntry mName;
  105. static void initPersistFields();
  106. DECLARE_CONOBJECT(WayPoint);
  107. };
  108. //------------------------------------------------------------------------------
  109. // Class: SpawnSphere
  110. //------------------------------------------------------------------------------
  111. class SpawnSphere : public MissionMarker
  112. {
  113. private:
  114. typedef MissionMarker Parent;
  115. public:
  116. SpawnSphere();
  117. // SimObject
  118. bool onAdd() override;
  119. void inspectPostApply() override;
  120. // NetObject
  121. enum SpawnSphereMasks
  122. {
  123. UpdateSphereMask = Parent::NextFreeMask,
  124. NextFreeMask = Parent::NextFreeMask << 1
  125. };
  126. U32 packUpdate (NetConnection *conn, U32 mask, BitStream *stream) override;
  127. void unpackUpdate(NetConnection *conn, BitStream *stream) override;
  128. // ProcessObject
  129. void advanceTime( F32 timeDelta ) override;
  130. void processTick( const Move *move ) override;
  131. // Spawn info
  132. String mSpawnClass;
  133. String mSpawnDataBlock;
  134. String mSpawnName;
  135. String mSpawnProperties;
  136. String mSpawnScript;
  137. bool mAutoSpawn;
  138. bool mSpawnTransform;
  139. /// returns the datablock spawned for this object
  140. StringTableEntry getTypeHint() const override { return (mSpawnDataBlock.isNotEmpty()) ? mSpawnDataBlock.c_str() : StringTable->EmptyString(); };
  141. // Radius/weight info
  142. F32 mRadius;
  143. F32 mSphereWeight;
  144. F32 mIndoorWeight;
  145. F32 mOutdoorWeight;
  146. SimObject* spawnObject(String additionalProps = String::EmptyString);
  147. static void initPersistFields();
  148. DECLARE_CONOBJECT(SpawnSphere);
  149. DECLARE_CALLBACK( void, onAdd, ( U32 objectId ) );
  150. };
  151. //------------------------------------------------------------------------------
  152. // Class: CameraBookmark
  153. //------------------------------------------------------------------------------
  154. class CameraBookmark : public MissionMarker
  155. {
  156. private:
  157. typedef MissionMarker Parent;
  158. public:
  159. enum WayPointMasks {
  160. UpdateNameMask = Parent::NextFreeMask,
  161. NextFreeMask = Parent::NextFreeMask << 1
  162. };
  163. CameraBookmark();
  164. // SimObject
  165. bool onAdd() override;
  166. void onRemove() override;
  167. void onGroupAdd() override;
  168. void onGroupRemove() override;
  169. void inspectPostApply() override;
  170. // NetObject
  171. U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream) override;
  172. void unpackUpdate(NetConnection *conn, BitStream *stream) override;
  173. // field data
  174. StringTableEntry mName;
  175. static void initPersistFields();
  176. DECLARE_CONOBJECT(CameraBookmark);
  177. DECLARE_CATEGORY("Markers");
  178. /*DECLARE_CALLBACK( void, onAdd, () );
  179. DECLARE_CALLBACK( void, onRemove, () );
  180. DECLARE_CALLBACK( void, onGroupAdd, () );
  181. DECLARE_CALLBACK( void, onGroupRemove, () );
  182. DECLARE_CALLBACK( void, onInspectPostApply, () );*/
  183. };
  184. #endif // _MISSIONMARKER_H_