Ejemplo n.º 1
0
        private void ShowTools(UniTool[] Tools)
        {
            ToolSelector = ComponentPlacer.PlaceComboBox(gbOptions, Tools, null, 15, 25, 220, 22);

            var Pref = PrState.Env.GetPreference(PrState.Project.GetID(PrState.Script));

            PrState.Tool = null;
            if (Pref != null)
            {
                for (int i = 0; i < ToolSelector.Items.Count; i++)
                {
                    if ((ToolSelector.Items[i] as UniTool).Name.CompareTo(Pref) == 0)
                    {
                        ToolSelector.SelectedIndex = i;
                        PrState.Tool = ToolSelector.SelectedItem as UniTool;
                        break;
                    }
                }
            }

            if ((PrState.Tool == null) && (Tools.Length > 0))
            {
                ToolSelector.SelectedIndex = 0;
                PrState.Tool = ToolSelector.SelectedItem as UniTool;
            }

            ToolSelector.SelectedIndexChanged += ToolSelector_SelectedIndexChanged;
        }
Ejemplo n.º 2
0
        private void bOpen_Click(object sender, EventArgs e)
        {
            if (ProjReadme != null)
            {
                ComponentPlacer.Remove(gbOptions, new Control[] { ProjReadme });
                ProjReadme = null;
            }
            PrState.SelectProject(cbProject.SelectedItem as Project);
            Text = $"NyaProg - {PrState.Project.Name}. {PrState.Project.Description}";
            // Если скрипт один, то откроем его.
            UpdateScripts();
            if (PrState.Project.Scripts.Count == 1)
            {
                SelectScript(PrState.Project.Scripts[0]);
            }
            else
            {
                SelectScript(null);
            }

            if (PrState.Project.Readme != null)
            {
                ProjReadme = ComponentPlacer.PlaceReadme(gbScripts, PrState.Project.Readme, 9, gbScripts.Width - 18, 9, 220);
            }
        }
Ejemplo n.º 3
0
        public static bool TryGetKeyFromOutput(CircuitOutput output, out StateKey key, bool clearCache = false)
        {
            if (clearCache || !KeysCache.TryGetValue(output, out key))
            {
                var component = ComponentPlacer.FullComponent(output.transform);

                var netObj = component.GetComponent <NetObject>();

                if (netObj == null)
                {
                    key = default(StateKey);
                    return(false);
                }

                byte ioIndex = 0;

                foreach (var item in component.GetComponentsInChildren <CircuitOutput>())
                {
                    if (item == output)
                    {
                        break;
                    }

                    ioIndex++;
                }

                key = KeysCache[output] = new KeyValuePair <int, byte>(netObj.NetID, ioIndex);
            }

            return(true);
        }
Ejemplo n.º 4
0
 private void UpdateScripts()
 {
     ComponentPlacer.CleanContainer(gbScripts);
     ComponentPlacer.PlaceScripts(gbScripts,
                                  PrState.Project.Scripts.ToArray(),
                                  new ButtonMapper(9, 25),
                                  S => SelectScript(S));
 }
Ejemplo n.º 5
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();
    }
Ejemplo n.º 6
0
        public static void BeginMove(GameObject obj)
        {
            IsMoving = true;

            var inputs  = obj.GetComponentsInChildren <CircuitInput>();
            var outputs = obj.GetComponentsInChildren <CircuitOutput>();

            Connections.Clear();

            foreach (var input in inputs)
            {
                foreach (var wire in input.IIConnections.Cast <Wire>().Concat(input.IOConnections.Cast <Wire>()))
                {
                    var point         = ComponentPlacer.FullComponent(wire.Point1) == obj ? wire.Point2 : wire.Point1;
                    var theOtherPoint = point == wire.Point1 ? wire.Point2 : wire.Point1;

                    if (CheckPointParent(wire.Point1) != CheckPointParent(wire.Point2))
                    {
                        Connections.Add(new Connection(Array.IndexOf(inputs, input), theOtherPoint, wire is InputInputConnection, false));
                    }
                }
            }

            foreach (var output in outputs)
            {
                foreach (var wire in output.GetIOConnections())
                {
                    var point = ComponentPlacer.FullComponent(wire.Point1) == obj ? wire.Point2 : wire.Point1;

                    if (CheckPointParent(wire.Point1) != CheckPointParent(wire.Point2))
                    {
                        Connections.Add(new Connection(Array.IndexOf(outputs, output), point, false, true));
                    }
                }
            }

            bool CheckPointParent(Transform point)
            {
                Transform p = point;

                while (p != null)
                {
                    if (p == obj.transform)
                    {
                        return(false);
                    }

                    p = p.parent;
                }

                return(true);
            }
        }
    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);
        }
    }
