Ejemplo n.º 1
0
        private static void AddContentManager(ContentManager contentManager)
        {
            lock (ContentManagerLock)
            {
                // Check if the list contains this content manager already.
                // Also take the opportunity to prune the list of any finalized content managers.
                bool contains = false;
                for (int i = ContentManagers.Count; i-- > 0;)
                {
                    if (!ContentManagers[i].TryGetTarget(out var target))
                    {
                        ContentManagers.RemoveAt(i);
                    }

                    if (ReferenceEquals(target, contentManager))
                    {
                        contains = true;
                    }
                }
                if (!contains)
                {
                    ContentManagers.Add(new WeakReference <ContentManager>(contentManager));
                }
            }
        }
Ejemplo n.º 2
0
        } // SortedContentManagers

        #endregion

        #endregion

        #region Constructor

        /// <summary>
        /// The ContentManager manages the loaded assets.
        /// To use it you have to create an instance of this class and set the CurrentContentManager static
        /// property of this class so that references the newly created ContentManager instance.
        /// All the assets that you load latter will be automatically managed by this content manager.
        /// You can unload or dispose it. In any case the loaded assets will be disposed.
        /// </summary>
        public GameObjectContentManager()
        {
            // Create a unique ID
            Id = uniqueIdCounter;
            uniqueIdCounter++;
            Name = "Content Manager";
            ContentManagers.Add(this);
            GameObjects = new List <GameObject>();
            areContentManagersSorted = false;
        } // GameObjectContentManager
        } // SortedContentManagers

        #endregion

        #endregion

        #region Constructor

        /// <summary>
        /// The ContentManager manages the loaded assets.
        /// To use it you have to create an instance of this class and set the CurrentContentManager static
        /// property of this class so that references the newly created ContentManager instance.
        /// All the assets that you load latter will be automatically managed by this content manager.
        /// You can unload or dispose it. In any case the loaded assets will be disposed.
        /// </summary>
        public AssetContentManager()
        {
            // Create a unique ID
            Id = uniqueIdCounter;
            uniqueIdCounter++;
            XnaContentManager = new Microsoft.Xna.Framework.Content.ContentManager(EngineManager.GameServices);
            Name = "Content Manager";
            ContentManagers.Add(this);
            Assets = new List <Asset>();
            areContentManagersSorted = false;
        } // AssetContentManager
Ejemplo n.º 4
0
        public void UpdateToEngine()
        {
            ContentManagers.Clear();

            foreach (var manager in FlatRedBall.FlatRedBallServices.ContentManagers)
            {
                ContentManagerViewModel managerViewModel = new ContentManagerViewModel();
                managerViewModel.UpdateTo(manager);

                ContentManagers.Add(managerViewModel);
            }
        }