/// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        public Blueprint LoadFromXML(XmlHouseData model)
        {
            this.Blueprint = new Blueprint(model.Size, model.Size);
            VM.Context.Blueprint = Blueprint;
            VM.Context.Architecture = new VMArchitecture(model.Size, model.Size, Blueprint, VM.Context);

            var arch = VM.Context.Architecture;

            foreach (var floor in model.World.Floors){
                arch.SetFloor(floor.X, floor.Y, (sbyte)(floor.Level+1), new FloorTile { Pattern = (ushort)floor.Value }, true);
            }

            foreach (var wall in model.World.Walls)
            {
                arch.SetWall((short)wall.X, (short)wall.Y, (sbyte)(wall.Level+1), new WallTile() //todo: these should read out in their intended formats - a cast shouldn't be necessary
                {
                    Segments = wall.Segments,
                    TopLeftPattern = (ushort)wall.TopLeftPattern,
                    TopRightPattern = (ushort)wall.TopRightPattern,
                    BottomLeftPattern = (ushort)wall.BottomLeftPattern,
                    BottomRightPattern = (ushort)wall.BottomRightPattern,
                    TopLeftStyle = (ushort)wall.LeftStyle,
                    TopRightStyle = (ushort)wall.RightStyle
                });
            }
            arch.RegenRoomMap();
            VM.Context.RegeneratePortalInfo();

            foreach (var obj in model.Objects)
            {
                //if (obj.Level == 0) continue;
                //if (obj.GUID == "0xE9CEB12F") obj.GUID = "0x01A0FD79"; //replace onlinejobs door with a normal one
                //if (obj.GUID == "0x346FE2BC") obj.GUID = "0x98E0F8BD"; //replace kitchen door with a normal one
                CreateObject(obj);
            }

            foreach (var obj in model.Sounds) {
                VM.Context.Ambience.SetAmbience(VM.Context.Ambience.GetAmbienceFromGUID(obj.ID), (obj.On == 1));
            }

            var testObject = new XmlHouseDataObject(); //test npc controller, not normally present on a job lot.
            testObject.GUID = "0x70F69082";
            testObject.X = 0;
            testObject.Y = 0;
            testObject.Level = 1;
            testObject.Dir = 0;
            CreateObject(testObject);

            Blueprint.Terrain = CreateTerrain(model);
            World.State.WorldSize = model.Size;

            arch.Tick();
            return this.Blueprint;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        public Blueprint LoadFromXML(XmlHouseData model)
        {
            this.Blueprint = new Blueprint(model.Size, model.Size);
            foreach (var obj in model.Objects.Where(x => x.Level == 1)){
                CreateObject(obj);
            }
            foreach (var floor in model.World.Floors.Where(x => x.Level == 0)){
                Blueprint.SetFloor(floor.X, floor.Y, new FloorComponent() { FloorID = (ushort)floor.Value });
            }

            Blueprint.Terrain = CreateTerrain(model);
            World.State.WorldSize = model.Size;
            return this.Blueprint;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        public Blueprint LoadFromXML(XmlHouseData model)
        {
            this.Blueprint = new Blueprint(model.Size, model.Size);
            foreach (var obj in model.Objects.Where(x => x.Level == 1)){
                CreateObject(obj);
            }
            foreach (var floor in model.World.Floors.Where(x => x.Level == 0)){
                Blueprint.SetFloor(floor.X, floor.Y, new FloorComponent() { FloorID = (ushort)floor.Value });
            }

            var testAquarium = new XmlHouseDataObject(); //used to create an aquarium to test with on the lot. remove this before final! (cant be giving out free aquariums!!)
            testAquarium.GUID = "0x98E0F8BD";
            testAquarium.X = 32;
            testAquarium.Y = 53;
            testAquarium.Level = 1;
            testAquarium.Dir = 4;
            CreateObject(testAquarium);

            Blueprint.Terrain = CreateTerrain(model);
            World.State.WorldSize = model.Size;
            return this.Blueprint;
        }
 private TerrainComponent CreateTerrain(XmlHouseData model)
 {
     var terrain = new TerrainComponent(new Rectangle(1, 1, model.Size - 2, model.Size - 2));
     this.InitWorldComponent(terrain);
     return terrain;
 }
        public void SaveHouse(VM vm, string path)
        {
            if (vm.Context.Blueprint != null)
            {
                housedata = new XmlHouseData();
                housedata.World = new XmlHouseDataWorld();
                housedata.World.Floors = new List<XmlHouseDataFloor>();
                housedata.World.Walls = new List<XmlHouseDataWall>();
                housedata.Objects = new List<XmlHouseDataObject>();

            }

            var HouseWidth = vm.Context.Blueprint.Width;
            var HouseHeight = vm.Context.Blueprint.Height;
            var Levels = vm.Context.Blueprint.Stories;
            housedata.Size = HouseWidth;

            for (short x = 0; x < HouseWidth; x++)
            {
                for (short y = 0; y < HouseHeight; y++)
                {
                    for (sbyte z = 1; z <= Levels; z++)
                        if (vm.Context.Architecture.GetFloor(x, y, z).Pattern != 0)
                        {
                            var Floor = vm.Context.Architecture.GetFloor(x, y, z);
                            housedata.World.Floors.Add(new XmlHouseDataFloor()
                            {
                                X = x,
                                Y = y,
                                Value = Floor.Pattern,
                                Level = z - 1
                            });
                        }

                    for (sbyte z = 1; z <= Levels; z++)
                    {
                        if (vm.Context.Architecture.GetWall(x, y, z).Segments != 0)
                        {
                            var Wall = vm.Context.Architecture.GetWall(x, y, z);
                            housedata.World.Walls.Add(new XmlHouseDataWall()
                            {
                                X = x,
                                Y = y,
                                Segments = Wall.Segments,
                                Placement = 0,
                                TopLeftPattern = Wall.TopLeftPattern,
                                TopRightPattern = Wall.TopRightPattern,
                                LeftStyle = Wall.TopLeftStyle,
                                RightStyle = Wall.TopRightStyle,
                                BottomLeftPattern = Wall.BottomLeftPattern,
                                BottomRightPattern = Wall.BottomRightPattern,
                                Level = z - 1

                            });
                        }
                    }
                }
            }

            foreach (var entity in vm.Entities)
            {
                if (entity != entity.MultitileGroup.BaseObject || entity is VMAvatar) continue;

                uint GUID = (entity.MultitileGroup.MultiTile)?entity.MasterDefinition.GUID:entity.Object.OBJ.GUID;

                housedata.Objects.Add(new XmlHouseDataObject()
                {
                    GUID = "0x" + GUID.ToString("X"),
                    X = entity.Position.TileX,
                    Y = entity.Position.TileY,
                    Level = (entity.Position == LotTilePos.OUT_OF_WORLD) ? 0 : entity.Position.Level,
                    Dir = (int)Math.Round(Math.Log((double)entity.Direction, 2))
                });
            }

            XmlHouseData.Save(path, housedata);
        }
예제 #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="model"></param>
        public Blueprint LoadFromXML(XmlHouseData model)
        {
            this.Blueprint = new Blueprint(model.Size, model.Size);
            VM.Context.Blueprint = Blueprint;

            foreach (var floor in model.World.Floors.Where(x => x.Level == 0)){
                Blueprint.SetFloor(floor.X, floor.Y, new FloorComponent() { FloorID = (ushort)floor.Value });
            }

            foreach (var wall in model.World.Walls.Where(x => x.Level == 0))
            {
                Blueprint.SetWall((short)wall.X, (short)wall.Y, new WallTile()
                {
                    Segments = wall.Segments,
                    TopLeftPattern = (ushort)wall.TopLeftPattern,
                    TopRightPattern = (ushort)wall.TopRightPattern,
                    BottomLeftPattern = (ushort)wall.BottomLeftPattern,
                    BottomRightPattern = (ushort)wall.BottomRightPattern,
                    TopLeftStyle = (ushort)wall.LeftStyle,
                    TopRightStyle = (ushort)wall.RightStyle
                });
            }
            Blueprint.RegenRoomMap();
            VM.Context.RegeneratePortalInfo();

            foreach (var obj in model.Objects.Where(x => x.Level == 1))
            {
                if (obj.GUID == "0xE3ABB5F3") obj.GUID = "0x01A0FD79"; //replace onlinejobs door with a normal one
                if (obj.GUID == "0x346FE2BC") obj.GUID = "0x98E0F8BD"; //replace kitchen door with a normal one
                CreateObject(obj);
            }

            foreach (var obj in model.Sounds) {
                VM.Context.Ambience.SetAmbience(VM.Context.Ambience.GetAmbienceFromGUID(obj.ID), (obj.On == 1));
            }

            var testAquarium = new XmlHouseDataObject(); //used to create an aquarium to test with on the lot. remove this before final! (cant be giving out free aquariums!!)
            testAquarium.GUID = "0x98E0F8BD";
            testAquarium.X = 33;
            testAquarium.Y = 57;
            testAquarium.Level = 1;
            testAquarium.Dir = 4;
            CreateObject(testAquarium);

            testAquarium = new XmlHouseDataObject(); //test stove
            testAquarium.GUID = "0xE542C148";
            testAquarium.X = 46;
            testAquarium.Y = 35;
            testAquarium.Level = 1;
            testAquarium.Dir = 1;
            CreateObject(testAquarium);

            testAquarium = new XmlHouseDataObject(); //parrot
            testAquarium.GUID = "0x03BB9D8A";
            testAquarium.X = 33;
            testAquarium.Y = 59;
            testAquarium.Level = 1;
            testAquarium.Dir = 4;
            CreateObject(testAquarium);

            var testCounter = new XmlHouseDataObject(); //test fridge
            testCounter.GUID = "0x675C18AF";
            testCounter.X = 34;
            testCounter.Y = 53;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test hat rack
            testCounter.GUID = "0x01DACE5C";
            testCounter.X = 36;
            testCounter.Y = 53;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test tp1
            testCounter.GUID = "0x96a776ce";
            testCounter.X = 40;
            testCounter.Y = 53;
            testCounter.Level = 1;
            testCounter.Dir = 0;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test Pet Gym
            testCounter.GUID = "0x3360D50A";
            testCounter.X = 10;
            testCounter.Y = 53;
            testCounter.Level = 1;
            testCounter.Dir = 0;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test tp2
            testCounter.GUID = "0x96a776ce";
            testCounter.X = 20;
            testCounter.Y = 53;
            testCounter.Level = 1;
            testCounter.Dir = 0;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test piano
            testCounter.GUID = "0x379EE047";
            testCounter.X = 20;
            testCounter.Y = 20;
            testCounter.Level = 1;
            testCounter.Dir = 2;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test limo
            testCounter.GUID = "0x9750EA9D";
            testCounter.X = 30;
            testCounter.Y = 30;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test Fountain
            testCounter.GUID = "0x3565E02A";
            testCounter.X = 20;
            testCounter.Y = 30;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test Aqu2
            testCounter.GUID = "0x2FC9B87D";
            testCounter.X = 35;
            testCounter.Y = 36;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            //tv arrangement

            testCounter = new XmlHouseDataObject(); //test tv
            testCounter.GUID = "0x5FA381C1";
            testCounter.X = 15;
            testCounter.Y = 45;
            testCounter.Level = 1;
            testCounter.Dir = 0;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test tv
            testCounter.GUID = "0x5FA381C1";
            testCounter.X = 16;
            testCounter.Y = 46;
            testCounter.Level = 1;
            testCounter.Dir = 2;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test tv
            testCounter.GUID = "0x5FA381C1";
            testCounter.X = 15;
            testCounter.Y = 47;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test tv
            testCounter.GUID = "0x5FA381C1";
            testCounter.X = 14;
            testCounter.Y = 46;
            testCounter.Level = 1;
            testCounter.Dir = 6;
            CreateObject(testCounter);

            //sofa
            //0x87D00ADC

            testCounter = new XmlHouseDataObject(); //test tv
            testCounter.GUID = "0x87D00ADC";
            testCounter.X = 20;
            testCounter.Y = 47;
            testCounter.Level = 1;
            testCounter.Dir = 6;
            CreateObject(testCounter);

            //end tv arrangement

            testCounter = new XmlHouseDataObject(); //test bed
            testCounter.GUID = "0x17579980";
            testCounter.X = 35;
            testCounter.Y = 45;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test mech bull
            testCounter.GUID = "0x5E8B157A";
            testCounter.X = 25;
            testCounter.Y = 40;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test hot tub
            testCounter.GUID = "0x8FED54C2";
            testCounter.X = 15;
            testCounter.Y = 40;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test pinball
            testCounter.GUID = "0x481A74EC";
            testCounter.X = 25;
            testCounter.Y = 45;
            testCounter.Level = 1;
            testCounter.Dir = 4;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test npc control
            testCounter.GUID = "0x70F69082";
            testCounter.X = 0;
            testCounter.Y = 0;
            testCounter.Level = 1;
            testCounter.Dir = 0;
            CreateObject(testCounter);

            testCounter = new XmlHouseDataObject(); //test pet carrier
            testCounter.GUID = "0x3278BD34";
            testCounter.X = 26;
            testCounter.Y = 41;
            testCounter.Level = 1;
            testCounter.Dir = 0;
            var objPet = CreateObject(testCounter);
            objPet.SetAttribute(1, 1); //open container

            /*var fsc = HIT.HITVM.Get().PlayFSC(TSO.Content.Content.Get().GetPath("sounddata\\ambience\\daybirds\\daybirds.fsc"));
            fsc = HIT.HITVM.Get().PlayFSC(TSO.Content.Content.Get().GetPath("sounddata\\ambience\\explosions\\explosions.fsc"));
            fsc = HIT.HITVM.Get().PlayFSC(TSO.Content.Content.Get().GetPath("sounddata\\ambience\\dog\\dog.fsc"));*/

            Blueprint.Terrain = CreateTerrain(model);
            World.State.WorldSize = model.Size;

            var rooms = new RoomMap();
            rooms.GenerateMap(Blueprint.Walls, Blueprint.Width, Blueprint.Height, 1);
            //rooms.PrintRoomMap();

            return this.Blueprint;
        }