Ejemplo n.º 9
0
 void AttachTowerComponentToPointer(ResourceController resourceController, ResourceCost resourceCost)
 {
     if (resourceController.CanAfford(resourceCost))
     {
         ComponentPlacer placer = cam.GetComponent <ComponentPlacer> ();
         placer.towerComponent    = towerComponent;
         placer.componentSelected = true;
         placer.AttachToPointer();
     }
     else
     {
         Debug.Log("Insufficient Resources");
     }
 }
Ejemplo n.º 10
0
        private void RebuildSteps()
        {
            ComponentPlacer.CleanContainer(gbSteps);

            var S = PrState.Script;

            if (S != null)
            {
                var Actions = S.GetActions(PrState);

                StepsControls = ComponentPlacer.PlaceSteps(gbSteps,
                                                           Actions.ToArray(),
                                                           new StepMapper(9, 25));
            }
        }
Ejemplo n.º 11
0
        private void SelectScript(Script S)
        {
            if (OptionsControls != null)
            {
                ComponentPlacer.Remove(gbOptions, OptionsControls);
            }
            if (ScriptReadme != null)
            {
                ComponentPlacer.Remove(gbOptions, new Control[] { ScriptReadme });
                ScriptReadme = null;
            }
            if (ToolSelector != null)
            {
                ToolSelector.SelectedIndexChanged -= ToolSelector_SelectedIndexChanged;
                ComponentPlacer.Remove(gbOptions, new Control[] { ToolSelector });
            }
            PrState.SelectScript(S);
            lResult.Text = "";

            if (S != null)
            {
                var Tools = PrState.Env.GetToolsByArch(PrState.Arch);
                ShowTools(Tools);
                ShowOptions();
                ApplyOptions();
                RebuildSteps();

                if (S.Readme != null)
                {
                    ScriptReadme = ComponentPlacer.PlaceReadme(gbOptions, S.Readme, 9, gbOptions.Width - 18, 58, 180);
                }
                else if (PrState.Project.Readme != null)
                {
                    ScriptReadme = ComponentPlacer.PlaceReadme(gbOptions, PrState.Project.Readme, 9, gbOptions.Width - 18, 58, 180);
                }

                gbOptions.Text    = S.Name;
                tTabs.SelectedTab = tOptions;
            }
            else
            {
                RebuildSteps();
                OptionsControls   = null;
                ToolSelector      = null;
                StepsControls     = null;
                tTabs.SelectedTab = tScripts;
            }
        }
Ejemplo n.º 12
0
        private void RunComponentMoving()
        {
            if (Input.GetMouseButtonDown(1) &&
                Input.GetKey(KeyCode.LeftControl) &&
                State.CurrentState == States.None &&
                Physics.Raycast(FirstPersonInteraction.Ray(), out var hit, Settings.ReachDistance) &&
                hit.collider.tag != "CircuitBoard" &&
                hit.collider.tag != "Wire")
            {
                var comp = ComponentPlacer.FullComponent(hit.collider);

                if (comp.GetComponent <ObjectInfo>() != null)
                {
                    Mover.BeginMove(comp);
                }
            }
        }
