SubScene.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #pragma once
  2. #ifndef SUB_SCENE_H
  3. #define SUB_SCENE_H
  4. #ifndef SCENE_GROUP_H
  5. #include "SceneGroup.h"
  6. #endif
  7. #ifndef SUBSCENE_ASSET_H
  8. #include "assets/SubSceneAsset.h"
  9. #endif
  10. class GameMode;
  11. class SubScene : public SceneGroup
  12. {
  13. typedef SceneGroup Parent;
  14. public:
  15. enum MaskBits
  16. {
  17. NextFreeMask = Parent::NextFreeMask << 0
  18. };
  19. void onSubSceneChanged() {}
  20. protected:
  21. static bool smTransformChildren;
  22. private:
  23. DECLARE_SUBSCENEASSET(SubScene, SubScene, onSubSceneChanged);
  24. StringTableEntry mGameModesNames;
  25. Vector<GameMode*> mGameModesList;
  26. F32 mScopeDistance;
  27. /// <summary>
  28. /// How long we wait once every control object has left the SubScene's load boundary for us to unload the levelAsset.
  29. /// </summary>
  30. S32 mStartUnloadTimerMS;
  31. bool mLoaded;
  32. bool mSaving;
  33. bool mFreezeLoading;
  34. String mLoadIf;
  35. String mOnLoadCommand;
  36. String mOnUnloadCommand;
  37. S32 mTickPeriodMS;
  38. U32 mCurrTick;
  39. bool mGlobalLayer;
  40. bool mUseSeparateLoadBounds;
  41. Point3F mLoadBounds;
  42. public:
  43. SubScene();
  44. virtual ~SubScene();
  45. DECLARE_CONOBJECT(SubScene);
  46. DECLARE_CATEGORY("Object \t Collection");
  47. static void initPersistFields();
  48. static void consoleInit();
  49. StringTableEntry getTypeHint() const override { return (getSubSceneAsset()) ? getSubSceneAsset()->getAssetName() : StringTable->EmptyString(); }
  50. // SimObject
  51. bool onAdd() override;
  52. void onRemove() override;
  53. U32 packUpdate(NetConnection* conn, U32 mask, BitStream* stream) override;
  54. void unpackUpdate(NetConnection* conn, BitStream* stream) override;
  55. void addObject(SimObject* object);
  56. void removeObject(SimObject* object);
  57. //void onEditorEnable() override;
  58. //void onEditorDisable() override;
  59. void inspectPostApply() override;
  60. void setTransform(const MatrixF& mat) override;
  61. void setRenderTransform(const MatrixF& mat) override;
  62. bool testBox(const Box3F& testBox);
  63. bool evaluateCondition();
  64. void _onSelected() override;
  65. void _onUnselected() override;
  66. static S32 mUnloadTimeoutMs;
  67. protected:
  68. void write(Stream& stream, U32 tabStop, U32 flags = 0) override;
  69. //
  70. void _onFileChanged(const Torque::Path& path);
  71. void _removeContents(SimGroupIterator);
  72. void _closeFile(bool removeFileNotify);
  73. void _loadFile(bool addFileNotify);
  74. //
  75. public:
  76. void processTick(const Move* move) override;
  77. //
  78. void onInspect(GuiInspector* inspector) override;
  79. void load();
  80. void unload();
  81. void prepRenderImage(SceneRenderState* state) override;
  82. void renderObject(ObjectRenderInst* ri,
  83. SceneRenderState* state,
  84. BaseMatInstance* overrideMat);
  85. bool isLoaded() { return mLoaded; }
  86. void setUnloadTimeMS(S32 unloadTimeMS) {
  87. mStartUnloadTimerMS = unloadTimeMS;
  88. }
  89. inline S32 getUnloadTimsMS() {
  90. return mStartUnloadTimerMS;
  91. }
  92. bool save(const String& filename = String());
  93. DECLARE_CALLBACK(void, onLoaded, ());
  94. DECLARE_CALLBACK(void, onUnloaded, ());
  95. DECLARE_ASSET_SETGET(SubScene, SubScene);
  96. };
  97. #endif