SubScene.h 2.8 KB

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