2
0

BsScriptResourceManager.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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* createScriptTexture2D(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* createScriptTexture2D(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. * Creates a new managed instance of the object.
  34. */
  35. ScriptFont* createScriptFont(const HFont& resourceHandle);
  36. /**
  37. * @note Throws an exception if resource for the handle already exists.
  38. * Initializes the ScriptResource with an existing managed instance.
  39. */
  40. ScriptFont* createScriptFont(MonoObject* existingInstance, const HFont& resourceHandle);
  41. /**
  42. * @note Throws an exception if resource for the handle already exists.
  43. * Initializes the ScriptResource with an existing managed instance.
  44. */
  45. ScriptManagedResource* createManagedResource(MonoObject* existingInstance, const HManagedResource& resourceHandle);
  46. /**
  47. * @note Returns nullptr if script resource doesn't exist.
  48. */
  49. ScriptTexture2D* getScriptTexture(const HTexture& resourceHandle);
  50. /**
  51. * @note Returns nullptr if script resource doesn't exist.
  52. */
  53. ScriptSpriteTexture* getScriptSpriteTexture(const HSpriteTexture& resourceHandle);
  54. /**
  55. * @note Returns nullptr if script resource doesn't exist.
  56. */
  57. ScriptManagedResource* getScriptManagedResource(const HManagedResource& resourceHandle);
  58. /**
  59. * @note Returns nullptr if script resource doesn't exist.
  60. */
  61. ScriptResourceBase* getScriptResource(const String& UUID);
  62. /**
  63. * @note Returns nullptr if script resource doesn't exist.
  64. */
  65. ScriptResourceBase* createScriptResource(const HResource& resource);
  66. void destroyScriptResource(ScriptResourceBase* resource);
  67. private:
  68. UnorderedMap<String, ScriptResourceBase*> mScriptResources;
  69. MonoClass* mTextureClass;
  70. MonoClass* mSpriteTextureClass;
  71. MonoClass* mFontClass;
  72. void throwExceptionIfInvalidOrDuplicate(const String& uuid) const;
  73. };
  74. }