/// <summary> /// Restore the state of this Map from the specified MapState /// </summary> /// <param name="state">Mapstate POCO (Plain Old C# Object) which represents this Map and can be easily serialized and deserialized</param> /// <exception cref="ArgumentNullException">Thrown on null map state</exception> public void Load(MapState state) { if (state == null) { throw new ArgumentNullException("state", "Map state cannot be null"); } var inFov = new HashSet <int>(); Initialize(state.Width, state.Height); foreach (IBlock Block in GetAllBlocks()) { MapState.BlockProperties BlockProperties = state.Blocks[Block.Y * Width + Block.X]; if (EnumExtensions.HasFlag(BlockProperties, MapState.BlockProperties.Visible)) { inFov.Add(IndexFor(Block.X, Block.Y)); } Block.IsTransparent = EnumExtensions.HasFlag(BlockProperties, MapState.BlockProperties.Transparent); Block.IsWalkable = EnumExtensions.HasFlag(BlockProperties, MapState.BlockProperties.Walkable); } _fieldOfView = new FieldOfView(this, inFov); }