ResourceRef.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. namespace BansheeEngine
  6. {
  7. /** @addtogroup Resources
  8. * @{
  9. */
  10. /// <summary>
  11. /// Allows you to store a reference to a resource without needing to have that resource loaded.
  12. /// </summary>
  13. public class ResourceRef : ScriptObject
  14. {
  15. /// <summary>
  16. /// Constructor for internal use only.
  17. /// </summary>
  18. protected ResourceRef()
  19. { }
  20. /// <summary>
  21. /// Checks is the referenced resource loaded.
  22. /// </summary>
  23. public bool IsLoaded
  24. {
  25. get { return Internal_IsLoaded(mCachedPtr); }
  26. }
  27. /// <inheritdoc/>
  28. public override bool Equals(object other)
  29. {
  30. if (!(other is ResourceRef))
  31. return false;
  32. ResourceRef otherRef = (ResourceRef)other;
  33. return Internal_GetUUID(mCachedPtr).Equals(Internal_GetUUID(otherRef.mCachedPtr));
  34. }
  35. /// <inheritdoc/>
  36. public override int GetHashCode()
  37. {
  38. return Internal_GetUUID(mCachedPtr).GetHashCode();
  39. }
  40. [MethodImpl(MethodImplOptions.InternalCall)]
  41. private static extern bool Internal_IsLoaded(IntPtr thisPtr);
  42. [MethodImpl(MethodImplOptions.InternalCall)]
  43. protected static extern Resource Internal_GetResource(IntPtr thisPtr);
  44. [MethodImpl(MethodImplOptions.InternalCall)]
  45. private static extern string Internal_GetUUID(IntPtr thisPtr);
  46. }
  47. /** @} */
  48. }