public override void ServerGenerateNodesFromNodeInfo() { if (serverEndRoundHackingResetSetup == false) { ServerRegisterHackingReset(); } List <HackingNodeInfo> infList = nodeInfo.nodeInfoList.ToList(); Shuffle(infList, Controller.doorType); foreach (HackingNodeInfo inf in infList) { HackingNode newNode = new HackingNode(); newNode.IsInput = inf.IsInput; newNode.IsOutput = inf.IsOutput; newNode.IsDeviceNode = inf.IsDeviceNode; newNode.InternalIdentifier = inf.InternalIdentifier; newNode.HiddenLabel = inf.HiddenLabel; newNode.PublicLabel = inf.PublicLabel; if (inf.IsInput) { inputNodes.Add(newNode); } else { outputNodes.Add(newNode); } } hackNodes = inputNodes.Concat(outputNodes).ToList(); }
public override void ServerGenerateNodesFromNodeInfo() { List <HackingNodeInfo> infList = nodeInfo.nodeInfoList.ToList(); Shuffle(infList); foreach (HackingNodeInfo inf in infList) { HackingNode newNode = new HackingNode(); newNode.IsInput = inf.IsInput; newNode.IsOutput = inf.IsOutput; newNode.IsDeviceNode = inf.IsDeviceNode; newNode.InternalIdentifier = inf.InternalIdentifier; newNode.HiddenLabel = inf.HiddenLabel; newNode.PublicLabel = inf.PublicLabel; if (inf.IsInput) { inputNodes.Add(newNode); } else { outputNodes.Add(newNode); } } hackNodes = inputNodes.Concat(outputNodes).ToList(); }
public void ServerPerformInteraction(HandApply interaction) { this.interaction = interaction; if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Crowbar)) { TryCrowbar(); } else if (!Controller.IsClosed) { TryClose(); // Close the door if it's open } else if (Validations.HasUsedActiveWelder(interaction)) { TryWelder(); // Repair or un/weld door, or deconstruct false wall } // Attempt to open if it's closed //Tell the OnAttemptOpen node to activate. else if (Controller.IsHackable) { HackingNode onAttemptOpen = Controller.HackingProcess.GetNodeWithInternalIdentifier("OnAttemptOpen"); onAttemptOpen.SendOutputToConnectedNodes(interaction.Performer); } else { TryOpen(interaction.Performer); } }
public void OnSpawnServer(SpawnInfo info) { if (!info.SpawnItems) { hasCables = false; stateSync = MountedMonitorState.OpenEmpty; statusText = GameManager.Instance.CentComm.CommandStatusString; } if (doorControllers.Count > 0) { OnTextBroadcastReceived(StatusDisplayChannel.DoorTimer); foreach (var door in doorControllers) { if (door.IsHackable) { HackingNode outsideSignalOpen = door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OutsideSignalOpen); outsideSignalOpen.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OpenDoor)); outsideSignalOpen.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.CancelCloseTimer)); HackingNode outsideSignalClose = door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OutsideSignalClose); outsideSignalClose.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.CloseDoor)); } } } SyncSprite(stateSync, stateSync); centComm = GameManager.Instance.CentComm; centComm.OnStatusDisplayUpdate.AddListener(OnTextBroadcastReceived); }
public void TryCrowbar() { if (Controller == null) { return; } if (Controller.IsHackable) { HackingNode onAttemptClose = Controller.HackingProcess.GetNodeWithInternalIdentifier("OnAttemptClose"); onAttemptClose.SendOutputToConnectedNodes(interaction.Performer); } else { //TODO: force the opening/close if powerless but make sure firelocks are unaffected if (!Controller.IsClosed) { Controller.ServerTryClose(); } else { Controller.ServerTryOpen(interaction.Performer); } } }
public void ServerOpen() { if (this == null || gameObject == null) { return; // probably destroyed by a shuttle crash } if (Time.time < delayStartTime + inputDelay) { return; } delayStartTime = Time.time; ResetWaiting(); IsClosed = false; if (isHackable && hackingLoaded) { HackingNode onDoorOpened = hackingProcess.GetNodeWithInternalIdentifier("OnDoorOpened"); onDoorOpened.SendOutputToConnectedNodes(); } if (!isPerformingAction) { DoorUpdateMessage.SendToAll(gameObject, DoorUpdateType.Open); } }
public void ServerTryClose() { if (Time.time < delayStartTimeTryOpen + inputDelay) { return; } delayStartTimeTryOpen = Time.time; // Sliding door is not passable according to matrix if (!IsClosed && !isPerformingAction && (matrix.CanCloseDoorAt(registerTile.LocalPositionServer, true) || doorType == DoorType.sliding)) { if (isHackable && hackingLoaded) { HackingNode onShouldClose = hackingProcess.GetNodeWithInternalIdentifier("OnShouldClose"); onShouldClose.SendOutputToConnectedNodes(); } // Sliding door is not passable according to matrix if (!IsClosed && !isPerformingAction && (ignorePassableChecks || matrix.CanCloseDoorAt(registerTile.LocalPositionServer, true) || doorType == DoorType.sliding)) { ServerClose(); } else { ServerClose(); } } else { ResetWaiting(); } }
public virtual void AddNodeConnection(int[] connection) { if (connection.Length != 2) { return; } if (hackNodes.ElementAtOrDefault(connection[0]) == null || hackNodes[connection[0]] == null) { return; } HackingNode outputNode = hackNodes[connection[0]]; if (hackNodes.ElementAtOrDefault(connection[1]) == null || hackNodes[connection[1]] == null) { return; } HackingNode inputNode = hackNodes[connection[1]]; bool nodeNotNull = outputNode != null && inputNode != null; bool isOutputAndInput = outputNode.IsOutput && inputNode.IsInput; bool notAlreadyHasNode = !outputNode.ConnectedInputNodes.Contains(inputNode); if (nodeNotNull && isOutputAndInput && notAlreadyHasNode) { outputNode.AddConnectedNode(inputNode); } }
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); }
public void LinkHackNodes() { //door opening HackingNode openDoor = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OpenDoor); openDoor.AddToInputMethods(HackingTryOpen); HackingNode onShouldOpen = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OnShouldOpen); onShouldOpen.AddWireCutCallback(ServerElectrocute); onShouldOpen.AddConnectedNode(openDoor); //door closing HackingNode closeDoor = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.CloseDoor); closeDoor.AddToInputMethods(TryClose); HackingNode onShouldClose = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OnShouldClose); onShouldClose.AddWireCutCallback(ServerElectrocute); onShouldClose.AddConnectedNode(closeDoor); //ID reject HackingNode rejectID = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.RejectId); rejectID.AddToInputMethods(ServerAccessDenied); HackingNode onIDRejected = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OnIdRejected); onIDRejected.AddConnectedNode(rejectID); //pressure warning HackingNode doPressureWarning = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.DoPressureWarning); doPressureWarning.AddToInputMethods(ServerPressureWarn); HackingNode shouldDoPressureWarning = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.ShouldDoPressureWarning); shouldDoPressureWarning.AddConnectedNode(doPressureWarning); //power HackingNode powerIn = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.PowerIn); HackingNode powerOut = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.PowerOut); powerOut.AddConnectedNode(powerIn); powerOut.AddWireCutCallback(ServerElectrocute); //dummy HackingNode dummyIn = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.DummyIn); HackingNode dummyOut = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.DummyOut); dummyOut.AddConnectedNode(dummyIn); //close timer HackingNode cancelCloseTimer = hackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.CancelCloseTimer); cancelCloseTimer.AddToInputMethods(CancelWaiting); }
/// <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 void OnSpawnServer(SpawnInfo info) { inputNode = new HackingNode(); inputNode.AddToInputMethods(onInputReceived.Invoke); inputNode.HiddenLabel = "Input"; inputNode.IsInput = true; inputNode.IsDeviceNode = true; outputNode = new HackingNode(); outputNode.HiddenLabel = "Output"; outputNode.IsOutput = true; outputNode.IsDeviceNode = true; }
public virtual void ServerPlayerRemoveConnection(PlayerScript player, int[] connection) { int outIndex = connection[0]; int inIndex = connection[1]; HackingNode node = hackNodes[outIndex]; if (node != null) { node.WireCutCallback(player.gameObject); } RemoveNodeConnection(connection); }
//Node list is just undefined nodes for the client. Important, because it means that the client does not know what nodes does what. It just needs the same amount of nodes. public virtual void ClientGenerateNodesFromNodeInfo() { foreach (HackingNodeInfo inf in nodeInfo.nodeInfoList) { HackingNode newNode = new HackingNode(); newNode.IsInput = inf.IsInput; newNode.IsOutput = inf.IsOutput; newNode.IsDeviceNode = inf.IsDeviceNode; newNode.PublicLabel = inf.PublicLabel; hackNodes.Add(newNode); } }
public void OnSpawnClient(ClientSpawnInfo info) { if (!CustomNetworkManager.IsServer) { inputNode = new HackingNode(); inputNode.HiddenLabel = "Input"; inputNode.IsInput = true; inputNode.IsDeviceNode = true; outputNode = new HackingNode(); outputNode.HiddenLabel = "Output"; outputNode.IsOutput = true; outputNode.IsDeviceNode = true; } }
/// <summary> /// Invoke this on server when player bumps into door to try to open it. /// </summary> public void Bump(GameObject byPlayer) { if (Controller.IsClosed && Controller.IsAutomatic) { if (Controller.IsHackable) { HackingNode onAttemptOpen = Controller.HackingProcess.GetNodeWithInternalIdentifier("OnAttemptOpen"); onAttemptOpen.SendOutputToConnectedNodes(byPlayer); } else { TryOpen(byPlayer); } } }
private void OnEnable() { inputNode = new HackingNode(); inputNode.HiddenLabel = "Input"; inputNode.IsInput = true; inputNode.IsDeviceNode = true; outputNode = new HackingNode(); outputNode.HiddenLabel = "Output"; outputNode.IsOutput = true; outputNode.IsDeviceNode = true; if (CustomNetworkManager.IsServer) { inputNode.AddToInputMethods(onInputReceived.Invoke); } }
public virtual void ServerGenerateNodesFromNodeInfo() { foreach (HackingNodeInfo inf in nodeInfo.nodeInfoList) { HackingNode newNode = new HackingNode(); newNode.IsInput = inf.IsInput; newNode.IsOutput = inf.IsOutput; newNode.IsDeviceNode = inf.IsDeviceNode; newNode.InternalIdentifier = inf.InternalIdentifier; newNode.HiddenLabel = inf.HiddenLabel; newNode.PublicLabel = inf.PublicLabel; hackNodes.Add(newNode); } }
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); } }
public void OnSpawnServer(SpawnInfo info) { foreach (var door in doorControllers) { if (door == null) { continue; } if (door.IsHackable) { HackingNode outsideSignalOpen = door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OutsideSignalOpen); outsideSignalOpen.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OpenDoor)); HackingNode outsideSignalClose = door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.OutsideSignalClose); outsideSignalClose.AddConnectedNode(door.HackingProcess.GetNodeWithInternalIdentifier(HackingIdentifier.CloseDoor)); } } }
public override void ClientGenerateNodesFromNodeInfo() { List <HackingNodeInfo> infList = nodeInfo.nodeInfoList; foreach (HackingNodeInfo inf in infList) { HackingNode newNode = new HackingNode(); newNode.IsInput = inf.IsInput; newNode.IsOutput = inf.IsOutput; newNode.IsDeviceNode = inf.IsDeviceNode; newNode.PublicLabel = inf.PublicLabel; if (inf.IsInput) { inputNodes.Add(newNode); } else { outputNodes.Add(newNode); } } hackNodes = inputNodes.Concat(outputNodes).ToList(); }
public void ServerPerformInteraction(HandApply interaction) { if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Crowbar)) { if (Controller.IsHackable) { HackingNode onAttemptClose = Controller.HackingProcess.GetNodeWithInternalIdentifier("OnAttemptClose"); onAttemptClose.SendOutputToConnectedNodes(interaction.Performer); } else { TryCrowbar(interaction.Performer); } } else if (!Controller.IsClosed) { TryClose(); // Close the door if it's open } else { if (Validations.HasItemTrait(interaction.HandObject, CommonTraits.Instance.Welder)) // welding the door (only if closed and not helping) { if (Controller.IsWeldable) { var welder = interaction.HandObject.GetComponent <Welder>(); if (welder.IsOn && interaction.Intent != Intent.Help) { void ProgressComplete() { if (Controller != null) { Chat.AddExamineMsgFromServer(interaction.Performer, "You " + (Controller.IsWelded ? "unweld" : "weld") + " the door."); Controller.ServerTryWeld(); } } var bar = StandardProgressAction.CreateForWelder(ProgressConfig, ProgressComplete, welder) .ServerStartProgress(interaction.Performer.transform.position, weldTime, interaction.Performer); if (bar != null) { SoundManager.PlayNetworkedAtPos("Weld", interaction.Performer.transform.position, UnityEngine.Random.Range(0.8f, 1.2f), sourceObj: interaction.Performer); Chat.AddExamineMsgFromServer(interaction.Performer, "You start " + (Controller.IsWelded ? "unwelding" : "welding") + " the door..."); } return; } } else if (!Controller.IsAutomatic) { ToolUtils.ServerUseToolWithActionMessages(interaction, 4f, "You start to disassemble the false wall...", $"{interaction.Performer.ExpensiveName()} starts to disassemble the false wall...", "You disassemble the girder.", $"{interaction.Performer.ExpensiveName()} disassembles the false wall.", () => Controller.ServerDisassemble(interaction)); return; } } // Attempt to open if it's closed //Tell the OnAttemptOpen node to activate. if (Controller.IsHackable) { HackingNode onAttemptOpen = Controller.HackingProcess.GetNodeWithInternalIdentifier("OnAttemptOpen"); onAttemptOpen.SendOutputToConnectedNodes(interaction.Performer); } else { Controller.ServerTryOpen(interaction.Performer); } } StartInputCoolDown(); }
public virtual void RemoveConnectedNode(HackingNode node) { connectedInputNodes.Remove(node); }
/// <summary> /// Gets the UI component of a node inside the system. Every node should have a UI component, so this shouldn't ever return null. If it does, uh oh. /// </summary> /// <param name="node"></param> /// <returns></returns> private GUI_HackingNode GetUIComponentOfNode(HackingNode node) { return(nodeUIObjects.Find(x => x.HackNode.Equals(node))); }
public virtual void AddConnectedNode(HackingNode node) { connectedInputNodes.Add(node); }
public void ServerTryOpen(GameObject Originator) { if (Time.time < delayStartTimeTryOpen + inputDelay) { return; } delayStartTimeTryOpen = Time.time; if (isWelded) { Chat.AddExamineMsgFromServer(Originator, "This door is welded shut."); return; } if (AccessRestrictions != null) { if (!AccessRestrictions.CheckAccess(Originator)) { if (IsClosed && !isPerformingAction) { if (isHackable && hackingLoaded) { HackingNode onIDRejected = hackingProcess.GetNodeWithInternalIdentifier("OnIDRejected"); onIDRejected.SendOutputToConnectedNodes(Originator); } else { ServerAccessDenied(); } return; } } } if (IsClosed && !isPerformingAction) { if (!pressureWarnActive && DoorUnderPressure()) { if (isHackable && hackingLoaded) { HackingNode shouldDoPressureWarn = hackingProcess.GetNodeWithInternalIdentifier("ShouldDoPressureWarning"); shouldDoPressureWarn.SendOutputToConnectedNodes(Originator); } else { ServerPressureWarn(); } } else { if (isHackable && hackingLoaded) { HackingNode onShouldOpen = hackingProcess.GetNodeWithInternalIdentifier("OnShouldOpen"); onShouldOpen.SendOutputToConnectedNodes(Originator); } else { ServerOpen(); } } } }
public void LinkHackNodes() { HackingNode openDoor = hackingProcess.GetNodeWithInternalIdentifier("OpenDoor"); openDoor.AddToInputMethods(ServerOpen); HackingNode closeDoor = hackingProcess.GetNodeWithInternalIdentifier("CloseDoor"); closeDoor.AddToInputMethods(ServerClose); HackingNode beginOpenProcedure = hackingProcess.GetNodeWithInternalIdentifier("BeginOpenProcedure"); beginOpenProcedure.AddToInputMethods(ServerTryOpen); HackingNode beginCloseProcedure = hackingProcess.GetNodeWithInternalIdentifier("BeginCloseProcedure"); beginCloseProcedure.AddToInputMethods(ServerTryClose); HackingNode onAttemptOpen = hackingProcess.GetNodeWithInternalIdentifier("OnAttemptOpen"); onAttemptOpen.AddConnectedNode(beginOpenProcedure); HackingNode onAttemptClose = hackingProcess.GetNodeWithInternalIdentifier("OnAttemptClose"); onAttemptClose.AddConnectedNode(beginCloseProcedure); HackingNode onShouldOpen = hackingProcess.GetNodeWithInternalIdentifier("OnShouldOpen"); onShouldOpen.AddWireCutCallback(ServerElectrocute); onShouldOpen.AddConnectedNode(openDoor); HackingNode onShouldClose = hackingProcess.GetNodeWithInternalIdentifier("OnShouldClose"); onShouldClose.AddWireCutCallback(ServerElectrocute); onShouldClose.AddConnectedNode(closeDoor); HackingNode acceptID = hackingProcess.GetNodeWithInternalIdentifier("AcceptId"); HackingNode rejectID = hackingProcess.GetNodeWithInternalIdentifier("RejectID"); rejectID.AddToInputMethods(ServerAccessDenied); HackingNode onIDRejected = hackingProcess.GetNodeWithInternalIdentifier("OnIDRejected"); onIDRejected.AddConnectedNode(rejectID); HackingNode doPressureWarning = hackingProcess.GetNodeWithInternalIdentifier("DoPressureWarning"); doPressureWarning.AddToInputMethods(ServerPressureWarn); HackingNode shouldDoPressureWarning = hackingProcess.GetNodeWithInternalIdentifier("ShouldDoPressureWarning"); shouldDoPressureWarning.AddConnectedNode(doPressureWarning); HackingNode onDoorOpened = hackingProcess.GetNodeWithInternalIdentifier("OnDoorOpened"); HackingNode onDoorClosed = hackingProcess.GetNodeWithInternalIdentifier("OnDoorClosed"); HackingNode powerIn = hackingProcess.GetNodeWithInternalIdentifier("PowerIn"); HackingNode powerOut = hackingProcess.GetNodeWithInternalIdentifier("PowerOut"); powerOut.AddConnectedNode(powerIn); powerOut.AddWireCutCallback(ServerElectrocute); HackingNode dummyIn = hackingProcess.GetNodeWithInternalIdentifier("DummyIn"); HackingNode dummyOut = hackingProcess.GetNodeWithInternalIdentifier("DummyOut"); dummyOut.AddConnectedNode(dummyIn); hackingLoaded = true; }
public void SendOutputToConnectedNodes(HackingIdentifier identifier, GameObject originator = null) { HackingNode node = GetNodeWithInternalIdentifier(identifier); node.SendOutputToConnectedNodes(originator); }
public void SetHackingNode(HackingNode node) { hackNode = node; SetUpNodeData(); }