CEngineSharp_Client.World.Map.LoadCache C# (CSharp) Method

LoadCache() public method

public LoadCache ( string mapName ) : void
mapName string
return void
        public void LoadCache(string mapName)
        {
            using (var fileStream = new FileStream(Constants.FILEPATH_CACHE + "Maps/" + mapName + ".map", FileMode.OpenOrCreate))
            {
                using (var binaryReader = new BinaryReader(fileStream))
                {
                    this.Name = binaryReader.ReadString();

                    this.Version = binaryReader.ReadInt32();

                    var mapWidth = binaryReader.ReadInt32();
                    var mapHeight = binaryReader.ReadInt32();

                    this.ResizeMap(mapWidth, mapHeight);

                    for (int x = 0; x < mapWidth; x++)
                    {
                        for (int y = 0; y < mapHeight; y++)
                        {
                            this.SetTile(x, y, new Map.Tile());

                            this.GetTile(x, y).Blocked = binaryReader.ReadBoolean();

                            foreach (Map.Layers layer in Enum.GetValues(typeof(Map.Layers)))
                            {
                                if (binaryReader.ReadBoolean() == false) continue;

                                var tileSetTextureName = binaryReader.ReadString();
                                var tileLeft = binaryReader.ReadInt32();
                                var tileTop = binaryReader.ReadInt32();
                                var tileWidth = binaryReader.ReadInt32();
                                var tileHeight = binaryReader.ReadInt32();

                                var tileRect = new IntRect(tileLeft, tileTop, tileWidth, tileHeight);

                                this.GetTile(x, y).SetLayer(layer, new Tile.Layer(new Sprite(ServiceLocator.ScreenManager.ActiveScreen.TextureManager.GetTexture(tileSetTextureName), tileRect), x, y));
                            }
                        }
                    }
                }
            }
        }