private static void ConnectionFinal() { if (CurrentWirePlacementIsValid()) { StuffPlacer.RemoveOutlineFromObject(WireBeingPlaced); WireBeingPlaced.GetComponent <Wire>().SetPegsBasedOnPoints(); StuffConnector.LinkConnection(WireBeingPlaced); StuffConnector.SetAppropriateConnectionParent(WireBeingPlaced); WireBeingPlaced.AddComponent <ObjectInfo>().ComponentType = ComponentType.Wire; WireBeingPlaced.GetComponent <BoxCollider>().enabled = true; SoundPlayer.PlaySoundAt(Sounds.ConnectionFinal, WireBeingPlaced); WireBeingPlaced = null; } else if (SelectedPeg != null) { SoundPlayer.PlaySoundAt(Sounds.FailDoSomething, SelectedPeg); // I'm using SelectedPeg instead of WireBeingPlaced here because I'm lazy; WireBeingPlaced might not exist } if (AutoHidePlacingGhostWhileConnecting) { ComponentPlacer.ShowPlacingGhost = PlacingGhostWasHiddenBeforeConnecting; } DoneConnecting(); }
public static void DestroyBoardBeingPlaced() { ReferenceObject.transform.parent = null; // without this line the referenceobject is left on the board and you are unable to delete it without move board if (BoardBeingPlaced == null) { return; } // so that we don't end up with empty clusters when deleting boards. // this code is from stuffdeleter.cs. TODO: merge in a nice way CircuitInput[] inputs = BoardBeingPlaced.GetComponentsInChildren <CircuitInput>(); CircuitOutput[] outputs = BoardBeingPlaced.GetComponentsInChildren <CircuitOutput>(); foreach (CircuitInput input in inputs) { StuffDeleter.DestroyInput(input); } foreach (CircuitOutput output in outputs) { StuffDeleter.DestroyOutput(output); } BoardBeingPlaced.transform.parent = null; // this is done so that when StuffPlacer sets the BoxCollidersOfThingBeingPlaced it doesn't get the box collider from the old board. Maybe a better way would be DestroyImmediate but the documentation is really insistant that you don't use that so IDK. Man... the extent to which stuff in this codebase is interdependant on other stuff in unintuitive ways really bothers me. I'll need to refactor the refactor at this rate... Object.Destroy(BoardBeingPlaced); StuffPlacer.ResetReferences(); }
private static void PlaceNewWire() { WireBeingPlaced = Object.Instantiate(Prefabs.Wire); StuffPlacer.OutlineObject(WireBeingPlaced); Wire addedwire = null; if (SelectedPeg.tag == "Input" && PegBeingLookedAt.tag == "Input") { addedwire = WireBeingPlaced.AddComponent <InputInputConnection>(); addedwire.Point1 = Wire.GetWireReference(SelectedPeg); addedwire.Point2 = Wire.GetWireReference(PegBeingLookedAt); } else { addedwire = WireBeingPlaced.AddComponent <InputOutputConnection>(); if (SelectedPeg.tag == "Input") { addedwire.Point1 = Wire.GetWireReference(SelectedPeg); addedwire.Point2 = Wire.GetWireReference(PegBeingLookedAt); } else { addedwire.Point2 = Wire.GetWireReference(SelectedPeg); addedwire.Point1 = Wire.GetWireReference(PegBeingLookedAt); } } addedwire.DrawWire(); addedwire.GetComponent <BoxCollider>().enabled = false; RotateWireBeingPlaced(PersistentDegrees); // so if you want to place many wires in a row with custom rotation you don't have to keep giving them that custom rotation }
public override void DeletePreview() { foreach (var item in GetWires()) { StuffPlacer.RemoveOutlineFromObject(item.gameObject); } }
private static bool PlacingGhostWasHiddenBeforeConnecting = ComponentPlacer.ShowPlacingGhost; // necessary to avoid BUGS! private static void ConnectionInitial() { RaycastHit hit; if (!Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask)) { return; } if (hit.collider.tag == "Input" || hit.collider.tag == "Output") // if it's an input or output... { SelectedPeg = hit.collider.gameObject; // ..make it the selected peg StuffPlacer.OutlineObject(SelectedPeg); PegBeingLookedAt = null; // fixes SetPegBeingLookedAt removing the outline if (AutoHidePlacingGhostWhileConnecting) { StuffPlacer.DeleteThingBeingPlaced(); PlacingGhostWasHiddenBeforeConnecting = ComponentPlacer.ShowPlacingGhost; ComponentPlacer.ShowPlacingGhost = false; } StuffRotater.AllowedToDoRotation = false; // so you can rotate wires while placing them StuffDeleter.AllowedToDoDeleting = false; // prevents a bug with how null is not the same as destroyed SoundPlayer.PlaySoundAt(Sounds.ConnectionInitial, SelectedPeg); } else { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); DoneConnecting(); } }
private void HighlightLookedAtBoard() { RaycastHit hit; if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask)) { if (hit.collider.tag == "CircuitBoard") { GameObject highlightthis = hit.collider.gameObject; if (Input.GetButton("Mod")) { GameObject RootObject = hit.collider.transform.root.gameObject; if (RootObject.tag == "CircuitBoard") // protection from mounts { highlightthis = hit.collider.transform.root.gameObject; } } if (highlightthis != highlightedboard) { RemoveOutlineFromLookedAtBoard(); highlightedboard = highlightthis; StuffPlacer.OutlineObject(highlightedboard, OutlineColor.blue); } } else { RemoveOutlineFromLookedAtBoard(); } } else { RemoveOutlineFromLookedAtBoard(); } }
private void IterationsChanged() { if (Iterations >= AllSubBoardsInvolvedWithStacking.Count) { int NumberOfNewBoards = Iterations + 1 - AllSubBoardsInvolvedWithStacking.Count; for (int i = 0; i < NumberOfNewBoards; i++) { GameObject NewBoard = Instantiate(BoardBeingStackedCopy); NewBoard.transform.position = new Vector3(1000, -1000, 1000); // so RecalculateCluster can work unhindered NewBoard.transform.parent = AllSubBoardsInvolvedWithStacking[AllSubBoardsInvolvedWithStacking.Count - 1].transform; StuffPlacer.SetStateOfAllBoxCollidersIn(NewBoard, false); AllSubBoardsInvolvedWithStacking.Add(NewBoard); BoardFunctions.RecalculateClustersOfBoard(NewBoard); MegaMeshManager.RemoveComponentsImmediatelyIn(NewBoard); MegaMeshManager.AddComponentsIn(NewBoard); } } else if (Iterations < AllSubBoardsInvolvedWithStacking.Count) { //int NumberOfExtraBoards = AllSubBoardsInvolvedWithStacking.Count + 1 - Iterations; for (int i = AllSubBoardsInvolvedWithStacking.Count - 1; i > Iterations; i--) { GameObject oldboard = AllSubBoardsInvolvedWithStacking[i]; AllSubBoardsInvolvedWithStacking.Remove(oldboard); oldboard.transform.parent = null; // because the board is not destroyed immediately, this is done to prevent the old board from being used in the interesction test of UpdateHighlight Destroy(oldboard); } } SetAllBoardPositions(); }
public void Place() { if (!CurrentPlacementIsValid) { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } StuffPlacer.RemoveOutlineFromObject(BoardBeingStacked); StuffPlacer.SetStateOfAllBoxCollidersIn(BoardBeingStacked, true); FloatingPointRounder.RoundIn(BoardBeingStacked, true); SnappingPeg.TryToSnapIn(BoardBeingStacked); MegaMeshManager.AddComponentsIn(StackedBoard); foreach (VisualUpdaterWithMeshCombining visualboi in StackedBoard.GetComponentsInChildren <VisualUpdaterWithMeshCombining>()) { visualboi.AllowedToCombineOnStable = true; } SoundPlayer.PlaySoundAt(Sounds.PlaceOnBoard, BoardBeingStacked); BoardBeingStacked = null; BoardBeingStackedCircuitBoard = null; AllSubBoardsInvolvedWithStacking = new List <GameObject>(); Done(); }
public static void NewBoardBeingPlaced(GameObject NewBoard) { if (NewBoard == null) { return; } DestroyBoardBeingPlaced(); BoardBeingPlaced = NewBoard; NewBoard.transform.parent = ReferenceObject.transform; CircuitBoardBeingPlaced = NewBoard.GetComponent <CircuitBoard>(); SetRotationState(); CapPlacingOffset(); StuffPlacer.BoardRotationLockAngle = Mathf.Round(StuffPlacer.BoardRotationLockAngle / 90f) * 90; // fixes being able to place boards at non-right angles by locking rotation beforehand StuffPlacer.RotationAboutUpVector = Mathf.RoundToInt(StuffPlacer.RotationAboutUpVector / 90) * 90f; if (!BoardBeingPlaced.GetComponent <ObjectInfo>()) { BoardBeingPlaced.AddComponent <ObjectInfo>().ComponentType = ComponentType.CircuitBoard; } BoardFunctions.DestroyAllWiresConnectedToBoardButNotPartOfIt(NewBoard); StuffPlacer.NewThingBeingPlaced(ReferenceObject); }
public bool LoadedMount = false; // set in LoadSaveObject private void Start() { if (!LoadedMount)// only do this for new mounts. This is uncomfortably hacky { GameObject TheBoardPart = Instantiate(References.Prefabs.CircuitBoard, transform); TheBoardPart.transform.localPosition = new Vector3(-0.15f, 0.65f, -0.15f); TheBoardPart.transform.localEulerAngles = new Vector3(0, 90, 90); TheBoardPart.AddComponent <ObjectInfo>().ComponentType = ComponentType.CircuitBoard; TheBoardPart.tag = "PlaceOnlyCircuitBoard"; Destroy(TheBoardPart.GetComponent <MegaMeshComponent>()); CircuitBoard board = TheBoardPart.GetComponent <CircuitBoard>(); board.CreateCuboid(); board.SetBoardColor(Color.white); // necessary for the board to appear in the selection menu MegaMeshManager.RemoveComponentImmediatelyOf(TheBoardPart); if (gameObject.layer == 5) { TheBoardPart.layer = 5; } if (StuffPlacer.GetThingBeingPlaced == gameObject) { StuffPlacer.NewThingBeingPlaced(gameObject); } // holy shit this is a terrible line of code. God damn. } else { transform.GetChild(1).tag = "PlaceOnlyCircuitBoard"; // this tag is applied to prevent actions like board moving and painting } Destroy(this); }
public void Done() { Canvas.enabled = false; GameplayUIManager.UIState = UIState.None; StuffPlacer.DeleteThingBeingPlaced(); // quick shitty fix for FrequencyForNewNoisemakers not working properly FrequencyForNewNoisemakers = NoisemakerBeingEdited.ToneFrequency; // only update this variable during this method, so players can check notes without screwing it up }
protected override IEnumerable <GameObject> CreateGhosts() { foreach (var item in GetWires()) { StuffPlacer.OutlineObject(item.gameObject, OutlineColor.red); } yield break; }
private void RemoveOutlineFromLookedAtBoard() { if (highlightedboard == null) { return; } StuffPlacer.RemoveOutlineFromObject(highlightedboard, true); highlightedboard = null; }
public void DoneMenu() { MenuCanvas.enabled = false; GameplayUIManager.UIState = UIState.None; // this is so that if you change the display color and you're in the middle of placing a display, it gets set to the new color if (StuffPlacer.GetThingBeingPlaced == null) { return; } if (StuffPlacer.GetThingBeingPlaced.GetComponentInChildren<Display>()) { StuffPlacer.DeleteThingBeingPlaced(); } }
protected GameObject CreateWire(Transform a, Transform b, bool ghost = true) { if (WirePlacer.ConnectionExists(a.parent.gameObject, b.parent.gameObject)) { return(null); } GameObject obj = GameObject.Instantiate(Prefabs.Wire); Wire w; if (a.parent.tag == "Input" && b.parent.tag == "Input") { w = obj.AddComponent <InputInputConnection>(); w.Point1 = a; w.Point2 = b; } else { w = obj.AddComponent <InputOutputConnection>(); if (a.parent.tag == "Input") { w.Point1 = a; w.Point2 = b; } else { w.Point1 = b; w.Point2 = a; } } if (!WirePlacer.CanConnect(w)) { GameObject.Destroy(obj); return(null); } w.DrawWire(); if (ghost) { obj.GetComponent <BoxCollider>().enabled = false; StuffPlacer.OutlineObject(obj, OutlineColor.blue); } else { w.SetPegsBasedOnPoints(); StuffConnector.LinkConnection(w); StuffConnector.SetAppropriateConnectionParent(w); obj.AddComponent <ObjectInfo>().ComponentType = ComponentType.Wire; obj.GetComponent <BoxCollider>().enabled = true; } return(obj); }
public static bool AllowedToDoRotation = true; // for when you're placing wires public static void RunGameplayRotation() { if (!AllowedToDoRotation) { return; } if (StuffPlacer.OkayToPlace) { return; } if (Input.GetButtonDown("Rotate")) { RaycastHit hit; if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, FirstPersonInteraction.IgnorePlayerLayermask)) { RotateThing(hit.collider.gameObject); } else { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); } } // kind of awkward that both this class and StuffPlacer are f*****g with RotationLocked. TODO do it better if (Input.GetButtonDown("RotationLock")) { RaycastHit hit; if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask)) { if (StuffPlacer.GetThingBeingPlaced == null || !StuffPlacer.OkayToPlace) // so that if there's something we're placing we can lock rotation to that and not what's under it { if (hit.collider.tag == "World" || hit.collider.tag == "CircuitBoard") { SetRotationLockToFalseIfThingBeingPlacedIsNull(); return; } StuffPlacer.SetRotationLockAngles(ComponentPlacer.FullComponent(hit.collider)); StuffPlacer.RotationLocked = true; } } else { StuffPlacer.RotationLocked = false; } SelectionMenu.Instance.SetRotationLockText(); } if (Input.GetButtonDown("RotateThroughBoard")) { RotateThroughBoard(); } }
private static void RotateThroughBoard() { RaycastHit hit; if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask)) { if (hit.collider.tag == "World" || hit.collider.tag == "CircuitBoard") { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } GameObject component = ComponentPlacer.FullComponent(hit.collider); if (component.transform.parent == null) { return; } if (!AllowFlippingOneSidedComponents) { if (!component.GetComponent <IsThroughComponent>()) { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } } component.transform.localEulerAngles += new Vector3(0, 0, 180); component.transform.Translate(Vector3.up * 0.15f, Space.Self); BoxCollider[] colliders = component.GetComponentsInChildren <BoxCollider>(); StuffPlacer.SetStateOfBoxColliders(colliders, false); if (StuffPlacer.GameObjectIntersectingStuffOrWouldDestroyWires(component, true)) { component.transform.localEulerAngles += new Vector3(0, 0, 180); component.transform.Translate(Vector3.up * 0.15f, Space.Self); StuffPlacer.SetStateOfBoxColliders(colliders, true); SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return; } FloatingPointRounder.RoundIn(component); StuffPlacer.SetStateOfBoxColliders(colliders, true); RedrawCircuitGeometryOf(component); DestroyIntersectingConnections(component); MegaMeshManager.RecalculateGroupsOf(component); SoundPlayer.PlaySoundAt(Sounds.RotateSomething, component); } else { SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); } }
public static void DoneConnecting() { StuffPlacer.RemoveOutlineFromObjects(ObjectsInvolvedWithPlacing, true); // DestroyImmediate is true because more outline code is run on the same frame and it needs to know that there is no outline on some things if (WireBeingPlaced != null) { Object.Destroy(WireBeingPlaced); } SelectedPeg = null; PegBeingLookedAt = null; StuffRotater.AllowedToDoRotation = true; StuffDeleter.AllowedToDoDeleting = true; }
private static void PlaceAndMoveAllInOneGo() { MakeSureThingBeingPlacedIsCorrect(); if (StuffPlacer.GetThingBeingPlaced != null) { StuffPlacer.GetThingBeingPlaced.AddComponent <ObjectInfo>().ComponentType = SelectionMenu.SelectedComponentType; } StuffPlacer.RunStuffPlacing(); //StuffPlacer.PlaceThingBeingPlaced(); // already called by RunStuffPlacing StuffPlacer.DeleteThingBeingPlaced(); }
private void UpdateHighlight() { if (StuffPlacer.GameObjectIntersectingStuffOrWouldDestroyWires(StackedBoard)) { CurrentPlacementIsValid = false; StuffPlacer.SetObjectOutlineColor(StackedBoard, OutlineColor.red); } else { CurrentPlacementIsValid = true; StuffPlacer.SetObjectOutlineColor(StackedBoard, OutlineColor.green); } }
// done after StuffPlacer has done its own thing in PlaceThingBeingPlaced private static void PlaceBoard() { if (!StuffPlacer.OkayToPlace) { return; } StuffPlacer.PlaceThingBeingPlaced(); BoardBeingPlaced.transform.parent = ReferenceObject.transform.parent; // StuffPlacer set referenceobject to the correct parent, but that should actually be BoardBeingPlaced's parent BoardBeingPlaced = null; ReferenceObject.transform.parent = null; // this is important because a circuitboard having any children means it can't be deleted, and this can f**k that up GameplayUIManager.UIState = UIState.None; }
protected virtual void ApplyInner() { foreach (var wire in Created) { StuffPlacer.RemoveOutlineFromObject(wire, false); wire.GetComponent <Wire>().SetPegsBasedOnPoints(); StuffConnector.LinkConnection(wire); StuffConnector.SetAppropriateConnectionParent(wire); wire.AddComponent <ObjectInfo>().ComponentType = ComponentType.Wire; wire.GetComponent <BoxCollider>().enabled = true; } SoundPlayer.PlaySoundGlobal(Sounds.ConnectionFinal); }
public GameObject Board(int width, int height, Vector3 position, Quaternion rotation, Transform parent = null) { GameObject board = UnityEngine.Object.Instantiate(boardPlacer.BoardPrefab, position, rotation, parent); CircuitBoard circuit = board.GetComponent <CircuitBoard>(); circuit.x = width; circuit.z = height; circuit.CreateCuboid(); StuffPlacer.DestroyIntersectingConnections(board); DestroyInvalidWiresOnBoard(board); MegaMesh.AddMeshesFrom(board); MegaBoardMeshManager.AddBoardsFrom(board); SetChildCircuitsMegaMeshStatus(board, true); return(board); }
public void Done() { StuffPlacer.RemoveOutlineFromObject(BoardBeingStacked); StuffPlacer.SetStateOfAllBoxCollidersIn(BoardBeingStacked, true); if (StackedBoard != null) { SoundPlayer.PlaySoundAt(Sounds.DeleteSomething, StackedBoard); Destroy(StackedBoard); } BoardBeingStacked = null; Destroy(BoardBeingStackedCopy); AllSubBoardsInvolvedWithStacking = new List <GameObject>(); Canvas.enabled = false; GameplayUIManager.UIState = UIState.None; }
public void Done() { Canvas.enabled = false; TextInput.DeactivateInputField(); UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject(null); TextBeingEdited = null; GameplayUIManager.UIState = UIState.None; // this is so that if you change the size of the label text and you're in the middle of placing a label, it gets set to the new size if (StuffPlacer.GetThingBeingPlaced == null) { return; } if (StuffPlacer.GetThingBeingPlaced.GetComponent <Label>()) { StuffPlacer.DeleteThingBeingPlaced(); } }
public void Initialize() { RaycastHit hit; if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask)) { if (hit.collider.tag == "CircuitBoard") { GameObject StackThis = hit.collider.gameObject; if (Input.GetButton("Mod")) { GameObject RootBoard = hit.collider.transform.root.gameObject; if (RootBoard.tag == "CircuitBoard") { StackThis = RootBoard; } // make sure to check for circuitboard in case of mounts } BoardBeingStacked = StackThis; BoardBeingStackedCircuitBoard = StackThis.GetComponent <CircuitBoard>(); AllSubBoardsInvolvedWithStacking.Add(BoardBeingStacked); BoardBeingStacked.AddComponent <cakeslice.Outline>(); // added before we get the copy so clones will have it too BoardBeingStackedCopy = Instantiate(BoardBeingStacked, new Vector3(-1000, -1000, -1000), BoardBeingStacked.transform.rotation); GameplayUIManager.UIState = UIState.StackBoardMenu; Canvas.enabled = true; IterationsInput.ActivateInputField(); StuffPlacer.SetObjectOutlineColor(BoardBeingStacked, OutlineColor.blue); // so that you don't accidentally crash your PC when you first stacked on a simple board then you go to stack on a complex board. Don't set iterations directly for // the reason outlined below TrueIterations = 1; // Using Invoke because for some reason this MUST be done a frame later. If it is not, outputs have duplicated geometry Invoke("ShittyHackThatShouldntExist", 0.01f); return; } } SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); GameplayUIManager.UIState = UIState.None; }
public static bool ShowPlacingGhost = true; // = Settings.Get("ShowPlacingGhost", true); public static void RunComponentPlacing() { if (Input.GetButtonDown("TogglePlacingGhost") && !Input.GetButton("Mod")) // holding mod is for toggling initial placing outline { ShowPlacingGhost = !ShowPlacingGhost; // Settings.Save("ShowPlacingGhost", ShowPlacingGhost); if (!ShowPlacingGhost) { StuffPlacer.DeleteThingBeingPlaced(); StuffPlacer.RotationAboutUpVector = 0; } } if (Input.GetButtonDown("Place") && StuffPlacer.OkayToPlace) // run BEFORE RunStuffPlacing so we can actually get ThingBeingPlaced { StuffPlacer.GetThingBeingPlaced.AddComponent <ObjectInfo>().ComponentType = SelectionMenu.SelectedComponentType; } if (ShowPlacingGhost) { MakeSureThingBeingPlacedIsCorrect(); StuffPlacer.RunStuffPlacing(true, true); // the booleans are AllowFineRotation and HideWhenInvalidPlacement } else { if (Input.GetButtonDown("Place")) { PlaceAndMoveAllInOneGo(); } } // I have absolutely no idea why this is necessary. Sometimes when you rotate a mount it f***s up component placing by enabling the colliders. This fixes that. if (StuffPlacer.MostRecentNonNullHit.collider == null) { return; } if (FullComponent(StuffPlacer.MostRecentNonNullHit.collider) == StuffPlacer.GetThingBeingPlaced) { Debug.Log("did a terrible shitty hack"); StuffPlacer.DeleteThingBeingPlaced(); } }
private static void MakeSureThingBeingPlacedIsCorrect() { if (SelectionMenu.Instance.CustomComponentSelected) { DoFancyModdedComponentThings(); return; } // replace ThingBeingPlaced when it should be replaced - when you switch selected things or when something was just placed if (SelectionMenu.Instance.SelectedThing != 0 && (SelectionMenu.Instance.SelectedThingJustChanged || StuffPlacer.GetThingBeingPlaced == null)) { StuffPlacer.NewThingBeingPlaced(Object.Instantiate(SelectionMenu.SelectedComponent)); DoThingsForNewComponents(StuffPlacer.GetThingBeingPlaced); } else if (SelectionMenu.Instance.SelectedThing == 0) { StuffPlacer.DeleteThingBeingPlaced(); } // switching to nothing selected deletes the thing being placed }
private static bool ShowPreWiringPegOutlines = true; //= Settings.Get("ShowPreWiringPegOutlines", true); // if we're looking at a peg, set PegBeingLookedAt to that. Otherwise, set it to null. private static void SetPegBeingLookedAt() { RaycastHit hit; if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, Wire.IgnoreWiresLayermask)) { if (hit.collider.gameObject == PegBeingLookedAt || hit.collider.gameObject == SelectedPeg) { return; } if (hit.collider.tag == "Input" || hit.collider.tag == "Output") { StuffPlacer.RemoveOutlineFromObject(PegBeingLookedAt); // in case you look directly from one peg to another peg PegBeingLookedAt = hit.collider.gameObject; if (SelectedPeg == null && !ShowPreWiringPegOutlines) { return; } StuffPlacer.OutlineObject(PegBeingLookedAt); // play the sound only if we're in the middle of making a connection if (SelectedPeg != null) { SoundPlayer.PlaySoundAt(Sounds.ConnectionInitial, PegBeingLookedAt); } } else { StuffPlacer.RemoveOutlineFromObject(PegBeingLookedAt); PegBeingLookedAt = null; } } else { StuffPlacer.RemoveOutlineFromObject(PegBeingLookedAt); PegBeingLookedAt = null; } }
// handles the first person placing of boards. Run every frame while there is a board to be placed public static void RunBoardPlacing() { if (BoardBeingPlaced == null) { return; } if (Input.GetButtonDown("Delete") || Input.GetButtonDown("Cancel")) { CancelPlacement(); } PollForInput(); SetRotationState(); ApplyPlacingOffset(); if (Input.GetButtonDown("Place")) { PlaceBoard(); return; } StuffPlacer.RunStuffPlacing(false, false, true); // those bools are AllowFineRotation, HideWhenInvalidPlacement, and AllowEdgePlacement, respectively }