Exemplo n.º 1
0
        /// <summary>
        /// Loads the data from file.
        /// </summary>
        /// <param name="contentPath">The content path to load the data from.</param>
        void Load(ContentPaths contentPath)
        {
            _npcChatDialogs.Clear();

            var filePath = GetFilePath(contentPath);

            if (!File.Exists(filePath))
            {
                _npcChatDialogs.Trim();
                return;
            }

            var reader = GenericValueReader.CreateFromFile(filePath, _rootNodeName);
            var items  = reader.ReadManyNodes(_chatDialogsNodeName, CreateDialog);

            for (var i = 0; i < items.Length; i++)
            {
                if (items[i] != null)
                {
                    _npcChatDialogs[i] = items[i];
                }
            }

            _npcChatDialogs.Trim();
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reads the state of the object from an <see cref="IValueReader"/>. Values should be read in the exact
        /// same order as they were written.
        /// </summary>
        /// <param name="reader">The <see cref="IValueReader"/> to read the values from.</param>
        void IPersistable.ReadState(IValueReader reader)
        {
            var items = reader.ReadManyNodes(_rootNodeName, r => new ActionDisplay(r));

            _items.Clear();

            foreach (var item in items)
            {
                Debug.Assert(!_items.CanGet((int)item.ID) || _items[(int)item.ID] == null, "This ID is already in use!");
                _items.Insert((int)item.ID, item);
            }
        }
Exemplo n.º 4
0
        static void ClearTestSub(bool trackFree)
        {
            const int size = 50;

            var d = new DArray<object>(trackFree);
            for (var i = 0; i < size; i++)
            {
                d[i] = new object();
            }

            d.Clear();

            Assert.AreEqual(0, d.Length);
            Assert.AreEqual(0, d.Count);

            object o;
            Assert.Throws<ArgumentOutOfRangeException>(() => o = d[0], "Failed to generate IndexOutOfRangeException for d[0].");
            Assert.IsFalse(d.CanGet(0));
        }
Exemplo n.º 5
0
        static void ClearTestSub(bool trackFree)
        {
            const int size = 50;

            var d = new DArray <object>(trackFree);

            for (var i = 0; i < size; i++)
            {
                d[i] = new object();
            }

            d.Clear();

            Assert.AreEqual(0, d.Length);
            Assert.AreEqual(0, d.Count);

            object o;

            Assert.Throws <ArgumentOutOfRangeException>(() => o = d[0], "Failed to generate IndexOutOfRangeException for d[0].");
            Assert.IsFalse(d.CanGet(0));
        }
Exemplo n.º 6
0
        public void Load(ContentPaths contentPath, CreateWallEntityFromReaderHandler createWall)
        {
            var filePath = GetFilePath(contentPath);

            // Clear the old walls in case this isn't the first load
            _walls.Clear();

            if (!File.Exists(filePath))
            {
                return;
            }

            // Read the values
            var reader      = XmlValueReader.CreateFromFile(filePath, _rootNodeName);
            var loadedWalls = reader.ReadManyNodes(_rootNodeName, x => ReadWalls(x, createWall));

            foreach (var wall in loadedWalls)
            {
                _walls[(int)wall.Key] = wall.Value;
            }
        }
 /// <summary>
 /// Removes all items from the <see cref="T:System.Collections.Generic.ICollection`1"/>.
 /// </summary>
 /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/>
 /// is read-only.</exception>
 public void Clear()
 {
     _questDescriptions.Clear();
 }