예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapGrhWalls"/> class.
        /// </summary>
        /// <param name="contentPath">The content path.</param>
        /// <param name="createWall">Delegate describing how to create the <see cref="WallEntityBase"/>
        /// from an <see cref="IValueReader"/>.</param>
        public MapGrhWalls(ContentPaths contentPath, CreateWallEntityFromReaderHandler createWall)
        {
            Load(contentPath, createWall);

            // Listen for the addition and removal of walls
            GrhInfo.AddedNew += DeleteGrhDataWalls;
            GrhInfo.Removed += DeleteGrhDataWalls;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MapGrhWalls"/> class.
        /// </summary>
        /// <param name="contentPath">The content path.</param>
        /// <param name="createWall">Delegate describing how to create the <see cref="WallEntityBase"/>
        /// from an <see cref="IValueReader"/>.</param>
        public MapGrhWalls(ContentPaths contentPath, CreateWallEntityFromReaderHandler createWall)
        {
            Load(contentPath, createWall);

            // Listen for the addition and removal of walls
            GrhInfo.AddedNew += DeleteGrhDataWalls;
            GrhInfo.Removed  += DeleteGrhDataWalls;
        }
예제 #3
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;
            }
        }
예제 #4
0
        static KeyValuePair<GrhIndex, List<WallEntityBase>> ReadWalls(IValueReader r, CreateWallEntityFromReaderHandler createWall)
        {
            var grhIndex = r.ReadGrhIndex(_grhIndexValueKey);
            var walls = r.ReadManyNodes(_wallsNodeName, x => createWall(x));

            return new KeyValuePair<GrhIndex, List<WallEntityBase>>(grhIndex, walls.ToList());
        }
예제 #5
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;
            }
        }
예제 #6
0
        static KeyValuePair <GrhIndex, List <WallEntityBase> > ReadWalls(IValueReader r, CreateWallEntityFromReaderHandler createWall)
        {
            var grhIndex = r.ReadGrhIndex(_grhIndexValueKey);
            var walls    = r.ReadManyNodes(_wallsNodeName, x => createWall(x));

            return(new KeyValuePair <GrhIndex, List <WallEntityBase> >(grhIndex, walls.ToList()));
        }