SubScene.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 LEVEL_ASSET_H
  8. #include "assets/LevelAsset.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 onLevelChanged() {}
  20. protected:
  21. static bool smTransformChildren;
  22. private:
  23. DECLARE_LEVELASSET(SubScene, Level, onLevelChanged);
  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. public:
  41. SubScene();
  42. virtual ~SubScene();
  43. DECLARE_CONOBJECT(SubScene);
  44. DECLARE_CATEGORY("Object \t Collection");
  45. static void initPersistFields();
  46. static void consoleInit();
  47. StringTableEntry getTypeHint() const override { return (getLevelAsset()) ? getLevelAsset()->getAssetName() : StringTable->EmptyString(); }
  48. // SimObject
  49. bool onAdd() override;
  50. void onRemove() override;
  51. U32 packUpdate(NetConnection* conn, U32 mask, BitStream* stream) override;
  52. void unpackUpdate(NetConnection* conn, BitStream* stream) override;
  53. void addObject(SimObject* object);
  54. void removeObject(SimObject* object);
  55. //void onEditorEnable() override;
  56. //void onEditorDisable() override;
  57. void inspectPostApply() override;
  58. void setTransform(const MatrixF& mat) override;
  59. void setRenderTransform(const MatrixF& mat) override;
  60. bool testBox(const Box3F& testBox);
  61. bool evaluateCondition();
  62. void _onSelected() override;
  63. void _onUnselected() override;
  64. static S32 mUnloadTimeoutMs;
  65. protected:
  66. void write(Stream& stream, U32 tabStop, U32 flags = 0) override;
  67. //
  68. void _onFileChanged(const Torque::Path& path);
  69. void _removeContents(SimGroupIterator);
  70. void _closeFile(bool removeFileNotify);
  71. void _loadFile(bool addFileNotify);
  72. //
  73. public:
  74. void processTick(const Move* move) override;
  75. //
  76. void onInspect(GuiInspector* inspector) override;
  77. void load();
  78. void unload();
  79. void prepRenderImage(SceneRenderState* state) override;
  80. void renderObject(ObjectRenderInst* ri,
  81. SceneRenderState* state,
  82. BaseMatInstance* overrideMat);
  83. bool isLoaded() { return mLoaded; }
  84. void setUnloadTimeMS(S32 unloadTimeMS) {
  85. mStartUnloadTimerMS = unloadTimeMS;
  86. }
  87. inline S32 getUnloadTimsMS() {
  88. return mStartUnloadTimerMS;
  89. }
  90. bool save();
  91. DECLARE_CALLBACK(void, onLoaded, ());
  92. DECLARE_CALLBACK(void, onUnloaded, ());
  93. DECLARE_ASSET_SETGET(SubScene, Level);
  94. };
  95. #endif