BsScriptResourceManager.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #pragma once
  2. #include "BsScriptEnginePrerequisites.h"
  3. #include "BsModule.h"
  4. #include <mono/jit/jit.h>
  5. namespace BansheeEngine
  6. {
  7. class BS_SCR_BE_EXPORT ScriptResourceManager : public Module<ScriptResourceManager>
  8. {
  9. public:
  10. ScriptResourceManager();
  11. /**
  12. * @note Throws an exception if resource for the handle already exists.
  13. * Creates a new managed instance of the object.
  14. */
  15. ScriptTexture2D* createScriptTexture(const HTexture& resourceHandle);
  16. /**
  17. * @note Throws an exception if resource for the handle already exists.
  18. * Initializes the ScriptResource with an existing managed instance.
  19. */
  20. ScriptTexture2D* createScriptTexture(MonoObject* existingInstance, const HTexture& resourceHandle);
  21. /**
  22. * @note Throws an exception if resource for the handle already exists.
  23. * Creates a new managed instance of the object.
  24. */
  25. ScriptSpriteTexture* createScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  26. /**
  27. * @note Throws an exception if resource for the handle already exists.
  28. * Initializes the ScriptResource with an existing managed instance.
  29. */
  30. ScriptSpriteTexture* createScriptSpriteTexture(MonoObject* existingInstance, const HSpriteTexture& resourceHandle);
  31. /**
  32. * @note Throws an exception if resource for the handle already exists.
  33. * Initializes the ScriptResource with an existing managed instance.
  34. */
  35. ScriptManagedResource* createManagedResource(MonoObject* existingInstance, const HManagedResource& resourceHandle);
  36. /**
  37. * @note Returns nullptr if script resource doesn't exist.
  38. */
  39. ScriptTexture2D* getScriptTexture(const HTexture& resourceHandle);
  40. /**
  41. * @note Returns nullptr if script resource doesn't exist.
  42. */
  43. ScriptSpriteTexture* getScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  44. /**
  45. * @note Returns nullptr if script resource doesn't exist.
  46. */
  47. ScriptManagedResource* getScriptManagedResource(const HManagedResource& resourceHandle);
  48. /**
  49. * @note Returns nullptr if script resource doesn't exist.
  50. */
  51. ScriptResourceBase* getScriptResource(const String& UUID);
  52. void destroyScriptResource(ScriptResourceBase* resource);
  53. private:
  54. UnorderedMap<String, ScriptResourceBase*> mScriptResources;
  55. MonoClass* mTextureClass;
  56. MonoClass* mSpriteTextureClass;
  57. void throwExceptionIfInvalidOrDuplicate(const String& uuid) const;
  58. };
  59. }