public void Reload(Map map)
 {
     using(var mapFile = new ZipFile(map.MapFileName))
         LoadDynamicData(map, mapFile);
     map.FindMainCharacter();
 }
        public List <Common.Tuple <String, System.Action> > GetLoadSteps(string filename, SlimDX.Direct3D9.Device device, out Map outMap)
        {
            var baseFileName = Path.GetFileName(filename);
            var map          = new Map {
                MapName = baseFileName, MapFileName = Path.GetFullPath(filename)
            };

            outMap = map;
            var mapFile = new ZipFile(filename);

            map.OnResetDevice = () => OnResetDevice(map);

            var a = new List <Common.Tuple <string, System.Action> >();

            a.Add(new Common.Tuple <string, System.Action>("Loading settings",
                                                           () => map.Settings = LoadSettings(baseFileName, mapFile)));

            a.Add(new Common.Tuple <string, System.Action>("Loading static data", () => LoadStaticData(map, mapFile)));
            a.Add(new Common.Tuple <string, System.Action>("Loading dynamic data", () => LoadDynamicData(map, mapFile)));
            a.Add(new Common.Tuple <string, System.Action>("Loading language data",
                                                           () => map.StringLocalizationStorage = LoadLanguageData(baseFileName, mapFile)));


            a.Add(new Common.Tuple <string, System.Action>("NormalizeStaticDynamicObjects",
                                                           map.NormalizeStaticDynamicObjects));

            a.Add(new Common.Tuple <string, System.Action>("Init scene root", () =>
            {
                foreach (var v in map.DynamicsRoot.Offspring)
                {
                    if (v is GameEntity)
                    {
                        ((GameEntity)v).Map = map;
                    }
                }

                foreach (var v in map.StaticsRoot.Offspring)
                {
                    if (v is GameEntity)
                    {
                        ((GameEntity)v).Map = map;
                    }
                }

                map.FindMainCharacter();
            }));

            a.Add(new Common.Tuple <string, System.Action>("Creating ground", () =>
            {
                map.Ground = new Ground();
                map.InitGround();
            }));

            a.Add(new Common.Tuple <string, System.Action>("Loading SplatMap", () => LoadSplatMap(map, device, mapFile)));

            a.Add(new Common.Tuple <string, System.Action>("Loading SplatMap2", () => LoadSplatMap2(map, device, mapFile)));


            a.Add(new Common.Tuple <string, System.Action>("Loading Heightmap", () => LoadHeightmap(map, mapFile)));
            a.Add(new Common.Tuple <string, System.Action>("Constructing ground pieces", () => map.Ground.ConstructPieces(map)));

            a.Add(new Common.Tuple <string, System.Action>("Initializing ground", () =>
            {
                if (map.Ground.SplatMap1 != null && map.Ground.SplatMap2 != null)
                {
                    map.Ground.Init();
                }
            }));

            a.Add(new Common.Tuple <string, System.Action>("Done", () =>
            {
                mapFile.Dispose();
            }));

            return(a);
        }
        public List<Common.Tuple<String, System.Action>> GetLoadSteps(string filename, SlimDX.Direct3D9.Device device, out Map outMap)
        {
            var baseFileName = Path.GetFileName(filename);
            var map = new Map { MapName = baseFileName, MapFileName = Path.GetFullPath(filename) };
            outMap = map;
            var mapFile = new ZipFile(filename);
            map.OnResetDevice = () => OnResetDevice(map);

            var a = new List<Common.Tuple<string, System.Action>>();

            a.Add(new Common.Tuple<string, System.Action>("Loading settings",
                () => map.Settings = LoadSettings(baseFileName, mapFile)));

            a.Add(new Common.Tuple<string, System.Action>("Loading static data", () => LoadStaticData(map, mapFile)));
            a.Add(new Common.Tuple<string, System.Action>("Loading dynamic data", () => LoadDynamicData(map, mapFile)));
            a.Add(new Common.Tuple<string, System.Action>("Loading language data",
                () => map.StringLocalizationStorage = LoadLanguageData(baseFileName, mapFile)));

            a.Add(new Common.Tuple<string, System.Action>("NormalizeStaticDynamicObjects",
                map.NormalizeStaticDynamicObjects));

            a.Add(new Common.Tuple<string, System.Action>("Init scene root", () =>
            {

                foreach (var v in map.DynamicsRoot.Offspring)
                    if (v is GameEntity)
                        ((GameEntity)v).Map = map;

                foreach (var v in map.StaticsRoot.Offspring)
                    if (v is GameEntity)
                        ((GameEntity)v).Map = map;

                map.FindMainCharacter();
            }));

            a.Add(new Common.Tuple<string, System.Action>("Creating ground", () =>
            {
                map.Ground = new Ground();
                map.InitGround();
            }));

            a.Add(new Common.Tuple<string, System.Action>("Loading SplatMap", () => LoadSplatMap(map, device, mapFile)));

            a.Add(new Common.Tuple<string, System.Action>("Loading SplatMap2", () => LoadSplatMap2(map, device, mapFile)));

            a.Add(new Common.Tuple<string, System.Action>("Loading Heightmap", () => LoadHeightmap(map, mapFile)));
            a.Add(new Common.Tuple<string, System.Action>("Constructing ground pieces", () => map.Ground.ConstructPieces(map)));

            a.Add(new Common.Tuple<string, System.Action>("Initializing ground", () =>
            {
                if (map.Ground.SplatMap1 != null && map.Ground.SplatMap2 != null)
                    map.Ground.Init();
            }));

            a.Add(new Common.Tuple<string, System.Action>("Done", () =>
            {
                mapFile.Dispose();
            }));

            return a;
        }
 public void Reload(Map map)
 {
     using (var mapFile = new ZipFile(map.MapFileName))
         LoadDynamicData(map, mapFile);
     map.FindMainCharacter();
 }