private void OnLeftMouseDown() { DebugUtils.Log("OnLeftMouseDown: " + ToolState); Vector3 mousePos = RaycastMouseLocation(); if (ToolState == ToolStates.Default) { if (marqueeSelection && (m_hoverInstance == null || !Action.selection.Contains(m_hoverInstance))) { m_selection = default; m_marqueeInstances = null; SetToolState(ToolStates.DrawingSelection); } m_lastInstance = m_hoverInstance; m_sensitivityTogglePosAbs = mousePos; m_clickPositionAbs = mousePos; } else if (ToolState == ToolStates.MouseDragging) { TransformAction action = ActionQueue.instance.current as TransformAction; m_dragStartRelative = action.moveDelta; UpdateSensitivityMode(); m_sensitivityTogglePosAbs = mousePos; m_clickPositionAbs = mousePos; } else if (ToolState == ToolStates.Cloning) { CloneAction action = ActionQueue.instance.current as CloneAction; action.followTerrain = followTerrain; if (POProcessing == 0) { SetToolState(); m_nextAction = ToolAction.Do; UpdateSensitivityMode(); } } }
private void OnLeftMouseDown() { DebugUtils.Log("OnLeftMouseDown: " + ToolState); if (ToolState == ToolStates.Default) { if (marqueeSelection && (m_hoverInstance == null || !Action.selection.Contains(m_hoverInstance))) { m_selection = default; m_marqueeInstances = null; ToolState = ToolStates.DrawingSelection; } m_lastInstance = m_hoverInstance; Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); m_mouseStartPosition = RaycastMouseLocation(mouseRay); } else if (ToolState == ToolStates.MouseDragging) { TransformAction action = ActionQueue.instance.current as TransformAction; m_startPosition = action.moveDelta; Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); m_mouseStartPosition = RaycastMouseLocation(mouseRay); } else if (ToolState == ToolStates.Cloning) { CloneAction action = ActionQueue.instance.current as CloneAction; action.followTerrain = followTerrain; if (!POProcessing) { ToolState = ToolStates.Default; m_nextAction = ToolAction.Do; } } }
private void OnRightMouseDown() { DebugUtils.Log("OnRightMouseDown: " + ToolState); if (ToolState == ToolStates.Default) { m_mouseStartX = Input.mousePosition.x; } else if (ToolState == ToolStates.MouseDragging) { TransformAction action = ActionQueue.instance.current as TransformAction; m_startAngle = action.angleDelta; m_mouseStartX = Input.mousePosition.x; } else if (ToolState == ToolStates.Cloning) { CloneAction action = ActionQueue.instance.current as CloneAction; m_startAngle = action.angleDelta; m_mouseStartX = Input.mousePosition.x; } }
protected override void OnToolUpdate() { if (m_nextAction != ToolAction.None) { return; } if (m_pauseMenu != null && m_pauseMenu.isVisible) { if (ToolState == ToolStates.Default || ToolState == ToolStates.MouseDragging || ToolState == ToolStates.DrawingSelection) { ToolsModifierControl.SetTool <DefaultTool>(); } StopCloning(); StopAligning(); ToolState = ToolStates.Default; UIView.library.Hide("PauseMenu"); return; } lock (ActionQueue.instance) { bool isInsideUI = this.m_toolController.IsInsideUI; if (m_leftClickTime == 0 && Input.GetMouseButton(0)) { if (!isInsideUI) { m_leftClickTime = Stopwatch.GetTimestamp(); OnLeftMouseDown(); } } if (m_leftClickTime != 0) { long elapsed = ElapsedMilliseconds(m_leftClickTime); if (!Input.GetMouseButton(0)) { m_leftClickTime = 0; if (elapsed < 200) { OnLeftClick(); } else { OnLeftDragStop(); } OnLeftMouseUp(); } else if (elapsed >= 200) { OnLeftDrag(); } } if (m_rightClickTime == 0 && Input.GetMouseButton(1)) { if (!isInsideUI) { m_rightClickTime = Stopwatch.GetTimestamp(); OnRightMouseDown(); } } if (m_rightClickTime != 0) { long elapsed = ElapsedMilliseconds(m_rightClickTime); if (!Input.GetMouseButton(1)) { m_rightClickTime = 0; if (elapsed < 200) { OnRightClick(); } else { OnRightDragStop(); } OnRightMouseUp(); } else if (elapsed >= 200) { OnRightDrag(); } } if (!isInsideUI && Cursor.visible) { Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); m_hoverInstance = null; m_marqueeInstances = null; m_segmentGuide = default; switch (ToolState) { case ToolStates.Default: case ToolStates.Aligning: case ToolStates.Picking: { RaycastHoverInstance(mouseRay); break; } case ToolStates.MouseDragging: { TransformAction action = ActionQueue.instance.current as TransformAction; Vector3 newMove = action.moveDelta; float newAngle = action.angleDelta; float newSnapAngle = 0f; if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { if (dragging) { foreach (Instance i in Action.selection) { if (i is MoveableBuilding mb) { mb.Virtual = !fastMove; } } } } else { foreach (Instance i in Action.selection) { if (i is MoveableBuilding mb) { mb.Virtual = fastMove; } } } if (m_leftClickTime > 0) { float y = action.moveDelta.y; newMove = m_startPosition + RaycastMouseLocation(mouseRay) - m_mouseStartPosition; newMove.y = y; } if (m_rightClickTime > 0) { newAngle = ushort.MaxValue * 9.58738E-05f * (Input.mousePosition.x - m_mouseStartX) / Screen.width; if (Event.current.control) { float quarterPI = Mathf.PI / 4; newAngle = quarterPI * Mathf.Round(newAngle / quarterPI); } newAngle += m_startAngle; action.autoCurve = false; } else if (snapping) { newMove = GetSnapDelta(newMove, newAngle, action.center, out action.autoCurve); if (action.autoCurve) { action.segmentCurve = m_segmentGuide; } } else { action.autoCurve = false; } if (action.moveDelta != newMove || action.angleDelta != newAngle || action.snapAngle != newSnapAngle) { action.moveDelta = newMove; action.angleDelta = newAngle; action.snapAngle = newSnapAngle; action.followTerrain = followTerrain; m_nextAction = ToolAction.Do; } UIToolOptionPanel.RefreshSnapButton(); break; } case ToolStates.Cloning: { if (m_rightClickTime != 0) { break; } CloneAction action = ActionQueue.instance.current as CloneAction; float y = action.moveDelta.y; Vector3 newMove = RaycastMouseLocation(mouseRay) - action.center; newMove.y = y; if (snapping) { newMove = GetSnapDelta(newMove, action.angleDelta, action.center, out bool autoCurve); } if (action.moveDelta != newMove) { action.moveDelta = newMove; } UIToolOptionPanel.RefreshSnapButton(); break; } case ToolStates.RightDraggingClone: { CloneAction action = ActionQueue.instance.current as CloneAction; float newAngle = ushort.MaxValue * 9.58738E-05f * (Input.mousePosition.x - m_mouseStartX) / Screen.width; if (Event.current.control) { float quarterPI = Mathf.PI / 4; newAngle = quarterPI * Mathf.Round(newAngle / quarterPI); } newAngle += m_startAngle; if (action.angleDelta != newAngle) { action.angleDelta = newAngle; } UIToolOptionPanel.RefreshSnapButton(); break; } case ToolStates.DrawingSelection: { RaycastHoverInstance(mouseRay); m_marqueeInstances = GetMarqueeList(mouseRay); break; } } } } }
protected override void OnToolGUI(Event e) { if (UIView.HasModalInput() || UIView.HasInputFocus()) { return; } lock (ActionQueue.instance) { if (ToolState == ToolStates.Default) { if (OptionsKeymapping.undo.IsPressed(e)) { m_nextAction = ToolAction.Undo; } else if (OptionsKeymapping.redo.IsPressed(e)) { m_nextAction = ToolAction.Redo; } } if (OptionsKeymapping.clone.IsPressed(e)) { if (ToolState == ToolStates.Cloning || ToolState == ToolStates.RightDraggingClone) { StopCloning(); } else { StartCloning(); } } else if (OptionsKeymapping.bulldoze.IsPressed(e)) { StartBulldoze(); } else if (OptionsKeymapping.reset.IsPressed(e)) { StartReset(); } else if (OptionsKeymapping.viewGrid.IsPressed(e)) { if (gridVisible) { gridVisible = false; UIToolOptionPanel.instance.grid.activeStateIndex = 0; } else { gridVisible = true; UIToolOptionPanel.instance.grid.activeStateIndex = 1; } } else if (OptionsKeymapping.viewUnderground.IsPressed(e)) { if (tunnelVisible) { tunnelVisible = false; UIToolOptionPanel.instance.underground.activeStateIndex = 0; } else { tunnelVisible = true; UIToolOptionPanel.instance.underground.activeStateIndex = 1; } } else if (OptionsKeymapping.viewDebug.IsPressed(e)) { showDebugPanel.value = !showDebugPanel; if (m_debugPanel != null) { m_debugPanel.Visible(showDebugPanel); } } else if (OptionsKeymapping.activatePO.IsPressed(e)) { if (PO.Active == false) { PO.Active = true; UIToolOptionPanel.instance.PO_button.activeStateIndex = 1; PO.ToolEnabled(); } else { PO.Active = false; UIToolOptionPanel.instance.PO_button.activeStateIndex = 0; } UIFilters.POToggled(); } else if (OptionsKeymapping.convertToPO.IsPressed(e)) { if (PO.Enabled && ToolState == ToolStates.Default) { if (PO.Active == false) { PO.Active = true; UIToolOptionPanel.instance.PO_button.activeStateIndex = 1; PO.ToolEnabled(); UIFilters.POToggled(); } ConvertToPOAction convertAction = new ConvertToPOAction(); ActionQueue.instance.Push(convertAction); ActionQueue.instance.Do(); } } else if (OptionsKeymapping.alignHeights.IsPressed(e)) { ProcessAligning(AlignModes.Height); } else if (OptionsKeymapping.alignSlope.IsPressed(e)) { ProcessAligning(AlignModes.Slope); } else if (OptionsKeymapping.alignMirror.IsPressed(e)) { ProcessAligning(AlignModes.Mirror); } else if (OptionsKeymapping.alignSlopeQuick.IsPressed(e)) { AlignMode = AlignModes.SlopeNode; if (ToolState == ToolStates.Cloning || ToolState == ToolStates.RightDraggingClone) { StopCloning(); } AlignSlopeAction asa = new AlignSlopeAction { followTerrain = followTerrain, IsQuick = true }; ActionQueue.instance.Push(asa); ActionQueue.instance.Do(); if (autoCloseAlignTools) { UIMoreTools.MoreToolsPanel.isVisible = false; } DeactivateTool(); } else if (OptionsKeymapping.alignInplace.IsPressed(e)) { ProcessAligning(AlignModes.Inplace); } else if (OptionsKeymapping.alignGroup.IsPressed(e)) { ProcessAligning(AlignModes.Group); } else if (OptionsKeymapping.alignRandom.IsPressed(e)) { AlignMode = AlignModes.Random; if (ToolState == ToolStates.Cloning || ToolState == ToolStates.RightDraggingClone) { StopCloning(); } AlignRandomAction action = new AlignRandomAction(); action.followTerrain = followTerrain; ActionQueue.instance.Push(action); ActionQueue.instance.Do(); DeactivateTool(); } if (ToolState == ToolStates.Cloning) { if (ProcessMoveKeys(e, out Vector3 direction, out float angle)) { CloneAction action = ActionQueue.instance.current as CloneAction; action.moveDelta.y += direction.y * YFACTOR; action.angleDelta += angle; } } else if (ToolState == ToolStates.Default && Action.selection.Count > 0) { if (ProcessMoveKeys(e, out Vector3 direction, out float angle)) { if (!(ActionQueue.instance.current is TransformAction action)) { action = new TransformAction(); ActionQueue.instance.Push(action); } if (direction != Vector3.zero) { direction.x = direction.x * XFACTOR; direction.y = direction.y * YFACTOR; direction.z = direction.z * ZFACTOR; if (!useCardinalMoves) { Matrix4x4 matrix4x = default; matrix4x.SetTRS(Vector3.zero, Quaternion.AngleAxis(Camera.main.transform.localEulerAngles.y, Vector3.up), Vector3.one); direction = matrix4x.MultiplyVector(direction); } } action.moveDelta += direction; action.angleDelta += angle; action.followTerrain = followTerrain; m_nextAction = ToolAction.Do; } } } }
protected override void OnToolGUI(Event e) { if (UIView.HasModalInput() || UIView.HasInputFocus()) { return; } lock (ActionQueue.instance) { if (ToolState == ToolStates.Default || ToolState == ToolStates.ToolActive) { if (OptionsKeymapping.undo.IsPressed(e)) { m_nextAction = ToolAction.Undo; } else if (OptionsKeymapping.redo.IsPressed(e)) { m_nextAction = ToolAction.Redo; } } if (OptionsKeymapping.clone.IsPressed(e)) { if (ToolState == ToolStates.Cloning || ToolState == ToolStates.RightDraggingClone) { StopCloning(); } else { StartCloning(); } } else if (OptionsKeymapping.bulldoze.IsPressed(e)) { StartBulldoze(); } else if (OptionsKeymapping.reset.IsPressed(e)) { StartReset(); } else if (OptionsKeymapping.viewGrid.IsPressed(e)) { if (gridVisible) { gridVisible = false; UIToolOptionPanel.instance.grid.activeStateIndex = 0; } else { gridVisible = true; UIToolOptionPanel.instance.grid.activeStateIndex = 1; } } else if (OptionsKeymapping.viewUnderground.IsPressed(e)) { if (tunnelVisible) { tunnelVisible = false; UIToolOptionPanel.instance.underground.activeStateIndex = 0; } else { tunnelVisible = true; UIToolOptionPanel.instance.underground.activeStateIndex = 1; } } else if (OptionsKeymapping.viewDebug.IsPressed(e)) { showDebugPanel.value = !showDebugPanel; if (m_debugPanel != null) { ClearDebugOverlays(); m_debugPanel.Visible(showDebugPanel); } } else if (OptionsKeymapping.viewSelectors.IsPressed(e)) { m_showSelectors = !m_showSelectors; } else if (OptionsKeymapping.activatePO.IsPressed(e)) { PO.InitialiseTool(); } else if (OptionsKeymapping.convertToPO.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_ConvertToPOBtn"); } else if (OptionsKeymapping.deselectAll.IsPressed(e)) { if (ToolState == ToolStates.Cloning) { StopCloning(); } else if (ToolState == ToolStates.Aligning || ToolState == ToolStates.ToolActive || ToolState == ToolStates.Picking || ToolState != ToolStates.MouseDragging) { if (ToolState == ToolStates.Picking) { UIFilters.UpdatePickerButton(1); } DeactivateTool(); } if (!(ActionQueue.instance.current is SelectAction)) { SelectAction action = new SelectAction(); ActionQueue.instance.Push(action); } else { Action.selection.Clear(); ActionQueue.instance.Invalidate(); } m_debugPanel.UpdatePanel(); } else if (OptionsKeymapping.alignHeights.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignHeightBtn"); } else if (OptionsKeymapping.alignTerrainHeight.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignTerrainHeightBtn"); } else if (OptionsKeymapping.alignMirror.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignMirrorBtn"); } else if (OptionsKeymapping.alignLine.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignLineBtn"); } else if (OptionsKeymapping.alignLineUnspaced.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignLineBtn", false, true); } else if (OptionsKeymapping.alignSlope.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignSlopeBtn"); } else if (OptionsKeymapping.alignSlopeQuick.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignSlopeBtn", true); } else if (OptionsKeymapping.alignSlopeFull.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignSlopeBtn", false, true); } else if (OptionsKeymapping.alignInplace.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignIndividualBtn"); } else if (OptionsKeymapping.alignGroup.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignGroupBtn"); } else if (OptionsKeymapping.alignRandom.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_AlignRandomBtn"); } else if (OptionsKeymapping.alignMoveTo.IsPressed(e)) { UIMoreTools.MoreToolsClicked("MoveIt_MoveToBtn"); } if (ToolState == ToolStates.Cloning) { if (ProcessMoveKeys(e, out Vector3 direction, out float angle)) { CloneAction action = ActionQueue.instance.current as CloneAction; action.moveDelta.y += direction.y * YFACTOR; action.angleDelta += angle; } } else if (ToolState == ToolStates.Default && Action.HasSelection()) { if (ProcessMoveKeys(e, out Vector3 direction, out float angle)) { if (!(ActionQueue.instance.current is TransformAction action)) { action = new TransformAction(); ActionQueue.instance.Push(action); } if (direction != Vector3.zero) { direction.x *= XFACTOR; direction.y *= YFACTOR; direction.z *= ZFACTOR; if (!useCardinalMoves) { Matrix4x4 matrix4x = default; matrix4x.SetTRS(Vector3.zero, Quaternion.AngleAxis(Camera.main.transform.localEulerAngles.y, Vector3.up), Vector3.one); direction = matrix4x.MultiplyVector(direction); } } action.moveDelta += direction; action.angleDelta += angle; action.followTerrain = followTerrain; m_nextAction = ToolAction.Do; } else if (ProcessScaleKeys(e, out float magnitude)) { if (!(ActionQueue.instance.current is ScaleAction action)) { action = new ScaleAction(); ActionQueue.instance.Push(action); } action.magnitude += magnitude; action.followTerrain = followTerrain; m_nextAction = ToolAction.Do; } } }
public IEnumerator <object> RetrieveClone(MoveableProc original, Vector3 position, float angle, Action action) { const uint MaxAttempts = 100_000; CloneAction ca = (CloneAction)action; if (!(original.m_procObj is PO_Object)) { Debug.Log($"PO Cloning failed: object not found"); MoveItTool.POProcessing--; yield break; } Type[] types = new Type[] { tPO, tPO.MakeByRefType(), typeof(uint).MakeByRefType() }; object[] paramList = new[] { original.m_procObj.GetProceduralObject(), null, null }; MethodInfo retrieve = tPOMoveIt.GetMethod("TryRetrieveClone", BindingFlags.Public | BindingFlags.Static, null, types, null); if (retrieve == null) { Debug.Log($"PO Cloning failed: retrieve not found"); MoveItTool.POProcessing--; yield break; } uint c = 0; while (c < MaxAttempts && !(bool)retrieve.Invoke(null, paramList)) { //if (c % 100 == 0) //{ // BindingFlags f = BindingFlags.Static | BindingFlags.Public; // object queueObj = tPOMoveIt.GetField("queuedCloning", f).GetValue(null); // int queueCount = (int)queueObj.GetType().GetProperty("Count").GetValue(queueObj, null); // object doneObj = tPOMoveIt.GetField("doneCloning", f).GetValue(null); // int doneCount = (int)doneObj.GetType().GetProperty("Count").GetValue(doneObj, null); //} c++; yield return(new WaitForSeconds(0.05f)); } if (c == MaxAttempts) { throw new Exception($"Failed to clone object #{original.m_procObj.Id}! [PO-F4]"); } try { PO_Object clone = new PO_Object(paramList[1]) { POColor = original.m_procObj.POColor }; InstanceID cloneID = default; cloneID.NetLane = clone.Id; MoveItTool.PO.visibleObjects.Add(cloneID.NetLane, clone); MoveableProc cloneInstance = new MoveableProc(cloneID) { position = position, angle = angle }; Action.selection.Add(cloneInstance); ca.m_clones.Add(cloneInstance); ca.m_origToClone.Add(original, cloneInstance); MoveItTool.SetToolState(); MoveItTool.instance.ProcessSensitivityMode(false); Debug.Log($"Cloned PO {original.m_procObj.Id} to #{clone.Id}"); } catch (Exception e) { Debug.Log($"Exception when cloning PO:\n{e}"); } yield return(new WaitForSeconds(0.25f)); MoveItTool.POProcessing--; }
protected override void OnToolUpdate() { if (m_nextAction != ToolAction.None) { return; } if (m_pauseMenu != null && m_pauseMenu.isVisible) { if (ToolState == ToolStates.Default || ToolState == ToolStates.MouseDragging || ToolState == ToolStates.DrawingSelection) { ToolsModifierControl.SetTool <DefaultTool>(); } StopCloning(); StopTool(); SetToolState(); UIView.library.Hide("PauseMenu"); return; } lock (ActionQueue.instance) { bool isInsideUI = this.m_toolController.IsInsideUI; if (m_leftClickTime == 0 && Input.GetMouseButton(0)) { if (!isInsideUI) { m_leftClickTime = Stopwatch.GetTimestamp(); OnLeftMouseDown(); } } if (m_leftClickTime != 0) { long elapsed = ElapsedMilliseconds(m_leftClickTime); if (!Input.GetMouseButton(0)) { m_leftClickTime = 0; if (elapsed < 250) { try { OnLeftClick(); } catch (MissingMethodException e) { Log.Debug("Prop Painter [OnLeftClick] error: " + e.ToString()); } } else { OnLeftDragStop(); } try { OnLeftMouseUp(); } catch (MissingMethodException e) { Log.Debug("Prop Painter [OnLeftMouseUp] error: " + e.ToString()); } } else if (elapsed >= 250) { OnLeftDrag(); } } if (m_rightClickTime == 0 && Input.GetMouseButton(1)) { if (!isInsideUI) { m_rightClickTime = Stopwatch.GetTimestamp(); OnRightMouseDown(); } } if (m_rightClickTime != 0) { long elapsed = ElapsedMilliseconds(m_rightClickTime); if (!Input.GetMouseButton(1)) { m_rightClickTime = 0; if (elapsed < 250) { OnRightClick(); } else { OnRightDragStop(); } OnRightMouseUp(); } else if (elapsed >= 250) { OnRightDrag(); } } if (m_middleClickTime == 0 && Input.GetMouseButton(2) && Event.current.control) { if (!isInsideUI) { m_middleClickTime = Stopwatch.GetTimestamp(); OnMiddleMouseDown(); } } if (m_middleClickTime != 0) { long elapsed = ElapsedMilliseconds(m_middleClickTime); if (!Input.GetMouseButton(2)) { m_middleClickTime = 0; if (elapsed < 250) { OnMiddleClick(); } else { OnMiddleDragStop(); } OnMiddleMouseUp(); } else if (elapsed >= 250) { OnMiddleDrag(); } } if (!isInsideUI && Cursor.visible) { Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); m_hoverInstance = null; m_marqueeInstances = null; m_segmentGuide = default; switch (ToolState) { case ToolStates.Default: case ToolStates.Aligning: case ToolStates.Picking: case ToolStates.ToolActive: { RaycastHoverInstance(mouseRay); break; } case ToolStates.MouseDragging: { TransformAction action = ActionQueue.instance.current as TransformAction; Vector3 newMove = action.moveDelta; float newAngle = action.angleDelta; float newSnapAngle = 0f; if (snapping) { action.Virtual = false; } else { if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { action.Virtual = !fastMove; } else { action.Virtual = fastMove; } } if (m_leftClickTime > 0 != m_middleClickTime > 0) { UpdateSensitivityMode(); float y = action.moveDelta.y; if (m_isLowSensitivity || m_middleClickTime > 0) { Vector3 mouseDeltaBefore = m_sensitivityTogglePosAbs - m_clickPositionAbs; Vector3 mouseDeltaAfter = (RaycastMouseLocation(mouseRay) - m_sensitivityTogglePosAbs) / 5f; newMove = m_dragStartRelative + mouseDeltaBefore + mouseDeltaAfter; } else { newMove = m_dragStartRelative + (RaycastMouseLocation(mouseRay) - m_clickPositionAbs); } newMove.y = y; } if (m_rightClickTime > 0) { UpdateSensitivityMode(); if (m_isLowSensitivity) { float mouseRotateBefore = m_sensitivityTogglePosX - m_sensitivityAngleOffset; float mouseRotateAfter = (Input.mousePosition.x - m_sensitivityTogglePosX) / 5; float mouseTravel = (mouseRotateBefore + mouseRotateAfter - m_mouseStartX) / Screen.width * 1.2f; newAngle = ushort.MaxValue * 9.58738E-05f * mouseTravel; } else { newAngle = ushort.MaxValue * 9.58738E-05f * (Input.mousePosition.x - m_mouseStartX) / Screen.width * 1.2f; } if (Event.current.alt) { float quarterPI = Mathf.PI / 4; newAngle = quarterPI * Mathf.Round(newAngle / quarterPI); } newAngle += m_startAngle; action.autoCurve = false; } else if (snapping) { newMove = GetSnapDelta(newMove, newAngle, action.center, out action.autoCurve); if (action.autoCurve) { action.segmentCurve = m_segmentGuide; } } else { action.autoCurve = false; } if (action.moveDelta != newMove || action.angleDelta != newAngle || action.snapAngle != newSnapAngle) { action.moveDelta = newMove; action.angleDelta = newAngle; action.snapAngle = newSnapAngle; action.followTerrain = followTerrain; m_nextAction = ToolAction.Do; } UIToolOptionPanel.RefreshSnapButton(); break; } case ToolStates.Cloning: { if (m_rightClickTime != 0) { break; } UpdateSensitivityMode(); CloneAction action = ActionQueue.instance.current as CloneAction; Vector3 newMove; float y = action.moveDelta.y; if (m_isLowSensitivity) { Vector3 mouseDeltaBefore = m_sensitivityTogglePosAbs - m_clickPositionAbs; Vector3 mouseDeltaAfter = (RaycastMouseLocation(mouseRay) - m_sensitivityTogglePosAbs) / 5; newMove = mouseDeltaBefore + mouseDeltaAfter; } else { newMove = RaycastMouseLocation(mouseRay) - action.center; } newMove.y = y; if (snapping) { newMove = GetSnapDelta(newMove, action.angleDelta, action.center, out bool autoCurve); } if (action.moveDelta != newMove) { action.moveDelta = newMove; } UIToolOptionPanel.RefreshSnapButton(); break; } case ToolStates.RightDraggingClone: { UpdateSensitivityMode(); CloneAction action = ActionQueue.instance.current as CloneAction; float newAngle; if (m_isLowSensitivity) { float mouseRotateBefore = m_sensitivityTogglePosX - m_sensitivityAngleOffset; float mouseRotateAfter = (Input.mousePosition.x - m_sensitivityTogglePosX) / 5; float mouseTravel = (mouseRotateBefore + mouseRotateAfter - m_mouseStartX) / Screen.width * 1.2f; newAngle = ushort.MaxValue * 9.58738E-05f * mouseTravel; } else { newAngle = ushort.MaxValue * 9.58738E-05f * (Input.mousePosition.x - m_mouseStartX) / Screen.width * 1.2f; } if (Event.current.alt) { float quarterPI = Mathf.PI / 4; newAngle = quarterPI * Mathf.Round(newAngle / quarterPI); } newAngle += m_startAngle; if (action.angleDelta != newAngle) { action.angleDelta = newAngle; } UIToolOptionPanel.RefreshSnapButton(); break; } case ToolStates.DrawingSelection: { RaycastHoverInstance(mouseRay); m_marqueeInstances = GetMarqueeList(mouseRay); break; } } } } }