Ejemplo n.º 13
0
        private void ShowOptions()
        {
            var OptsTool   = new List <Option>();
            var OptsProj   = new List <Option>();
            var OptViewers = new List <OptionViewer>();

            if (PrState.Tool != null)
            {
                OptsTool.AddRange(PrState.Tool.GetOptions());
            }
            if (PrState.Project != null)
            {
                OptsProj.AddRange(PrState.Project.Options);
            }
            if (PrState.Script != null)
            {
                OptsProj.AddRange(PrState.Script.Options);

                var Input = PrState.Script.Input;
                var IL    = PrState.Env.InputTypes;
                foreach (var I in Input)
                {
                    OptsProj.Add(new OptionInput(I.Name, I.Name, IL.GetInputType(I.Type), I.Default, I.ID));
                }
            }

            if (OptionsControls != null)
            {
                ComponentPlacer.Remove(gbOptions, OptionsControls);
            }

            OptViewers.AddRange(ComponentPlacer.PlaceOptions(gbOptions, OptsTool.ToArray(), new OptionMapper(15, 25 + 22 + 8, 220), OnOptionChange));
            OptViewers.AddRange(ComponentPlacer.PlaceOptions(gbOptions, OptsProj.ToArray(), new OptionMapper(gbOptions.Width - 208, 25, 200), OnOptionChange));

            foreach (var O in OptViewers)
            {
                if (O.ID != null)
                {
                    O.SetDefault(PrState.Env.GetPreference(O.ID));
                }
            }

            OptionsControls = OptViewers.ToArray();
        }
Ejemplo n.º 14
0
        public static bool set_On(CircuitOutput __instance, bool value)
        {
            if (Network.IsClient && ComponentActions.CurrentlyUpdating != __instance)
            {
                return(false);
            }

            if (Network.IsServer)
            {
                var component = ComponentPlacer.FullComponent(__instance.transform);
                var netObj    = component.GetComponent <NetObject>();

                if (netObj == null)
                {
                    component.AddComponent <NetObject>();
                }

                CircuitStatePacket.SetOutputState(__instance, value);
            }

            return(true);
        }
    public static bool CurrentWirePlacementIsValid()
    {
        // below: some invalid placement conditions. We must do CanConnect as well as CanFindPoints because each can sometimes return true while the other returns false; sorry, future me, but I'm too lazy to type out exactly what those scenarios are. Figure it out yourself you ungrateful piece of shit
        if (ConnectionExists(SelectedPeg, PegBeingLookedAt) || !WireBeingPlaced.GetComponent <Wire>().CanFindPoints())
        {
            return(false);
        }

        InputInputConnection IIconnection = WireBeingPlaced.GetComponent <InputInputConnection>();

        if (IIconnection != null)
        {
            // for the edge case of color displays
            if (ComponentPlacer.FullComponent(IIconnection.Point1) == ComponentPlacer.FullComponent(IIconnection.Point2))
            {
                return(false);
            }
        }

        // a snapping peg may only have one non-snapped connection
        SnappingPeg TheSnappyPeg = SelectedPeg.GetComponent <SnappingPeg>();

        if (TheSnappyPeg == null)
        {
            TheSnappyPeg = PegBeingLookedAt.GetComponent <SnappingPeg>();
        }
        if (TheSnappyPeg != null)
        {
            int MaxConnections = TheSnappyPeg.SnappedConnection == null ? 1 : 2;
            if (TheSnappyPeg.IIConnections.Count + TheSnappyPeg.IOConnections.Count >= MaxConnections)
            {
                return(false);
            }
        }

        return(true);
    }
Ejemplo n.º 16
0
    // TODO move to a better class
    public void PickComponent()
    {
        RaycastHit hit;

        if (Physics.Raycast(FirstPersonInteraction.Ray(), out hit, Settings.ReachDistance, 1 << 0))
        {
            GameObject ThingWeHit = ComponentPlacer.FullComponent(hit.collider);

            ObjectInfo buttcrack = ThingWeHit.GetComponent <ObjectInfo>();
            if (buttcrack != null)
            {
                for (int i = 0; i < PlaceableObjectTypes.Count; i++)
                {
                    if (PlaceableObjectTypes[i] == buttcrack.ComponentType)
                    {
                        SelectedThing = i + 1;
                        UpdateSelectedThing();
                        MenuClosesIn = SelectionMenuOpenTime;
                        return;
                    }
                }
            }
        }
    }
