コード例 #1
0
ファイル: StationaryGrhData.cs プロジェクト: Furt/netgore
 /// <summary>
 /// Initializes a new instance of the <see cref="StationaryGrhData"/> class.
 /// </summary>
 /// <param name="autoGrhData">The <see cref="AutomaticAnimatedGrhData"/>.</param>
 /// <param name="assetName">Name of the asset.</param>
 internal StationaryGrhData(AutomaticAnimatedGrhData autoGrhData, TextureAssetName assetName)
     : base(autoGrhData.Categorization)
 {
     _cm = autoGrhData.ContentManager;
     _textureName = assetName;
     AutomaticSize = true;
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StationaryGrhData"/> class.
 /// </summary>
 /// <param name="autoGrhData">The <see cref="AutomaticAnimatedGrhData"/>.</param>
 /// <param name="assetName">Name of the asset.</param>
 internal StationaryGrhData(AutomaticAnimatedGrhData autoGrhData, TextureAssetName assetName)
     : base(autoGrhData.Categorization)
 {
     _cm           = autoGrhData.ContentManager;
     _textureName  = assetName;
     AutomaticSize = true;
 }
コード例 #3
0
ファイル: GrhInfo.cs プロジェクト: wtfcolt/game
        public static void Load(ContentPaths contentPath, IContentManager cm)
        {
            if (IsLoaded)
            {
                return;
            }

            _isLoaded = true;

            var path = GetGrhDataFilePath(contentPath);

            if (cm == null)
            {
                throw new ArgumentNullException("cm");
            }

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("GrhData data file not found.", path);
            }

            _isLoading = true;

            try
            {
                // Create the GrhData DArray
                if (_grhDatas == null)
                {
                    _grhDatas = new DArray <GrhData>(256);
                }
                else
                {
                    _grhDatas.Clear();
                }

                _catDic.Clear();

                _grhDatas.ItemAdded -= AddHandler;
                _grhDatas.ItemAdded += AddHandler;

                _grhDatas.ItemRemoved -= RemoveHandler;
                _grhDatas.ItemRemoved += RemoveHandler;

                // Read and add the GrhDatas in order by their type
                var reader = GenericValueReader.CreateFromFile(path, _rootNodeName);

                LoadGrhDatas(reader, _nonAnimatedGrhDatasNodeName, x => StationaryGrhData.Read(x, cm));
                LoadGrhDatas(reader, _animatedGrhDatasNodeName, AnimatedGrhData.Read);
                LoadGrhDatas(reader, _autoAnimatedGrhDatasNodeName, x => AutomaticAnimatedGrhData.Read(x, cm));

                // Trim down the GrhData array, mainly for the client since it will never add/remove any GrhDatas
                // while in the Client, and the Client is what counts, baby!
                _grhDatas.Trim();
            }
            finally
            {
                _isLoading = false;
            }
        }
コード例 #4
0
ファイル: GrhInfo.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Creates a new <see cref="AutomaticAnimatedGrhData"/>. This should only be called from the
        /// AutomaticGrhDataUpdater.
        /// </summary>
        /// <param name="contentManager">The content manager.</param>
        /// <param name="categorization">The categorization for the <see cref="AutomaticAnimatedGrhData"/>.</param>
        /// <returns>The new <see cref="AutomaticAnimatedGrhData"/>, or null if none created.</returns>
        public static AutomaticAnimatedGrhData CreateAutomaticAnimatedGrhData(IContentManager contentManager,
                                                                              SpriteCategorization categorization)
        {
            // Check if the GrhData already exists
            if (GetData(categorization) != null)
            {
                return(null);
            }

            var index = NextFreeIndex();
            var gd    = new AutomaticAnimatedGrhData(contentManager, index, categorization);

            AddGrhData(gd);
            return(gd);
        }