Beispiel #1
0
 public bool _LoadTextureResource(TPF tex, int index, AccessLevel al, GameType type)
 {
     lock (LoadingLock)
     {
         if (IsLoaded)
         {
             Unload();
         }
         AccessLevel = AccessLevel.AccessLoading;
         Resource    = new TextureResource(tex, index);
         Resource._LoadTexture(al);
         // Prevent any new completion handlers from being added while executing them all
         // Any subsequent pending handlers will be executed after this is done
         WeakReference <IResourceEventListener>[] listeners;
         lock (HandlerLock)
         {
             IsLoaded  = true;
             listeners = EventListeners.ToArray();
         }
         foreach (var listener in listeners)
         {
             try
             {
                 IResourceEventListener l;
                 bool succ = listener.TryGetTarget(out l);
                 if (succ)
                 {
                     l.OnResourceLoaded(this);
                 }
             }
             catch (Exception e)
             {
                 System.Console.WriteLine("blah");
             }
         }
         AccessLevel = al;
     }
     return(true);
 }