Ejemplo n.º 17
0
    public static void DeleteThing(GameObject DestroyThis)
    {
        if (DestroyThis == null)
        {
            return;
        }

        // don't let players destroy the world lol
        if (DestroyThis.tag == "World")
        {
            SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
            return;
        }

        // destroy the full object, not part of it
        DestroyThis = ComponentPlacer.FullComponent(DestroyThis);

        // special cases of stuff to hit
        ObjectInfo info = DestroyThis.GetComponent <ObjectInfo>();

        if (info != null && info.ComponentType == ComponentType.Mount)
        {
            // code copied from below - don't let players destroy a mount if it has children
            Transform TheBoardBit = DestroyThis.transform.GetChild(1); // the 0th child is the blocky bit
            if (TheBoardBit.childCount > 0)
            {
                if (TheBoardBit.childCount == 1)
                {
                    if (!TheBoardBit.GetChild(0).gameObject == StuffPlacer.GetThingBeingPlaced)
                    {
                        SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return;
                    }                                                                                                                                            // just a check so that you can destroy a board when looking at it with a component ghost
                }
                else
                {
                    SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
                    return;
                }
            }
        }

        if (DestroyThis.tag == "CircuitBoard") // only let players destroy a circuit board if it is empty, to prevent losing lots and lots of work
        {
            if (DestroyThis.transform.childCount > 0)
            {
                if (DestroyThis.transform.childCount == 1)
                {
                    if (!DestroyThis.transform.GetChild(0).gameObject == StuffPlacer.GetThingBeingPlaced)
                    {
                        SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething); return;
                    }                                                                                                                                                      // just a check so that you can destroy a board when looking at it with a component ghost
                }
                else
                {
                    SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
                    return;
                }
            }
            // if no occupied slots are found, continue to destroy the board
        }

        // delink all inputs and outputs in the object if it's not a circuitboard
        else
        {
            CircuitInput[]  inputs  = DestroyThis.GetComponentsInChildren <CircuitInput>();
            CircuitOutput[] outputs = DestroyThis.GetComponentsInChildren <CircuitOutput>();
            foreach (CircuitInput input in inputs)
            {
                DestroyInput(input);
            }
            foreach (CircuitOutput output in outputs)
            {
                DestroyOutput(output);
            }
        }

        if (DestroyThis.tag == "Wire")                          // if it's a wire, determine which type of connection it is and destroy that connection
        {
            if (DestroyThis.GetComponent <SnappedConnection>()) // you cannot delete snapped connections
            {
                SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
                return;
            }

            DestroyWire(DestroyThis);
            SoundPlayer.PlaySoundAt(Sounds.DeleteSomething, DestroyThis);
        }
        else if (DestroyThis.tag == "CircuitBoard")
        {
            SoundPlayer.PlaySoundAt(Sounds.DeleteSomething, DestroyThis);
        }
        else
        {
            SoundPlayer.PlaySoundAt(Sounds.DeleteSomething, DestroyThis);
        }

        Object.Destroy(DestroyThis);
    }
    public static void RotateThing(GameObject RotateThis)
    {
        // determines which direction to rotate
        // TODO: use camera.main.transform to rotate stuff left and right rather than clockwise & ccw

        if (RotateThis.tag == "World")
        {
            SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
            return;
        }

        if (RotateThis.tag == "CircuitBoard" || RotateThis.tag == "PlaceOnlyCircuitBoard")
        {
            SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
            return;
        }

        // rotate the full object, not part of it
        // the last check is so that rotating child boards doesn't rotate their parent
        RotateThis = ComponentPlacer.FullComponent(RotateThis);

        Quaternion BeforeRotation     = Quaternion.identity;
        Vector3    AxisToRotateAround = RotateThis.transform.up;

        // everything but wires should rotate around transform.up
        if (RotateThis.tag == "Wire")
        {
            if (RotateThis.GetComponent <SnappedConnection>()) // you cannot rotate snapped connections
            {
                SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
                return;
            }

            AxisToRotateAround = RotateThis.transform.forward;
            StuffConnector.QueueWireMeshRecalculation(RotateThis);

            SoundPlayer.PlaySoundAt(Sounds.RotateSomething, RotateThis);
        }
        else
        {
            BeforeRotation = RotateThis.transform.rotation; // non-wires might be rotated into invalid positions, in which case they should be reverted to their original rotations
        }

        int direction = 1;

        if (Input.GetAxis("Rotate") < 0)
        {
            direction = -1;
        }
        else
        {
            direction = 1;
        }

        if (Input.GetButton("Mod")) // rotate by 22.5 degrees if the mod key is held down
        {
            RotateThis.transform.RotateAround(RotateThis.transform.position, AxisToRotateAround, direction * 22.5f);
        }
        else // ...but normally rotate by 90 degrees
        {
            RotateThis.transform.RotateAround(RotateThis.transform.position, AxisToRotateAround, direction * 90f);
        }

        // the validity of wire placement is never affected when rotating them, but if it's an object, check if it can actually be placed there. If not, revert to original rotation
        if (RotateThis.tag != "Wire")
        {
            BoxCollider[] colliders = RotateThis.GetComponentsInChildren <BoxCollider>();
            StuffPlacer.SetStateOfBoxColliders(colliders, false);

            if (StuffPlacer.GameObjectIntersectingStuffOrWouldDestroyWires(RotateThis, true, true)) // ignore wires
            {
                RotateThis.transform.rotation = BeforeRotation;
                StuffPlacer.SetStateOfBoxColliders(colliders, true);

                SoundPlayer.PlaySoundGlobal(Sounds.FailDoSomething);
                return;
            }

            SoundPlayer.PlaySoundAt(Sounds.RotateSomething, RotateThis);
            StuffPlacer.SetStateOfBoxColliders(colliders, true);
        }

        FloatingPointRounder.RoundIn(RotateThis);

        RedrawCircuitGeometryOf(RotateThis);
        DestroyIntersectingConnections(RotateThis);

        SnappingPeg.TryToSnapIn(RotateThis);

        MegaMeshManager.RecalculateGroupsOf(RotateThis);
    }
