private void UpdateCursor(MeshHitTarget potentialMeshInteraction) { ConstructionCursor.MouseState state = Input.GetMouseButton(0) ? ConstructionCursor.MouseState.LeftClickDown : (Input.GetMouseButton(1) ? ConstructionCursor.MouseState.RightClickDown : ConstructionCursor.MouseState.Hovering); cursor.UpdateCursor(potentialMeshInteraction, state); }
private void Update() { if (GroundModificationMode) { DoEasing(); GridExpander expander = new GridExpander(gameMain.MainGrid, ExpansionAngleThreshold); expander.PreviewExpansion(gameMain.MainGrid); if (Input.GetMouseButtonUp(0)) { gameMain.MainGrid.AddToMesh(expander.Points, expander.Edges); gameMain.UpdateInteractionGrid(); } } else { MeshHitTarget potentialMeshInteraction = GetPotentialMeshInteraction(); UpdateCursor(potentialMeshInteraction); HandleRightMeshClicks(potentialMeshInteraction); HandleLeftMeshClicks(potentialMeshInteraction); } UpdateCursorHighlight(); HandleOrbit(); HandlePan(); cameraInteraction.HandleMouseScrollwheel(); }
private void HandleRightMeshClicks(MeshHitTarget hitInfo) { if (Input.GetMouseButtonUp(1) && hitInfo != null && hitInfo.SourceCell != null) { hitInfo.SourceCell.Filled = false; gameMain.UpdateInteractionGrid(); gameMain.UpdateVoxelVisuals(hitInfo.SourceCell); } }
private void HandleLeftMeshClicks(MeshHitTarget hitInfo) { if (Input.GetMouseButtonUp(0) && hitInfo != null && hitInfo.TargetCell != null) { hitInfo.TargetCell.Filled = true; gameMain.UpdateInteractionGrid(); gameMain.UpdateVoxelVisuals(hitInfo.TargetCell); } }
private MeshHitTarget GetPotentialMeshInteraction() { if (rightDragDetector.IsDragging || leftDragDetector.IsDragging) { return(null); } RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { MeshHitTarget ret = gameMain.InteractionMesh.GetHitTarget(hit.triangleIndex); if (ret != null && !(ret.TargetCell != null && ret.TargetCell.GroundPoint.IsBorder)) { return(ret); } } return(null); }