private static void MirrorBoard(MirrorAxis axis) { if (BoardBeingPlaced.GetComponentsInChildren <CircuitBoard>().Length > 1) { return; } // everything will be screwed up if we have a board with other boards attached to it List <Transform> childcomponents = new List <Transform>(); for (int i = 0; i < BoardBeingPlaced.transform.childCount; i++) { childcomponents.Add(BoardBeingPlaced.transform.GetChild(i)); } foreach (Transform child in childcomponents) { if (axis == MirrorAxis.x) { float Xcenter = (CircuitBoardBeingPlaced.x * 0.3f) / 2; float DistanceFromCenter = Mathf.Abs(Xcenter - child.localPosition.x); float NewX = child.localPosition.x; if (child.transform.localPosition.x > Xcenter) { NewX = Xcenter - DistanceFromCenter; } else if (child.transform.localPosition.x < Xcenter) { NewX = Xcenter + DistanceFromCenter; } child.transform.localPosition = new Vector3(NewX, child.transform.localPosition.y, child.transform.localPosition.z); Quaternion oldrot = child.transform.localRotation; child.transform.localRotation = new Quaternion(-oldrot.x, oldrot.y, oldrot.z, -oldrot.w); // this is my first time really using quaternions. I have absolutely no idea how this works, I found it on google } else { float Zcenter = (CircuitBoardBeingPlaced.z * 0.3f) / 2; float DistanceFromCenter = Mathf.Abs(Zcenter - child.localPosition.z); float NewZ = child.localPosition.z; if (child.transform.localPosition.z > Zcenter) { NewZ = Zcenter - DistanceFromCenter; } else if (child.transform.localPosition.z < Zcenter) { NewZ = Zcenter + DistanceFromCenter; } child.transform.localPosition = new Vector3(child.transform.localPosition.x, child.transform.localPosition.y, NewZ); Quaternion oldrot = child.transform.localRotation; child.transform.localRotation = new Quaternion(oldrot.x, oldrot.y, -oldrot.z, -oldrot.w); child.transform.localEulerAngles += new Vector3(180, 0, 180); // why is the previous effect always off by 180 on two axes? I don't f*****g know! Quaternions!!!!!!!! } StuffRotater.RedrawCircuitGeometryOf(BoardBeingPlaced); } }
// called once per frame public static void DoInteraction() { if (Input.GetButtonDown("BoardMenu")) { BoardMenu.Instance.InitializeBoardMenu(); Done(); return; } if (Input.GetButtonDown("PickComponent")) { SelectionMenu.Instance.PickComponent(); } if (Input.GetButtonDown("Interact")) { RaycastHit hit; if (Physics.Raycast(Ray(), out hit, Settings.ReachDistance, IgnorePlayerLayermask)) { if (hit.collider.tag == "Interactable") // if the cast hits an interactable such as a button or lever, interact with it { hit.collider.GetComponent <Interactable>().Interact(); return; // so we can't place stuff too, as they are bound to the same key } } } if (Input.GetButtonDown("Zoom")) { FirstPersonCamera.fieldOfView = 10; FirstPersonController.Instance.m_MouseLook.XSensitivity /= 3; FirstPersonController.Instance.m_MouseLook.YSensitivity /= 3; } if (Input.GetButtonUp("Zoom")) { SettingsApplier.Instance.LoadFOV(); SettingsApplier.Instance.LoadXSensitivity(); SettingsApplier.Instance.LoadYSensitivity(); } if (Input.GetButtonDown("Cancel")) { PauseMenu.Instance.PauseGame(); } if (Input.GetButtonDown("UndoBoardDelete")) { BoardFunctions.RestoreMostRecentlyDeletedBoard(); return; } ComponentPlacer.RunComponentPlacing(); WirePlacer.RunWirePlacing(); StuffDeleter.RunGameplayDeleting(); StuffRotater.RunGameplayRotation(); SelectionMenu.Instance.RunBuildMenu(); LookThroughBoard.Run(); }
public override void Do() { var RotateThis = NetObject.GetByNetId(Packet.ComponentID)?.gameObject; if (RotateThis != null) { BoxCollider[] componentsInChildren = RotateThis.GetComponentsInChildren <BoxCollider>(); SoundPlayer.PlaySoundAt(Sounds.RotateSomething, RotateThis); RotateThis.transform.localEulerAngles = Packet.EulerAngles; FloatingPointRounder.RoundIn(RotateThis, false); StuffRotater.RedrawCircuitGeometryOf(RotateThis); StuffRotater.DestroyIntersectingConnections(RotateThis); SnappingPeg.TryToSnapIn(RotateThis); MegaMeshManager.RecalculateGroupsOf(RotateThis); } }