ResourceRef.cs 1.4 KB

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