ResourceRef.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /// <summary>
  8. /// Allows you to store a reference to a resource without needing to have that resource loaded.
  9. /// </summary>
  10. public class ResourceRef : ScriptObject
  11. {
  12. /// <summary>
  13. /// Constructor for internal use only.
  14. /// </summary>
  15. protected ResourceRef()
  16. { }
  17. /// <summary>
  18. /// Checks is the referenced resource loaded
  19. /// </summary>
  20. public bool IsLoaded
  21. {
  22. get { return Internal_IsLoaded(mCachedPtr); }
  23. }
  24. /// <inheritdoc/>
  25. public override bool Equals(object other)
  26. {
  27. if (!(other is ResourceRef))
  28. return false;
  29. ResourceRef otherRef = (ResourceRef)other;
  30. return Internal_GetUUID(mCachedPtr).Equals(Internal_GetUUID(otherRef.mCachedPtr));
  31. }
  32. /// <inheritdoc/>
  33. public override int GetHashCode()
  34. {
  35. return Internal_GetUUID(mCachedPtr).GetHashCode();
  36. }
  37. [MethodImpl(MethodImplOptions.InternalCall)]
  38. private static extern bool Internal_IsLoaded(IntPtr thisPtr);
  39. [MethodImpl(MethodImplOptions.InternalCall)]
  40. protected static extern Resource Internal_GetResource(IntPtr thisPtr);
  41. [MethodImpl(MethodImplOptions.InternalCall)]
  42. private static extern string Internal_GetUUID(IntPtr thisPtr);
  43. }
  44. }