Ejemplo n.º 19
0
        private void RunWireHighlight()
        {
            if (Input.GetMouseButtonDown(0) && Input.GetKey(KeyCode.LeftControl) && State.CurrentState == States.None)
            {
                foreach (var item in Highlighted)
                {
                    Highlighter.StopHighlight(item);
                }
                Highlighted.Clear();

                if (Physics.Raycast(FirstPersonInteraction.Ray(), out var hit, Settings.ReachDistance) &&
                    hit.collider.tag != "CircuitBoard")
                {
                    var wire = hit.collider.GetComponent <Wire>();

                    if (wire != null) //Clicked on wire, highlight it and both ends
                    {
                        HighlightWire(wire);
                    }
                    else
                    {
                        var input  = hit.collider.GetComponent <CircuitInput>();
                        var output = hit.collider.GetComponent <CircuitOutput>();

                        if (input != null) //Clicked on input peg, highlight it and all wires connected to it
                        {
                            foreach (var item in input.IIConnections.Cast <Wire>().Concat(input.IOConnections.Cast <Wire>()))
                            {
                                HighlightWire(item);
                            }
                        }
                        else if (output != null) //Clicked on output peg, highlight it and all wires connected to it
                        {
                            foreach (var item in output.GetIOConnections())
                            {
                                HighlightWire(item);
                            }
                        }
                        else //Clicked on component, highlight inputs and outputs and all wires connected to it
                        {
                            var component = ComponentPlacer.FullComponent(hit.collider);

                            foreach (var item in Mover.GetWires(component))
                            {
                                HighlightWire(item);
                            }
                        }
                    }
                }
            }

            void HighlightWire(Wire wire)
            {
                Highlight(wire.gameObject, 0);

                HighlightComponent(wire.Point1);
                HighlightComponent(wire.Point2);
            }

            void HighlightComponent(Transform wireReference)
            {
                Highlight(wireReference.parent.gameObject, 3);

                if (wireReference.parent.parent?.tag != "CircuitBoard" && wireReference.parent.parent != null)
                {
                    Highlight(wireReference.parent.parent.gameObject, 2);
                }
            }

            void Highlight(GameObject obj, int clr)
            {
                Highlighted.Add(obj);
                Highlighter.Highlight(obj, clr);
            }
        }
Ejemplo n.º 20
0
 private void fMain_Load(object sender, EventArgs e)
 {
     ComponentPlacer.HideTabs(tTabs);
     InitProgrammer();
     InitDirs();
 }