예제 #1
0
 public override void DeletePreview()
 {
     foreach (var item in GetWires())
     {
         StuffPlacer.RemoveOutlineFromObject(item.gameObject);
     }
 }
예제 #2
0
    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();
    }
    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();
    }
 private void RemoveOutlineFromLookedAtBoard()
 {
     if (highlightedboard == null)
     {
         return;
     }
     StuffPlacer.RemoveOutlineFromObject(highlightedboard, true);
     highlightedboard = null;
 }
예제 #5
0
파일: Editor.cs 프로젝트: pipe01/WireEdit
        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);
        }
예제 #6
0
    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;
    }
    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;
        }
    }
    public static void RunWirePlacing()
    {
        if (Input.GetButtonDown("ToggleConnectionMode"))
        {
            // this is a really gross hacky way of doing it but whatever yolo am i right
            if (ConnectionMode == ConnectionMode.HoldDown)
            {
                ConnectionMode = ConnectionMode.MultiPhase;
            }
            else if (ConnectionMode == ConnectionMode.MultiPhase)
            {
                ConnectionMode = ConnectionMode.Chained;
            }
            else
            {
                ConnectionMode = ConnectionMode.HoldDown;
            }
        }

        // do the proper placing methods depending on the user's settings
        if (ConnectionMode == ConnectionMode.HoldDown)
        {
            HoldDownPlacing();
        }
        else if (ConnectionMode == ConnectionMode.MultiPhase)
        {
            MultiphasePlacing();
        }
        else if (ConnectionMode == ConnectionMode.Chained)
        {
            ChainedPlacing();
        }

        if (Input.GetButtonDown("TogglePlacingGhost") && Input.GetButton("Mod"))
        {
            ShowPreWiringPegOutlines = !ShowPreWiringPegOutlines;
            // Settings.Save("ShowPreWiringPegOutlines", ShowPreWiringPegOutlines);
            if (ShowPreWiringPegOutlines)
            {
                StuffPlacer.OutlineObject(PegBeingLookedAt);
            }
            else
            {
                StuffPlacer.RemoveOutlineFromObject(PegBeingLookedAt);
            }
        }

        PollRotationInput();
        SetPegBeingLookedAt();

        // don't do all the outlining stuff if nothing's changed. A small optimization. (also it makes some code more convenient)
        if (PreviousPegBeingLookedAt == PegBeingLookedAt && PreviousSelectedPeg == SelectedPeg)
        {
            return;
        }
        else
        {
            PreviousPegBeingLookedAt = PegBeingLookedAt; PreviousSelectedPeg = SelectedPeg;
        }                                                                                        // keep these values updated

        // if the above things changed, odds are we need a new WireBeingPlaced
        if (WireBeingPlaced != null)
        {
            Object.Destroy(WireBeingPlaced);
        }

        if ((SelectedPeg == null || PegBeingLookedAt == null) || // if we have less than two pegs
            (SelectedPeg.tag == "Output" && PegBeingLookedAt.tag == "Output"))    // or if our pegs are both outputs
        {
            OutlineColor color;
            if (SelectedPeg == null && PegBeingLookedAt != null)
            {
                color = OutlineColor.blue;
            }                                                                                   // if we're not in the process of placing and just looking at a peg, make it blue
            else
            {
                color = OutlineColor.red;
            }                                  // otherwise - since the other possibilities of the above if statement are all invalid placements - make it red
            SetOutlineColorOfObjectsInvolvedWithPlacing(color);
            return;
        }

        PlaceNewWire();

        if (CurrentWirePlacementIsValid())
        {
            SetOutlineColorOfObjectsInvolvedWithPlacing(OutlineColor.green);
        }
        else
        {
            SetOutlineColorOfObjectsInvolvedWithPlacing(OutlineColor.red);
        }
    }