public void InitTestLot(string path, bool host) { if (Connecting) return; if (vm != null) CleanupLastWorld(); World = new LotView.World(GameFacade.Game.GraphicsDevice); GameFacade.Scenes.Add(World); VMNetDriver driver; if (host) { driver = new VMServerDriver(37564, null); } else { Connecting = true; ConnectingDialog = new UILoginProgress(); ConnectingDialog.Caption = GameFacade.Strings.GetString("211", "1"); ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24"); //this.Add(ConnectingDialog); UIScreen.ShowDialog(ConnectingDialog, true); driver = new VMClientDriver(path, 37564, ClientStateChange); } vm = new VM(new VMContext(World), driver, new UIHeadlineRendererProvider()); vm.Init(); vm.LotName = (path == null) ? "localhost" : path.Split('/').LastOrDefault(); //quick hack just so we can remember where we are if (host) { //check: do we have an fsov to try loading from? string filename = Path.GetFileName(path); try { using (var file = new BinaryReader(File.OpenRead(Path.Combine(FSOEnvironment.UserDir, "LocalHouse/")+filename.Substring(0, filename.Length-4)+".fsov"))) { var marshal = new SimAntics.Marshals.VMMarshal(); marshal.Deserialize(file); vm.Load(marshal); vm.Reset(); } } catch (Exception) { 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) }); } } uint simID = (uint)(new Random()).Next(); vm.MyUID = simID; vm.SendCommand(new VMNetSimJoinCmd { ActorUID = simID, HeadID = GlobalSettings.Default.DebugHead, BodyID = GlobalSettings.Default.DebugBody, SkinTone = (byte)GlobalSettings.Default.DebugSkin, Gender = !GlobalSettings.Default.DebugGender, Name = GlobalSettings.Default.LastUser }); LotController = new UILotControl(vm, World); this.AddAt(0, LotController); vm.Context.Clock.Hours = 10; if (m_ZoomLevel > 3) { World.Visible = false; LotController.Visible = false; } if (host) { ZoomLevel = 1; ucp.SetInLot(true); } else { ZoomLevel = Math.Max(ZoomLevel, 4); } if (IDEHook.IDE != null) IDEHook.IDE.StartIDE(vm); vm.OnFullRefresh += VMRefreshed; vm.OnChatEvent += Vm_OnChatEvent; vm.OnEODMessage += LotController.EODs.OnEODMessage; }
public void InitTestLot(string path, bool host) { if (Connecting) return; if (vm != null) CleanupLastWorld(); World = new LotView.World(GameFacade.Game.GraphicsDevice); GameFacade.Scenes.Add(World); VMNetDriver driver; if (host) { driver = new VMServerDriver(37564); } else { Connecting = true; ConnectingDialog = new UILoginProgress(); ConnectingDialog.Caption = GameFacade.Strings.GetString("211", "1"); ConnectingDialog.ProgressCaption = GameFacade.Strings.GetString("211", "24"); //this.Add(ConnectingDialog); UIScreen.ShowDialog(ConnectingDialog, true); driver = new VMClientDriver(path, 37564, ClientStateChange); } vm = new VM(new VMContext(World), driver); vm.Init(); if (host) { vm.SendCommand(new VMBlueprintRestoreCmd { XMLData = File.ReadAllBytes(path) }); } uint simID = (uint)(new Random()).Next(); vm.SendCommand(new VMNetSimJoinCmd { SimID = simID, HeadID = GlobalSettings.Default.DebugHead, BodyID = GlobalSettings.Default.DebugBody, SkinTone = (byte)GlobalSettings.Default.DebugSkin, Gender = !GlobalSettings.Default.DebugGender, Name = GlobalSettings.Default.LastUser }); LotController = new UILotControl(vm, World); LotController.SelectedSimID = simID; this.AddAt(0, LotController); vm.Context.Clock.Hours = 8; if (m_ZoomLevel > 3) { World.Visible = false; LotController.Visible = false; } if (host) { ZoomLevel = 1; ucp.SetInLot(true); } else { ZoomLevel = Math.Max(ZoomLevel, 4); } vm.OnFullRefresh += VMRefreshed; }