예제 #1
0
    // 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();
    }
예제 #2
0
파일: Editor.cs 프로젝트: pipe01/WireEdit
        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);
        }
예제 #3
0
        public static void ConnectionFinal()
        {
            if (WirePlacer.CurrentWirePlacementIsValid())
            {
                var wireBeingPlaced = ModUtilities.GetStaticFieldValue <GameObject>(typeof(WirePlacer), "WireBeingPlaced");
                var wire            = wireBeingPlaced.GetComponent <Wire>();

                Network.SendPacket(PlaceWirePacket.BuildFromLocalWire(wire));
            }
        }
예제 #4
0
        public static bool ConnectionFinal()
        {
            if (WireEdit.State.CurrentState == States.Selecting)
            {
                Selection.Instance.SaveAnotherSelection(!Input.GetKey(KeyCode.LeftControl));
                WirePlacer.DoneConnecting();
                return(false);
            }

            return(true);
        }
예제 #5
0
파일: Mover.cs 프로젝트: pipe01/WireEdit
        public static void EndMove(GameObject newObj)
        {
            var inputs  = newObj.GetComponentsInChildren <CircuitInput>();
            var outputs = newObj.GetComponentsInChildren <CircuitOutput>();

            foreach (var item in Connections)
            {
                GameObject obj = GameObject.Instantiate(Prefabs.Wire);

                var wire = item.InputInput ? (Wire)obj.AddComponent <InputInputConnection>() : obj.AddComponent <InputOutputConnection>();

                var a = (item.OutputIsMoved ? outputs[item.Index].transform : inputs[item.Index].transform).Find("WireReference");
                var b = item.Point;

                if (a.parent.tag == "Input")
                {
                    wire.Point1 = a;
                    wire.Point2 = b;
                }
                else
                {
                    wire.Point1 = b;
                    wire.Point2 = a;
                }

                if (!WirePlacer.CanConnect(wire))
                {
                    GameObject.Destroy(obj);
                    continue;
                }

                wire.DrawWire();
                wire.SetPegsBasedOnPoints();
                StuffConnector.LinkConnection(wire);
                StuffConnector.SetAppropriateConnectionParent(wire);
                obj.AddComponent <ObjectInfo>().ComponentType = ComponentType.Wire;
                obj.GetComponent <BoxCollider>().enabled      = true;
            }

            IsMoving = false;
        }
    public SnappingPeg GetPegToSnapTo()
    {
        Vector3    origin = Wire.GetWireReference(gameObject).position;
        RaycastHit hit;

        if (Physics.Raycast(origin, -Wire.GetWireReference(gameObject).forward, out hit, 0.20f, Wire.IgnoreWiresLayermask)) // snapped connections will be about 18cm long; we cast for 20, just to be safe
        {
            if (hit.collider.tag == "Input")
            {
                SnappingPeg OtherSnappyPeg = hit.collider.GetComponent <SnappingPeg>();
                if (OtherSnappyPeg != null)
                {
                    if (StuffConnector.CanConnect(gameObject, OtherSnappyPeg.gameObject) && !WirePlacer.ConnectionExists(gameObject, OtherSnappyPeg.gameObject) &&
                        hit.transform.InverseTransformPoint(hit.point).z < -0.49f // make sure it hits the right face of the other peg
                        &&

                        // make sure it's rotated approximately correctly
                        // use the wire reference instead of the peg itself so the same code works for vertical and horizontal pegs
                        ((Wire.GetWireReference(hit).eulerAngles.y + 180 > Wire.GetWireReference(transform).eulerAngles.y - 2 &&
                          Wire.GetWireReference(hit).eulerAngles.y + 180 < Wire.GetWireReference(transform).eulerAngles.y + 2)

                         || (Wire.GetWireReference(hit).eulerAngles.y - 180 > Wire.GetWireReference(transform).eulerAngles.y - 2 &&
                             Wire.GetWireReference(hit).eulerAngles.y - 180 < Wire.GetWireReference(transform).eulerAngles.y + 2)))
                    {
                        return(OtherSnappyPeg);
                    }
                }
            }
        }

        return(null);
    }
예제 #7
0
 public static void Done()
 {
     StuffPlacer.DeleteThingBeingPlaced();
     WirePlacer.DoneConnecting();
     SelectionMenu.Instance.FuckOff();
 }