public void RemoveWire(GUI_HackingWire wireUI) { //Temporary. We should eventually sync this up with a a unified server/client check for whether someone can remove a wire from the hacking process. Pickupable handItem = PlayerManager.LocalPlayerScript.Equipment.ItemStorage.GetActiveHandSlot().Item; if (handItem == null || !Validations.HasItemTrait(handItem.gameObject, CommonTraits.Instance.Wirecutter)) { return; } if (wireUI.StartNode == null || wireUI.EndNode == null) { return; } HackingNode outputNode = wireUI.StartNode.HackNode; HackingNode inputNode = wireUI.EndNode.HackNode; outputNode.RemoveConnectedNode(inputNode); SoundManager.PlayNetworkedAtPos(Wirecut, PlayerManager.LocalPlayerScript.WorldPos); //If we're on client, network to the server the changes we made. if (!IsServer) { int outIndex = hackNodes.IndexOf(outputNode); int inIndex = hackNodes.IndexOf(inputNode); int[] connectionToRemove = { outIndex, inIndex }; RemoveHackingConnection.Send(PlayerManager.LocalPlayerScript.gameObject, hackProcess.gameObject, connectionToRemove); } hackingWires.Remove(wireUI); Destroy(wireUI.gameObject); }
/// <summary> /// Remove a connection between two nodes. keyOutput is the index of the output node, similar for key input. /// </summary> /// <param name="keyOutput"></param> /// <param name="keyInput"></param> public virtual void RemoveNodeConnection(int keyOutput, int keyInput) { HackingNode outputNode = GetHackNodes()[keyOutput]; HackingNode inputNode = GetHackNodes()[keyInput]; if (outputNode != null && inputNode != null && outputNode.IsOutput && inputNode.IsInput) { outputNode.RemoveConnectedNode(inputNode); } }
public virtual void RemoveNodeConnection(int[] connection) { if (connection.Length != 2) { return; } HackingNode outputNode = GetHackNodes()[connection[0]]; HackingNode inputNode = GetHackNodes()[connection[1]]; if (outputNode != null && inputNode != null && outputNode.IsOutput && inputNode.IsInput) { outputNode.RemoveConnectedNode(inputNode); } }