interiorRes.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 _INTERIORRES_H_
  23. #define _INTERIORRES_H_
  24. #ifndef _TVECTOR_H_
  25. #include "core/util/tVector.h"
  26. #endif
  27. class Stream;
  28. class Interior;
  29. class GBitmap;
  30. class InteriorResTrigger;
  31. class InteriorPath;
  32. class InteriorPathFollower;
  33. class ForceField;
  34. class AISpecialNode;
  35. class ItrGameEntity;
  36. class InteriorResource
  37. {
  38. static const U32 smFileVersion;
  39. protected:
  40. Vector<Interior*> mDetailLevels;
  41. Vector<Interior*> mSubObjects;
  42. Vector<InteriorResTrigger*> mTriggers;
  43. Vector<InteriorPathFollower*> mInteriorPathFollowers;
  44. Vector<ForceField*> mForceFields;
  45. Vector<AISpecialNode*> mAISpecialNodes;
  46. Vector<ItrGameEntity*> mGameEntities;
  47. GBitmap* mPreviewBitmap;
  48. public:
  49. InteriorResource();
  50. ~InteriorResource();
  51. bool read(Stream& stream);
  52. bool write(Stream& stream) const;
  53. static GBitmap* extractPreview(Stream&);
  54. S32 getNumDetailLevels() const;
  55. S32 getNumSubObjects() const;
  56. S32 getNumTriggers() const;
  57. S32 getNumInteriorPathFollowers() const;
  58. S32 getNumForceFields() const;
  59. S32 getNumSpecialNodes() const;
  60. S32 getNumGameEntities() const;
  61. Interior* getDetailLevel(const U32);
  62. Interior* getSubObject(const U32);
  63. InteriorResTrigger* getTrigger(const U32);
  64. InteriorPathFollower* getInteriorPathFollower(const U32);
  65. ForceField* getForceField(const U32);
  66. AISpecialNode* getSpecialNode(const U32);
  67. ItrGameEntity* getGameEntity(const U32);
  68. };
  69. //--------------------------------------------------------------------------
  70. inline S32 InteriorResource::getNumDetailLevels() const
  71. {
  72. return mDetailLevels.size();
  73. }
  74. inline S32 InteriorResource::getNumSubObjects() const
  75. {
  76. return mSubObjects.size();
  77. }
  78. inline S32 InteriorResource::getNumTriggers() const
  79. {
  80. return mTriggers.size();
  81. }
  82. inline S32 InteriorResource::getNumSpecialNodes() const
  83. {
  84. return mAISpecialNodes.size();
  85. }
  86. inline S32 InteriorResource::getNumGameEntities() const
  87. {
  88. return mGameEntities.size();
  89. }
  90. inline S32 InteriorResource::getNumInteriorPathFollowers() const
  91. {
  92. return mInteriorPathFollowers.size();
  93. }
  94. inline S32 InteriorResource::getNumForceFields() const
  95. {
  96. return mForceFields.size();
  97. }
  98. inline Interior* InteriorResource::getDetailLevel(const U32 idx)
  99. {
  100. AssertFatal(idx < getNumDetailLevels(), "Error, out of bounds detail level!");
  101. if (idx < getNumDetailLevels())
  102. return mDetailLevels[idx];
  103. else
  104. return NULL;
  105. }
  106. inline Interior* InteriorResource::getSubObject(const U32 idx)
  107. {
  108. AssertFatal(idx < getNumSubObjects(), "Error, out of bounds subObject!");
  109. return mSubObjects[idx];
  110. }
  111. inline InteriorResTrigger* InteriorResource::getTrigger(const U32 idx)
  112. {
  113. AssertFatal(idx < getNumTriggers(), "Error, out of bounds trigger!");
  114. return mTriggers[idx];
  115. }
  116. inline InteriorPathFollower* InteriorResource::getInteriorPathFollower(const U32 idx)
  117. {
  118. AssertFatal(idx < getNumInteriorPathFollowers(), "Error, out of bounds path follower!");
  119. return mInteriorPathFollowers[idx];
  120. }
  121. inline ForceField* InteriorResource::getForceField(const U32 idx)
  122. {
  123. AssertFatal(idx < getNumForceFields(), "Error, out of bounds force field!");
  124. return mForceFields[idx];
  125. }
  126. inline AISpecialNode* InteriorResource::getSpecialNode(const U32 idx)
  127. {
  128. AssertFatal(idx < getNumSpecialNodes(), "Error, out of bounds Special Nodes!");
  129. return mAISpecialNodes[idx];
  130. }
  131. inline ItrGameEntity* InteriorResource::getGameEntity(const U32 idx)
  132. {
  133. AssertFatal(idx < getNumGameEntities(), "Error, out of bounds Game ENts!");
  134. return mGameEntities[idx];
  135. }
  136. #endif // _H_INTERIORRES_