public override void Update(UpdateState state) { base.Update(state); if (!vm.Ready || vm.Context.Architecture == null) { return; } //handling smooth scaled zoom if (FSOEnvironment.Enable3D) { var s3d = ((WorldStateRC)World.State); s3d.Zoom3D += ((9.75f - (TargetZoom - 0.25f) * 5.7f) - s3d.Zoom3D) / 10; } else { if (World.State.Zoom != LastZoom) { //zoom has been changed by something else. inherit the value SetTargetZoom(World.State.Zoom); LastZoom = World.State.Zoom; } float BaseScale; WorldZoom targetZoom; if (TargetZoom < 0.5f) { targetZoom = WorldZoom.Far; BaseScale = 0.25f; } else if (TargetZoom < 1f) { targetZoom = WorldZoom.Medium; BaseScale = 0.5f; } else { targetZoom = WorldZoom.Near; BaseScale = 1f; } World.BackbufferScale = TargetZoom / BaseScale; if (World.State.Zoom != targetZoom) { World.State.Zoom = targetZoom; } LastZoom = targetZoom; WorldConfig.Current.SmoothZoom = false; } Cheats.Update(state); AvatarDS.Update(); if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected. if (ActiveEntity == null) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID > 0); } if (!FoundMe && ActiveEntity != null) { vm.Context.World.State.CenterTile = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y); vm.Context.World.State.ScrollAnchor = null; FoundMe = true; } Queue.QueueOwner = ActiveEntity; } if (GotoObject == null) { GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0]; } if (ActiveEntity != null && BlockingDialog != null) { //are we still waiting on a blocking dialog? if not, cancel. if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult))) { UIScreen.RemoveDialog(BlockingDialog); LastDialogID = 0; BlockingDialog = null; } } if (Visible) { if (ShowTooltip) { state.UIState.TooltipProperties.UpdateDead = false; } bool scrolled = false; if (RMBScroll) { World.State.ScrollAnchor = null; Vector2 scrollBy = new Vector2(); if (state.TouchMode) { scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; scrollBy /= 128f; scrollBy /= FSOEnvironment.DPIScaleFactor; } else { scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY); scrollBy *= 0.0005f; var angle = (Math.Atan2(state.MouseState.X - RMBScrollX, (RMBScrollY - state.MouseState.Y) * 2) / Math.PI) * 4; angle += 8; angle %= 8; CursorType type = CursorType.ArrowUp; switch ((int)Math.Round(angle)) { case 0: type = CursorType.ArrowUp; break; case 1: type = CursorType.ArrowUpRight; break; case 2: type = CursorType.ArrowRight; break; case 3: type = CursorType.ArrowDownRight; break; case 4: type = CursorType.ArrowDown; break; case 5: type = CursorType.ArrowDownLeft; break; case 6: type = CursorType.ArrowLeft; break; case 7: type = CursorType.ArrowUpLeft; break; } GameFacade.Cursor.SetCursor(type); } World.Scroll(scrollBy * (60f / FSOEnvironment.RefreshRate)); scrolled = true; } if (MouseIsOn) { if (state.MouseState.RightButton == ButtonState.Pressed) { if (RMBScroll == false) { RMBScroll = true; RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; } } else { if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) { scrolled = World.TestScroll(state); } } } if (state.MouseState.RightButton != ButtonState.Pressed) { if (RMBScroll) { GameFacade.Cursor.SetCursor(CursorType.Normal); } RMBScroll = false; } if (LiveMode) { LiveModeUpdate(state, scrolled); } else if (CustomControl != null) { CustomControl.Update(state, scrolled); } else { ObjectHolder.Update(state, scrolled); } //set cutaway around mouse UpdateCutaway(state); if (state.NewKeys.Contains(Keys.S) && state.KeyboardState.IsKeyDown(Keys.LeftControl)) { //save lot if (LotSaveDialog == null) { SaveLot(); } } } }
public override void Update(UpdateState state) { base.Update(state); Cheats.Update(state); if (!vm.Ready) { return; } if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected. if (ActiveEntity == null) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); } if (!FoundMe && ActiveEntity != null) { vm.Context.World.State.CenterTile = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y); vm.Context.World.State.ScrollAnchor = null; FoundMe = true; } Queue.QueueOwner = ActiveEntity; } if (GotoObject == null) { GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0]; } if (ActiveEntity != null && BlockingDialog != null) { //are we still waiting on a blocking dialog? if not, cancel. if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult))) { UIScreen.RemoveDialog(BlockingDialog); LastDialogID = 0; BlockingDialog = null; } } if (Visible) { if (ShowTooltip) { state.UIState.TooltipProperties.UpdateDead = false; } bool scrolled = false; if (KBScroll) { World.State.ScrollAnchor = null; int KeyboardAxisX = 0; int KeyboardAxisY = 0; Vector2 scrollBy = new Vector2(); if (state.KeyboardState.IsKeyDown(Keys.Up) || state.KeyboardState.IsKeyDown(Keys.W)) { KeyboardAxisY -= 1; } if (state.KeyboardState.IsKeyDown(Keys.Left) || state.KeyboardState.IsKeyDown(Keys.A)) { KeyboardAxisX -= 1; } if (state.KeyboardState.IsKeyDown(Keys.Down) || state.KeyboardState.IsKeyDown(Keys.S)) { KeyboardAxisY += 1; } if (state.KeyboardState.IsKeyDown(Keys.Right) || state.KeyboardState.IsKeyDown(Keys.D)) { KeyboardAxisX += 1; } scrollBy = new Vector2(KeyboardAxisX, KeyboardAxisY); scrollBy *= 0.05f; World.Scroll(scrollBy * (60f / 60)); } if (RMBScroll) { World.State.ScrollAnchor = null; Vector2 scrollBy = new Vector2(); if (state.TouchMode) { scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; scrollBy /= 128f; scrollBy /= FSOEnvironment.DPIScaleFactor; } else { scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY); scrollBy *= 0.0005f; var angle = (Math.Atan2(state.MouseState.X - RMBScrollX, (RMBScrollY - state.MouseState.Y) * 2) / Math.PI) * 4; angle += 8; angle %= 8; CursorType type = CursorType.ArrowUp; switch ((int)Math.Round(angle)) { case 0: type = CursorType.ArrowUp; break; case 1: type = CursorType.ArrowUpRight; break; case 2: type = CursorType.ArrowRight; break; case 3: type = CursorType.ArrowDownRight; break; case 4: type = CursorType.ArrowDown; break; case 5: type = CursorType.ArrowDownLeft; break; case 6: type = CursorType.ArrowLeft; break; case 7: type = CursorType.ArrowUpLeft; break; } GameFacade.Cursor.SetCursor(type); } World.Scroll(scrollBy * (60f / 60)); scrolled = true; } var nofocus = state.InputManager.GetFocus() == null; var keyst = state.KeyboardState; if (nofocus && (keyst.IsKeyDown(Keys.Up) || keyst.IsKeyDown(Keys.Left) || keyst.IsKeyDown(Keys.Down) || keyst.IsKeyDown(Keys.Right) || (keyst.IsKeyDown(Keys.W) || keyst.IsKeyDown(Keys.A) || keyst.IsKeyDown(Keys.S) || keyst.IsKeyDown(Keys.D)))) { KBScroll = true; } else { KBScroll = false; } if (MouseIsOn) { if (state.MouseState.RightButton == ButtonState.Pressed) { if (RMBScroll == false) { RMBScroll = true; state.InputManager.SetFocus(null); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; } } else { RMBScroll = false; if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) { scrolled = World.TestScroll(state); } } } if (state.MouseState.RightButton != ButtonState.Pressed) { if (RMBScroll) { GameFacade.Cursor.SetCursor(CursorType.Normal); } RMBScroll = false; } if (LiveMode) { LiveModeUpdate(state, scrolled); } else if (CustomControl != null) { CustomControl.Update(state, scrolled); } else { ObjectHolder.Update(state, scrolled); } //set cutaway around mouse if (vm.Context.Blueprint != null) { World.State.DynamicCutaway = (WallsMode == 1); //first we need to cycle the rooms that are being cutaway. Keep this up even if we're in all-cut mode. var mouseTilePos = World.State.WorldSpace.GetTileAtPosWithScroll(new Vector2(state.MouseState.X, state.MouseState.Y) / FSOEnvironment.DPIScaleFactor); var roomHover = vm.Context.GetRoomAt(LotTilePos.FromBigTile((short)(mouseTilePos.X), (short)(mouseTilePos.Y), World.State.Level)); var outside = (vm.Context.RoomInfo[roomHover].Room.IsOutside); if (!outside && !CutRooms.Contains(roomHover)) { CutRooms.Add(roomHover); //outside hover should not persist like with other rooms. } while (CutRooms.Count > 3) { CutRooms.Remove(CutRooms.ElementAt(0)); } if (LastWallMode != WallsMode) { if (WallsMode == 0) //walls down { LastCuts = new bool[vm.Context.Architecture.Width * vm.Context.Architecture.Height]; vm.Context.Blueprint.Cutaway = LastCuts; vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED)); for (int i = 0; i < LastCuts.Length; i++) { LastCuts[i] = true; } } else if (WallsMode == 1) { MouseCutRect = new Rectangle(); LastCutRooms = new HashSet <uint>() { uint.MaxValue }; //must regenerate cuts } else //walls up or roof { LastCuts = new bool[vm.Context.Architecture.Width * vm.Context.Architecture.Height]; vm.Context.Blueprint.Cutaway = LastCuts; vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED)); } LastWallMode = WallsMode; } if (WallsMode == 1) { int recut = 0; var finalRooms = new HashSet <uint>(CutRooms); var newCut = new Rectangle((int)(mouseTilePos.X - 2.5), (int)(mouseTilePos.Y - 2.5), 5, 5); newCut.X -= VMArchitectureTools.CutCheckDir[(int)World.State.Rotation][0] * 2; newCut.Y -= VMArchitectureTools.CutCheckDir[(int)World.State.Rotation][1] * 2; if (newCut != MouseCutRect) { MouseCutRect = newCut; recut = 1; } if (LastFloor != World.State.Level || LastRotation != World.State.Rotation || !finalRooms.SetEquals(LastCutRooms)) { LastCuts = VMArchitectureTools.GenerateRoomCut(vm.Context.Architecture, World.State.Level, World.State.Rotation, finalRooms); recut = 2; LastFloor = World.State.Level; LastRotation = World.State.Rotation; } LastCutRooms = finalRooms; if (recut > 0) { var finalCut = new bool[LastCuts.Length]; Array.Copy(LastCuts, finalCut, LastCuts.Length); var notableChange = VMArchitectureTools.ApplyCutRectangle(vm.Context.Architecture, World.State.Level, finalCut, MouseCutRect); if (recut > 1 || notableChange || LastRectCutNotable) { vm.Context.Blueprint.Cutaway = finalCut; vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED)); } LastRectCutNotable = notableChange; } } } } }
public override void Update(UpdateState state) { base.Update(state); Cheats.Update(state); if (!vm.Ready) { return; } if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected. if (ActiveEntity == null) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); } if (!FoundMe && ActiveEntity != null) { vm.Context.World.State.CenterTile = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y); FoundMe = true; } Queue.QueueOwner = ActiveEntity; } if (GotoObject == null) { GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0]; } if (Visible) { if (ShowTooltip) { state.UIState.TooltipProperties.UpdateDead = false; } bool scrolled = false; if (RMBScroll) { Vector2 scrollBy = new Vector2(); if (state.TouchMode) { scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; scrollBy /= 128f; } else { scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY); scrollBy *= 0.0005f; } World.Scroll(scrollBy); scrolled = true; } if (MouseIsOn) { if (state.MouseState.RightButton == ButtonState.Pressed) { if (RMBScroll == false) { RMBScroll = true; RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; } } else { RMBScroll = false; if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) { scrolled = World.TestScroll(state); } } } if (LiveMode) { LiveModeUpdate(state, scrolled); } else if (CustomControl != null) { CustomControl.Update(state, scrolled); } else { ObjectHolder.Update(state, scrolled); } //set cutaway around mouse if (vm.Context.Blueprint != null) { var cuts = vm.Context.Blueprint.Cutaway; Rectangle newCut; if (WallsMode == 0) { newCut = new Rectangle(-1, -1, 1024, 1024); //cut all; walls down. } else if (WallsMode == 1) { var mouseTilePos = World.State.WorldSpace.GetTileAtPosWithScroll(new Vector2(state.MouseState.X, state.MouseState.Y + 128)); newCut = new Rectangle((int)(mouseTilePos.X - 5.5), (int)(mouseTilePos.Y - 5.5), 11, 11); } else { newCut = new Rectangle(0, 0, 0, 0); //walls up or roof } if (!newCut.Equals(MouseCutRect)) { if (cuts.Contains(MouseCutRect)) { cuts.Remove(MouseCutRect); } MouseCutRect = newCut; cuts.Add(MouseCutRect); vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED)); } } } }
public override void Update(UpdateState state) { base.Update(state); if (!vm.Ready || vm.Context.Architecture == null) { return; } Cheats.Update(state); AvatarDS.Update(); if (ActiveEntity == null || ActiveEntity.Dead || ActiveEntity.PersistID != SelectedSimID) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar && x.PersistID == SelectedSimID); //try and hook onto a sim if we have none selected. if (ActiveEntity == null) { ActiveEntity = vm.Entities.FirstOrDefault(x => x is VMAvatar); } if (!FoundMe && ActiveEntity != null) { vm.Context.World.State.CenterTile = new Vector2(ActiveEntity.VisualPosition.X, ActiveEntity.VisualPosition.Y); vm.Context.World.State.ScrollAnchor = null; FoundMe = true; } Queue.QueueOwner = ActiveEntity; } if (GotoObject == null) { GotoObject = vm.Context.CreateObjectInstance(GOTO_GUID, LotTilePos.OUT_OF_WORLD, Direction.NORTH, true).Objects[0]; } if (ActiveEntity != null && BlockingDialog != null) { //are we still waiting on a blocking dialog? if not, cancel. if (ActiveEntity.Thread != null && (ActiveEntity.Thread.BlockingState == null || !(ActiveEntity.Thread.BlockingState is VMDialogResult))) { UIScreen.RemoveDialog(BlockingDialog); LastDialogID = 0; BlockingDialog = null; } } if (Visible) { if (ShowTooltip) { state.UIState.TooltipProperties.UpdateDead = false; } bool scrolled = false; if (RMBScroll) { World.State.ScrollAnchor = null; Vector2 scrollBy = new Vector2(); if (state.TouchMode) { scrollBy = new Vector2(RMBScrollX - state.MouseState.X, RMBScrollY - state.MouseState.Y); RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; scrollBy /= 128f; scrollBy /= FSOEnvironment.DPIScaleFactor; } else { scrollBy = new Vector2(state.MouseState.X - RMBScrollX, state.MouseState.Y - RMBScrollY); scrollBy *= 0.0005f; var angle = (Math.Atan2(state.MouseState.X - RMBScrollX, (RMBScrollY - state.MouseState.Y) * 2) / Math.PI) * 4; angle += 8; angle %= 8; CursorType type = CursorType.ArrowUp; switch ((int)Math.Round(angle)) { case 0: type = CursorType.ArrowUp; break; case 1: type = CursorType.ArrowUpRight; break; case 2: type = CursorType.ArrowRight; break; case 3: type = CursorType.ArrowDownRight; break; case 4: type = CursorType.ArrowDown; break; case 5: type = CursorType.ArrowDownLeft; break; case 6: type = CursorType.ArrowLeft; break; case 7: type = CursorType.ArrowUpLeft; break; } GameFacade.Cursor.SetCursor(type); } World.Scroll(scrollBy * (60f / FSOEnvironment.RefreshRate)); scrolled = true; } if (MouseIsOn) { if (state.MouseState.RightButton == ButtonState.Pressed) { if (RMBScroll == false) { RMBScroll = true; RMBScrollX = state.MouseState.X; RMBScrollY = state.MouseState.Y; } } else { if (!scrolled && GlobalSettings.Default.EdgeScroll && !state.TouchMode) { scrolled = World.TestScroll(state); } } } if (state.MouseState.RightButton != ButtonState.Pressed) { if (RMBScroll) { GameFacade.Cursor.SetCursor(CursorType.Normal); } RMBScroll = false; } if (LiveMode) { LiveModeUpdate(state, scrolled); } else if (CustomControl != null) { CustomControl.Update(state, scrolled); } else { ObjectHolder.Update(state, scrolled); } //set cutaway around mouse UpdateCutaway(state); } }