SubScene.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. private:
  21. DECLARE_LEVELASSET(SubScene, Level, onLevelChanged);
  22. StringTableEntry mGameModesNames;
  23. Vector<GameMode*> mGameModesList;
  24. F32 mScopeDistance;
  25. /// <summary>
  26. /// How long we wait once every control object has left the SubScene's load boundary for us to unload the levelAsset.
  27. /// </summary>
  28. S32 mStartUnloadTimerMS;
  29. bool mLoaded;
  30. bool mFreezeLoading;
  31. String mLoadIf;
  32. String mOnLoadCommand;
  33. String mOnUnloadCommand;
  34. S32 mTickPeriodMS;
  35. U32 mCurrTick;
  36. bool mGlobalLayer;
  37. public:
  38. SubScene();
  39. virtual ~SubScene();
  40. DECLARE_CONOBJECT(SubScene);
  41. DECLARE_CATEGORY("Object \t Collection");
  42. static void initPersistFields();
  43. static void consoleInit();
  44. StringTableEntry getTypeHint() const override { return (getLevelAsset()) ? getLevelAsset()->getAssetName() : StringTable->EmptyString(); }
  45. // SimObject
  46. bool onAdd() override;
  47. void onRemove() override;
  48. U32 packUpdate(NetConnection* conn, U32 mask, BitStream* stream) override;
  49. void unpackUpdate(NetConnection* conn, BitStream* stream) override;
  50. void addObject(SimObject* object);
  51. void removeObject(SimObject* object);
  52. //void onEditorEnable() override;
  53. //void onEditorDisable() override;
  54. void inspectPostApply() override;
  55. bool testBox(const Box3F& testBox);
  56. bool evaluateCondition();
  57. void _onSelected() override;
  58. void _onUnselected() override;
  59. static S32 mUnloadTimeoutMs;
  60. protected:
  61. void write(Stream& stream, U32 tabStop, U32 flags = 0) override;
  62. //
  63. void _onFileChanged(const Torque::Path& path);
  64. void _removeContents(SimGroupIterator);
  65. void _closeFile(bool removeFileNotify);
  66. void _loadFile(bool addFileNotify);
  67. //
  68. public:
  69. void processTick(const Move* move) override;
  70. //
  71. void onInspect(GuiInspector* inspector) override;
  72. void load();
  73. void unload();
  74. void prepRenderImage(SceneRenderState* state) override;
  75. void renderObject(ObjectRenderInst* ri,
  76. SceneRenderState* state,
  77. BaseMatInstance* overrideMat);
  78. bool isLoaded() { return mLoaded; }
  79. void setUnloadTimeMS(S32 unloadTimeMS) {
  80. mStartUnloadTimerMS = unloadTimeMS;
  81. }
  82. inline S32 getUnloadTimsMS() {
  83. return mStartUnloadTimerMS;
  84. }
  85. bool save();
  86. DECLARE_CALLBACK(void, onLoaded, ());
  87. DECLARE_CALLBACK(void, onUnloaded, ());
  88. DECLARE_ASSET_SETGET(SubScene, Level);
  89. };
  90. #endif