Advertisement
KakCAT

Untitled

May 2nd, 2014
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1.  
  2.         // variables to notify the reloading status via GetGraphicsReloadStatus
  3.         private bool _isContentBeingReloaded;
  4.         private int _currentReloadedAsset;
  5.  
  6.  
  7.         /// returns true when the graphics are being reloaded. False otherwise.
  8.         public bool GetGraphicsReloadStatus (out int currentAsset,out int totalAssets)
  9.         {
  10.             if (_isContentBeingReloaded)
  11.             {
  12.                 currentAsset=_currentReloadedAsset;
  13.                 totalAssets=LoadedAssets.Count;
  14.                 return true;
  15.             }
  16.             else
  17.             {
  18.                 currentAsset=0;
  19.                 totalAssets=0;
  20.                 return false;
  21.             }
  22.            
  23.         }
  24.  
  25.  
  26.  
  27.  
  28.  
  29.         protected virtual void ReloadGraphicsAssets()
  30.                 {
  31.             _currentReloadedAsset=0;
  32.             _isContentBeingReloaded=true;
  33.  
  34.             foreach (var asset in LoadedAssets)
  35.             {
  36.                 // This never executes as asset.Key is never null.  This just forces the
  37.                 // linker to include the ReloadAsset function when AOT compiled.
  38.                 if (asset.Key == null)
  39.                     ReloadAsset(asset.Key, Convert.ChangeType(asset.Value, asset.Value.GetType()));
  40.  
  41. #if WINDOWS_STOREAPP
  42.                 var methodInfo = typeof(ContentManager).GetType().GetTypeInfo().GetDeclaredMethod("ReloadAsset");
  43. #else
  44.                 var methodInfo = typeof(ContentManager).GetMethod("ReloadAsset", BindingFlags.NonPublic | BindingFlags.Instance);
  45. #endif
  46.                 var genericMethod = methodInfo.MakeGenericMethod(asset.Value.GetType());
  47.                 genericMethod.Invoke(this, new object[] { asset.Key, Convert.ChangeType(asset.Value, asset.Value.GetType()) });
  48.  
  49.                 _currentReloadedAsset++;
  50.             }
  51.  
  52.             _isContentBeingReloaded=false;
  53.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement