Ejemplo n.º 1
0
        public void Save()
        {
            //save the house first
            var iff = new IffFile();

            vm.TS1State.UpdateSIMI(vm);
            var marshal = vm.Save();
            var fsov    = new FSOV();

            fsov.ChunkLabel     = "Simitone Lot Data";
            fsov.ChunkID        = 1;
            fsov.ChunkProcessed = true;
            fsov.ChunkType      = "FSOV";
            fsov.AddedByPatch   = true;

            using (var stream = new MemoryStream())
            {
                marshal.SerializeInto(new BinaryWriter(stream));
                fsov.Data = stream.ToArray();
            }

            iff.AddChunk(fsov);

            var simi = vm.TS1State.SimulationInfo;

            simi.ChunkProcessed = true;
            simi.AddedByPatch   = true;
            iff.AddChunk(simi);

            Texture2D roofless = null;
            var       thumb    = World.GetLotThumb(GameFacade.GraphicsDevice, (tex) => roofless = FSO.Common.Utils.TextureUtils.Decimate(tex, GameFacade.GraphicsDevice, 2, false));

            thumb = FSO.Common.Utils.TextureUtils.Decimate(thumb, GameFacade.GraphicsDevice, 2, false);

            var tPNG = GeneratePNG(thumb);

            tPNG.ChunkID = 513;
            iff.AddChunk(tPNG);

            var rPNG = GeneratePNG(roofless);

            rPNG.ChunkID = 512;
            iff.AddChunk(rPNG);

            Content.Get().Neighborhood.SaveHouse(vm.GetGlobalValue(10), iff);
            Content.Get().Neighborhood.SaveNeighbourhood(true);
        }