#pragma once #include "BsScriptEnginePrerequisites.h" #include "BsModule.h" namespace BansheeEngine { class BS_SCR_BE_EXPORT ScriptObjectManager : public Module { public: ScriptObjectManager(); ~ScriptObjectManager(); void registerScriptObject(ScriptObjectBase* instance); void unregisterScriptObject(ScriptObjectBase* instance); void refreshAssemblies(); void update(); /** * @brief Call this when object finalizer is triggered. At the end of the frame * all objects queued with this method will have their _onManagedInstanceDeleted methods * triggered. * * @note Thread safe. */ void notifyObjectFinalized(ScriptObjectBase* instance); /** * @brief Triggers _onManagedInstanceDeleted deleted callbacks on all objects that were finalized this frame. * This allows the native portions of those objects to properly clean up any resources. * * @note Sim thread. */ void processFinalizedObjects(); /** * @brief Triggered right after a domain was reloaded. This signals the outside world that they should * update any kept Mono references as the old ones will no longer be valid. */ Event onRefreshDomainLoaded; Event onRefreshStarted; Event onRefreshComplete; private: Set mScriptObjects; Vector mFinalizedObjects[2]; UINT32 mFinalizedQueueIdx; BS_MUTEX(mMutex); }; }