private void UpdateCutaway(UpdateState state) { 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.EstTileAtPosWithScroll(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) { if (RMBScroll || !MouseIsOn) { return; } 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.CutRotation][0] * 2; newCut.Y -= VMArchitectureTools.CutCheckDir[(int)World.State.CutRotation][1] * 2; if (newCut != MouseCutRect) { MouseCutRect = newCut; recut = 1; } if (LastFloor != World.State.Level || LastRotation != World.State.CutRotation || !finalRooms.SetEquals(LastCutRooms)) { LastCuts = VMArchitectureTools.GenerateRoomCut(vm.Context.Architecture, World.State.Level, World.State.CutRotation, finalRooms); recut = 2; LastFloor = World.State.Level; LastRotation = World.State.CutRotation; } 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); ModePositions[3].Y = 11; ModeTargets[3].Y = 7.896059f; if (Dead) { return; } if (vm == null) { InitializeLot(); } vm.Update(); if (World != null && !Initialized) { var rcs = (World.State as WorldStateRC); if (rcs != null) { Cam = (WorldCamera3D)rcs.Camera; rcs.FixedCam = true; rcs.CameraMode = true; } SetMode(UICASMode.FamilySelect); SetFamilies(); Initialized = true; //FamilySimInterp = FamilySimInterp; } if (World.State.PreciseZoom != 1) { World.State.PreciseZoom = World.State.PreciseZoom; } switch (Mode) { case UICASMode.FamilySelect: if (World.State.Level != 2) { World.State.Level = 2; World.State.DrawRoofs = true; vm.Context.Blueprint.Cutaway = new bool[vm.Context.Blueprint.Cutaway.Length]; vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED)); } break; default: if (World.State.Level != 1 && Cam == null) { World.State.Level = 1; World.State.DrawRoofs = false; vm.Context.Blueprint.Cutaway = VMArchitectureTools.GenerateRoomCut(vm.Context.Architecture, World.State.Level, World.State.CutRotation, new HashSet <uint>(vm.Context.RoomInfo.Where(x => x.Room.IsOutside == false).Select(x => (uint)x.Room.RoomID))); vm.Context.Blueprint.Damage.Add(new FSO.LotView.Model.BlueprintDamage(FSO.LotView.Model.BlueprintDamageType.WALL_CUT_CHANGED)); } break; } vm.Context.Clock.Minutes = 0; vm.Context.Clock.Hours = 12; var disableAccept = false; switch (Mode) { case UICASMode.SimEdit: if (CASPanel.FirstNameTextBox.CurrentText.Length == 0) { disableAccept = true; } break; case UICASMode.FamilySelect: if (FamiliesPanel.Selection == -1) { disableAccept = true; } break; case UICASMode.FamilyEdit: if (WIPFamily.Count == 0) { disableAccept = true; } break; } AcceptButton.Disabled = disableAccept; //AcceptButton.ForceState = disableAccept ? 0 : -1; //AcceptButton.Opacity = disableAccept ? 0.5f : 1; if (Mode == UICASMode.SimEdit) { UpdateCarousel(state); } for (int i = 0; i < 18; i++) { var relPos = HeadPosition + i - 9; relPos = (float)DirectionUtils.PosMod(relPos, 18); if (relPos > 9) { relPos += 6; } var angle = (relPos / 24) * (Math.PI * 2); var pos = new Vector3(28.5f + 4.5f * (float)Math.Cos(angle), 21.5f + 4.5f * (float)Math.Sin(angle), 0); HeadAvatars[i].RadianDirection = (float)angle + (float)Math.PI / 2; HeadAvatars[i].VisualPosition = pos; } for (int i = 0; i < 18; i++) { var relPos = BodyPosition + i - 9; relPos = (float)DirectionUtils.PosMod(relPos, 18); if (relPos > 9) { relPos += 6; } var angle = (relPos / 24) * (Math.PI * 2); var pos = new Vector3(28.5f + 4.5f * (float)Math.Cos(angle), 21.5f + 4.5f * (float)Math.Sin(angle), 0); BodyAvatars[i].RadianDirection = (float)angle + (float)Math.PI / 2; BodyAvatars[i].VisualPosition = pos; } foreach (var fam in RepresentFamily) { for (int i = 0; i < 16; i++) { fam.SetMotiveData((VMMotive)i, 100); } var q = new List <FSO.SimAntics.Engine.VMQueuedAction>(fam.Thread.Queue); foreach (var action in q) { fam.Thread.CancelAction(action.UID); } } }
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; } } } } }