/// <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; }
/// <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; }
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; } }
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()); }
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; } }
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())); }