public override void OnKeyDown(KButtonEvent e) { if (e.TryConsume(Action.RotateBuilding)) { if ((Object)visualizer != (Object)null) { Rotatable component = visualizer.GetComponent <Rotatable>(); if ((Object)component != (Object)null) { KFMOD.PlayOneShot(GlobalAssets.GetSound("HUD_Rotate", false)); buildingOrientation = component.Rotate(); if (Grid.IsValidBuildingCell(lastCell)) { Vector3 pos = Grid.CellToPosCCC(lastCell, Grid.SceneLayer.Building); UpdateVis(pos); } if (base.Dragging && lastDragCell != -1) { TryBuild(lastDragCell); } } } } else { base.OnKeyDown(e); } }
private void OnRotateClicked() { Rotatable rotatable = this.gameObject.GetComponent <Rotatable>(); if (rotatable != null) { rotatable.Rotate(); // Buildings with even width values jump one tile when rotating and must be moved back Building building = this.gameObject.GetComponent <Building>(); if (building != null && building.Def != null && building.Def.WidthInCells % 2 == 0) { this.transform.position += rotatable.GetOrientation() != Orientation.Neutral ? new UnityEngine.Vector3(1, 0, 0) : new UnityEngine.Vector3(-1, 0, 0); } } }
private void OnRotateClicked() { Rotatable rotatable = this.gameObject.GetComponent <Rotatable>(); if (rotatable != null) { rotatable.Rotate(); } BuildingDef def = this.gameObject.GetComponent <Building>()?.Def; if (def != null && def.WidthInCells % 2 == 0) { this.transform.position += rotatable.GetOrientation() != Orientation.Neutral ? new UnityEngine.Vector3(1, 0, 0) : new UnityEngine.Vector3(-1, 0, 0); } artable.SetStage(artable.CurrentStage, false); }
// ------------------------------------------------------------------------------- public void Update() { // The Universe sphere doesn't have collision becaue we're *inside* the sphere // which messes up Raycasts and input events, so calculate input drag manually.. if (Input.GetMouseButton(0) && !Input.GetMouseButtonDown(0)) { var mouseDelta = Input.mousePosition - mPrevMousePosition; if (mouseDelta.sqrMagnitude > 0.0f) { mRotatable.Rotate(mouseDelta); } } mPrevMousePosition = Input.mousePosition; // Make sure the home planetoid's star always has the same flat rotation Universe.CurrentHomePlanetoid.DistantStar.transform.up = Vector3.up; }
///------------------------------------------------------------------------------------------------- /// \fn private void TrackBar1_Scroll(object sender, EventArgs e) /// /// \brief Event handler. Called by TrackBar1 for scroll events /// /// \param sender Source of the event. /// \param e Event information. ///------------------------------------------------------------------------------------------------- private void TrackBar1_Scroll(object sender, EventArgs e) { whichToBeRotated.Rotate(rotatingButton_mid.Location, trackBar.Value); History.GetInstance().Update(); }