private TerrainComponent CreateTerrain(XmlHouseData model) { var terrain = new TerrainComponent(new Rectangle(1, 1, model.Size - 2, model.Size - 2)); this.InitWorldComponent(terrain); return(terrain); }
private TerrainComponent CreateTerrain(XmlHouseData model) { var terrain = new TerrainComponent(new Rectangle(0, 0, model.Size, model.Size), Blueprint); this.InitWorldComponent(terrain); return(terrain); }
/// <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); }
public override bool Execute(VM vm) { //the client should ignore these. Can be sent before state sync when joining job lots (by accident) if (!vm.BlueprintRestore) { return(true); } vm.SetGlobalValue(11, JobLevel); //set job level beforehand if (IffData) { var iff = new IffFile(); using (var stream = new MemoryStream(XMLData)) { iff.Read(stream); } var fsov = iff.List <FSOV>()?.FirstOrDefault(); if (fsov != null) { var marshal = new VMMarshal(); using (var read = new BinaryReader(new MemoryStream(fsov.Data))) marshal.Deserialize(read); vm.Load(marshal); } else { var activator = new VMTS1Activator(vm, vm.Context.World, JobLevel); var blueprint = activator.LoadFromIff(iff); } var entClone = new List <VMEntity>(vm.Entities); foreach (var nobj in entClone) { nobj.ExecuteEntryPoint(2, vm.Context, true); } vm.TS1State.VerifyFamily(vm); } else { XmlHouseData lotInfo; using (var stream = new MemoryStream(XMLData)) { lotInfo = XmlHouseData.Parse(stream); } var activator = new VMWorldActivator(vm, vm.Context.World); activator.FloorClip = new Microsoft.Xna.Framework.Rectangle(FloorClipX, FloorClipY, FloorClipWidth, FloorClipHeight); activator.Offset = new Microsoft.Xna.Framework.Point(OffsetX, OffsetY); activator.TargetSize = TargetSize; var blueprint = activator.LoadFromXML(lotInfo); } /*if (VM.UseWorld) * { * vm.Context.World.InitBlueprint(blueprint); * vm.Context.Blueprint = blueprint; * }*/ return(true); }
public override bool Execute(VM vm) { string[] CharacterInfos = new string[9]; XmlHouseData lotInfo; using (var stream = new MemoryStream(XMLData)) { lotInfo = XmlHouseData.Parse(stream); } VMWorldActivator activator = new VMWorldActivator(vm, vm.Context.World); vm.Activator = activator; var blueprint = activator.LoadFromXML(lotInfo); if (VM.UseWorld) { vm.Context.World.InitBlueprint(blueprint); vm.Context.Blueprint = blueprint; } vm.SetGlobalValue(11, JobLevel); AppearanceType type; foreach (XmlCharacter Char in Characters) { uint vsimID = (uint)(new Random()).Next(); Enum.TryParse(Char.Appearance, out type); var vheadPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(Char.Head, 16)); var vbodyPurchasable = Content.Content.Get().AvatarPurchasables.Get(Convert.ToUInt64(Char.Body, 16)); var vHeadID = vheadPurchasable != null ? vheadPurchasable.OutfitID : Convert.ToUInt64(Char.Head, 16); var vBodyID = vbodyPurchasable != null ? vbodyPurchasable.OutfitID : Convert.ToUInt64(Char.Body, 16); VMAvatar visitor = vm.Activator.CreateAvatar (Convert.ToUInt32(Char.ObjID, 16), Char, true, Convert.ToInt16(Char.Id)); if (!vm.Entities.Contains(visitor)) { vm.SendCommand(new VMNetVisitorCmd { ActorUID = vsimID, HeadID = vHeadID, BodyID = vBodyID, SkinTone = (byte)type, Gender = Char.Gender == "male" ? true : false, Name = Char.Name }); } } return(true); }
public LotDebugScreen() { var lotInfo = XmlHouseData.Parse(GameFacade.GameFilePath("housedata/blueprints/restaurant01_00.xml")); World = new World(GameFacade.Game.GraphicsDevice); GameFacade.Scenes.Add(World); vm = new TSO.Simantics.VM(new VMContext(World)); vm.Init(); var activator = new VMWorldActivator(vm, World); var blueprint = activator.LoadFromXML(lotInfo); World.InitBlueprint(blueprint); vm.Context.Blueprint = blueprint; var sim = activator.CreateAvatar(); //sim.Position = new Vector3(31.5f, 55.5f, 0.0f); sim.Position = new Vector3(26.5f, 41.5f, 0.0f); VMDebug = new UIButton() { Caption = "Simantics", Y = 45, Width = 100, X = GlobalSettings.Default.GraphicsWidth - 110 }; VMDebug.OnButtonClick += new ButtonClickDelegate(VMDebug_OnButtonClick); this.Add(VMDebug); LotController = new UILotControl(vm, World); this.AddAt(0, LotController); ucp = new UIUCP(this); ucp.Y = ScreenHeight - 210; ucp.SetInLot(true); ucp.SetMode(UIUCP.UCPMode.LotMode); ucp.SelectedAvatar = sim; ucp.SetPanel(1); //ucp.ZoomLevel = 1; //ucp.OnZoomChanged += new UCPZoomChangeEvent(ucp_OnZoomChanged); //ucp.OnRotateChanged += new UCPRotateChangeEvent(ucp_OnRotateChanged); this.Add(ucp); }
public override bool Execute(VM vm) { //the client should ignore these. Can be sent before state sync when joining job lots (by accident) if (!vm.IsServer) { return(true); } vm.SetGlobalValue(11, JobLevel); //set job level beforehand if (IffData) { vm.SetGlobalValue(10, JobLevel); //set house number var iff = new IffFile(); using (var stream = new MemoryStream(XMLData)) { iff.Read(stream); } var activator = new VMTS1Activator(vm, vm.Context.World); var blueprint = activator.LoadFromIff(iff); vm.VerifyFamily(); } else { XmlHouseData lotInfo; using (var stream = new MemoryStream(XMLData)) { lotInfo = XmlHouseData.Parse(stream); } var activator = new VMWorldActivator(vm, vm.Context.World); activator.FloorClip = new Microsoft.Xna.Framework.Rectangle(FloorClipX, FloorClipY, FloorClipWidth, FloorClipHeight); activator.Offset = new Microsoft.Xna.Framework.Point(OffsetX, OffsetY); activator.TargetSize = TargetSize; var blueprint = activator.LoadFromXML(lotInfo); } /*if (VM.UseWorld) * { * vm.Context.World.InitBlueprint(blueprint); * vm.Context.Blueprint = blueprint; * }*/ return(true); }
public override bool Execute(VM vm) { XmlHouseData lotInfo; using (var stream = new MemoryStream(XMLData)) { lotInfo = XmlHouseData.Parse(stream); } var activator = new VMWorldActivator(vm, vm.Context.World); var blueprint = activator.LoadFromXML(lotInfo); if (VM.UseWorld) { vm.Context.World.InitBlueprint(blueprint); vm.Context.Blueprint = blueprint; } vm.SetGlobalValue(11, JobLevel); return(true); }
public void InitTestLot() { var lotInfo = XmlHouseData.Parse(GameFacade.GameFilePath("housedata/blueprints/restaurant08_00.xml")); World = new World(GameFacade.Game.GraphicsDevice); GameFacade.Scenes.Add(World); vm = new TSO.Simantics.VM(new VMContext(World)); vm.Init(); var activator = new VMWorldActivator(vm, World); var blueprint = activator.LoadFromXML(lotInfo); World.InitBlueprint(blueprint); vm.Context.Blueprint = blueprint; var sim = activator.CreateAvatar(); sim.Position = new Vector3(26.5f, 41.5f, 0.0f); var sim2 = activator.CreateAvatar(); sim2.Position = new Vector3(27.5f, 41.5f, 0.0f); LotController = new UILotControl(vm, World); this.AddAt(0, LotController); vm.Context.Clock.Hours = 6; ucp.SelectedAvatar = sim; ucp.SetInLot(true); if (m_ZoomLevel > 3) { World.Visible = false; } }
/// <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 pool in model.World.Pools) { arch.SetFloor(pool.X, pool.Y, 1, new FloorTile { Pattern = 65535 }, 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); } if (VM.UseWorld) { foreach (var obj in model.Sounds) { VM.Context.Ambience.SetAmbience(VM.Context.Ambience.GetAmbienceFromGUID(obj.ID), (obj.On == 1)); World.State.WorldSize = model.Size; } Blueprint.Terrain = CreateTerrain(model); } 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); arch.Tick(); return(this.Blueprint); }
/// <summary> /// /// </summary> /// <param name="model"></param> public Blueprint LoadFromXML(XmlHouseData model) { var size = TargetSize; if (size == 0) { size = model.Size; } model.Size = size; if (VM.UseWorld) { this.Blueprint = new Blueprint(size, size); } VM.Entities = new List <VMEntity>(); VM.Scheduler = new Engine.VMScheduler(VM); VM.Context = new VMContext(VM.Context.World); VM.Context.VM = VM; VM.Context.Blueprint = Blueprint; VM.Context.Architecture = new VMArchitecture(size, size, Blueprint, VM.Context); var phone = model.Objects.FirstOrDefault(x => x.GUIDInt == 0x313D2F9A); if (phone != null && TargetSize != 0) { //determine lot alignment var dirDiff = new Point(phone.X, phone.Y) - new Point(model.Size / 2); // (atan result) 1 is default, 2 is 90 clockwise var dir = (int)(Math.Round(Math.Atan2(dirDiff.Y, dirDiff.X) / (Math.PI / 2)) + 3) % 4; Offset = DirOffsets[dir]; VM.TSOState.Size = ((10) | (3 << 8)) | (dir << 16); } var arch = VM.Context.Architecture; foreach (var floor in model.World.Floors) { if (FloorClip != Rectangle.Empty && !FloorClip.Contains(floor.X, floor.Y)) { continue; } arch.SetFloor((short)(floor.X + Offset.X), (short)(floor.Y + Offset.Y), (sbyte)(floor.Level + 1), new FloorTile { Pattern = (ushort)floor.Value }, true); } foreach (var pool in model.World.Pools) { arch.SetFloor((short)(pool.X + Offset.X), (short)(pool.Y + Offset.Y), 1, new FloorTile { Pattern = 65535 }, true); } { foreach (var wall in model.World.Walls) { arch.SetWall((short)(wall.X + Offset.X), (short)(wall.Y + Offset.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) { CreateObject(obj); } if (VM.UseWorld) { foreach (var obj in model.Sounds) { VM.Context.Ambience.SetAmbience(VM.Context.Ambience.GetAmbienceFromGUID(obj.ID), (obj.On == 1)); World.State.WorldSize = size; } Blueprint.Terrain = CreateTerrain(model); } arch.SignalTerrainRedraw(); VM.Context.World?.InitBlueprint(Blueprint); arch.Tick(); return(this.Blueprint); }
public void SaveHouse(VM vm, string path) { if (vm.Context.Architecture != 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.Architecture.Width; var HouseHeight = vm.Context.Architecture.Height; var Levels = vm.Context.Architecture.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); }
/// <summary> /// /// </summary> /// <param name="model"></param> public Blueprint LoadFromXML(XmlHouseData model) { var size = TargetSize; if (size == 0) { size = model.Size; } model.Size = size; if (VM.UseWorld) { this.Blueprint = new Blueprint(size, size); } VM.Entities = new List <VMEntity>(); VM.Scheduler = new Engine.VMScheduler(VM); VM.Context = new VMContext(VM.Context.World); VM.Context.VM = VM; VM.Context.Blueprint = Blueprint; VM.Context.Architecture = new VMArchitecture(size, size, Blueprint, VM.Context); var arch = VM.Context.Architecture; foreach (var floor in model.World.Floors) { if (FloorClip != Rectangle.Empty && !FloorClip.Contains(floor.X, floor.Y)) { continue; } arch.SetFloor((short)(floor.X + Offset.X), (short)(floor.Y + Offset.Y), (sbyte)(floor.Level + 1), new FloorTile { Pattern = (ushort)floor.Value }, true); } foreach (var pool in model.World.Pools) { arch.SetFloor((short)(pool.X + Offset.X), (short)(pool.Y + Offset.Y), 1, new FloorTile { Pattern = 65535 }, true); } foreach (var wall in model.World.Walls) { arch.SetWall((short)(wall.X + Offset.X), (short)(wall.Y + Offset.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) { CreateObject(obj); } if (VM.UseWorld) { foreach (var obj in model.Sounds) { VM.Context.Ambience.SetAmbience(VM.Context.Ambience.GetAmbienceFromGUID(obj.ID), (obj.On == 1)); World.State.WorldSize = size; } Blueprint.Terrain = CreateTerrain(model); } arch.SignalTerrainRedraw(); VM.Context.World?.InitBlueprint(Blueprint); arch.Tick(); return(this.Blueprint); }
public LotDebugScreen() { var lotInfo = XmlHouseData.Parse(GameFacade.GameFilePath("housedata/blueprints/restaurant01_00.xml")); World = new World(GameFacade.Game.GraphicsDevice); GameFacade.Scenes.Add(World); vm = new tso.simantics.VM(new VMContext(World)); vm.Init(); var activator = new VMWorldActivator(vm, World); var blueprint = activator.LoadFromXML(lotInfo); World.InitBlueprint(blueprint); vm.Context.Blueprint = blueprint; var sim = activator.CreateAvatar(); //sim.Position = new Vector3(31.5f, 55.5f, 0.0f); sim.Position = new Vector3(26.5f, 41.5f, 0.0f); VMDebug = new UIButton() { Caption = "Simantics", Y = 45, Width = 100, X = GlobalSettings.Default.GraphicsWidth - 110 }; VMDebug.OnButtonClick += new ButtonClickDelegate(VMDebug_OnButtonClick); this.Add(VMDebug); //var lotInfo = HouseData.Parse("C:\\restaurant00_00_small.xml"); //for (int i = 1; i < 64; i++) //{ // lotInfo.World.Floors.Add(new HouseDataFloor { // X = 1, // Y = i, // Level = 0, // Value = 9 // }); //} //lotInfo.World.Floors.Add(new HouseDataFloor { // X = 0, Y = 0, // Level = 0, Value = 20 //}); //lotInfo.World.Floors.Add(new HouseDataFloor //{ // X = 63, // Y = 63, // Level = 0, // Value = 40 //}); //lotInfo.World.Floors.Add(new HouseDataFloor //{ // X = 0, // Y = 63, // Level = 0, // Value = 20 //}); //lotInfo.World.Floors.Add(new HouseDataFloor //{ // X = 63, // Y = 0, // Level = 0, // Value = 20 //}); //Renderer = new HouseRenderer(); //Renderer.SetModel(lotInfo); ////Renderer.Position = new Microsoft.Xna.Framework.Vector3(-32.0f, -40.0f, 0.0f); //var scene = new ThreeDScene(); //var focusPoint = Vector3.Zero; //var yValue = (float)Math.Cos(MathHelper.ToRadians(30.0f)) * 96.0f; //var cameraOffset = new Vector3(-96.0f, yValue, 96.0f); //var rotatedOffset = Vector3.Transform(cameraOffset, Microsoft.Xna.Framework.Matrix.CreateRotationY(MathHelper.PiOver2 * 0.5f)); ////rotatedOffset = Vector3.Transform(rotatedOffset, Microsoft.Xna.Framework.Matrix.CreateScale(3f)); ////Renderer.Position = new Vector3(-96.0f, 0.0f, -96.0f); //scene.Camera.Position = cameraOffset;// new Microsoft.Xna.Framework.Vector3(0, 0, 80); //scene.Add(Renderer); //Renderer.Scale = new Vector3(0.005f); //GameFacade.Scenes.AddScene(scene); ucp = new UIUCP(); ucp.Y = ScreenHeight - 210; //ucp.OnZoomChanged += new UCPZoomChangeEvent(ucp_OnZoomChanged); //ucp.OnRotateChanged += new UCPRotateChangeEvent(ucp_OnRotateChanged); this.Add(ucp); }
public void ResetVM() { VMNetDriver driver; driver = new VMServerDriver(Port, NetClosed); var vm = new VM(new VMContext(null), new VMNullHeadlineProvider()); state = vm; vm.Init(); vm.VM_SetDriver(driver); vm.OnChatEvent += Vm_OnChatEvent; Console.WriteLine("Select the lot type"); Console.WriteLine("1-Empty"); Console.WriteLine("2-Blueprint"); Console.WriteLine("3-House"); string path = ""; int lot = Convert.ToInt32(Console.ReadLine()); if (lot == 1) { if (Settings.Default.DebugLot != String.Empty) { path = AppDomain.CurrentDomain.BaseDirectory + "Content/Houses/" + Settings.Default.DebugLot; } else { path = AppDomain.CurrentDomain.BaseDirectory + "Content/Houses/empty_lot.xml"; } } else if (lot == 2) { Console.WriteLine("Specify lot name"); path = AppDomain.CurrentDomain.BaseDirectory + "Content/Houses/" + Console.ReadLine() + ".xml"; } else if (lot == 3) { Console.WriteLine("Specify house name"); path = AppDomain.CurrentDomain.BaseDirectory + "Content/Houses/" + Console.ReadLine() + ".iff"; TS1 = true; } XmlHouseData lotInfo; IffFile HouseInfo = null; string filename = Path.GetFileName(path); if (!TS1) { try { //try to load from FSOV first. LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + ".fsov"); } catch (Exception) { try { Console.WriteLine("Failed FSOV load... Trying Backup"); LoadState(vm, "Content/LocalHouse/" + filename.Substring(0, filename.Length - 4) + "_backup.fsov"); } catch (Exception) { Console.WriteLine("CRITICAL::: Failed FSOV load... Trying Blueprint (first run or something went wrong)"); short jobLevel = -1; //quick hack to find the job level from the chosen blueprint //the final server will know this from the fact that it wants to create a job lot in the first place... try { if (filename.StartsWith("nightclub") || filename.StartsWith("restaurant") || filename.StartsWith("robotfactory")) { jobLevel = Convert.ToInt16(filename.Substring(filename.Length - 9, 2)); } } catch (Exception) { } //vm.SendCommand(new VMBlueprintRestoreCmd //{ // JobLevel = jobLevel, // XMLData = File.ReadAllBytes(path) //}); using (var stream = new MemoryStream(File.ReadAllBytes(path))) { lotInfo = XmlHouseData.Parse(stream); } VMWorldActivator activator = new VMWorldActivator(vm, vm.Context.World); vm.Activator = activator; var blueprint = activator.LoadFromXML(lotInfo); if (VM.UseWorld) { vm.Context.World.InitBlueprint(blueprint); vm.Context.Blueprint = blueprint; } vm.Context.Clock.Hours = 10; vm.MyUID = uint.MaxValue - 1; } } } else { if (File.Exists(path)) { HouseInfo = new IffFile(path); } VMWorldActivator activator = new VMWorldActivator(vm, vm.Context.World); vm.Activator = activator; var blueprint = activator.LoadFromIff(HouseInfo); if (VM.UseWorld) { vm.Context.World.InitBlueprint(blueprint); vm.Context.Blueprint = blueprint; } vm.Context.Clock.Hours = 10; vm.MyUID = uint.MaxValue - 1; } Console.WriteLine("Select the server type"); Console.WriteLine("1-Host"); Console.WriteLine("2-Dedicated"); int host = Convert.ToInt32(Console.ReadLine()); if (host == 1) { vm.SendCommand(new VMNetSimJoinCmd { ActorUID = uint.MaxValue - 1, Name = "server" }); } else if (host == 2) { Dedicated = true; } }
/// <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 } 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(); //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 = 40; 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); 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 Hot tub testCounter.GUID = "0x5E8B157A"; testCounter.X = 25; 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); }