private void SceneUnloaded(Scene unloadedScene) { // ReSharper disable once SwitchStatementMissingSomeCases switch (GetSceneBy) { case GetSceneBy.Name: if (!unloadedScene.name.Equals(SceneName)) { return; } break; case GetSceneBy.BuildIndex: if (!unloadedScene.name.Equals(SceneManager.GetSceneByBuildIndex(SceneBuildIndex).name)) { return; } break; } if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
private void ContinueToNextNode() { if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
private void ActivateOutputSocketInputNode(Socket socket) { if (ActiveGraph == null || socket == null) { return; //sanity check } ActiveGraph.SetActiveNodeByConnection(socket.Connections[0]); }
public void ExitSubGraphNode() { if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.ActiveSubGraph = null; ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
public void ExitSubGraphNode() { if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.ActiveSubGraph.Enabled = false; ActiveGraph.ActiveSubGraph = null; ActiveGraph.ActivateGlobalNodes(); ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
public override void OnEnter(Node previousActiveNode, Connection connection) { base.OnEnter(previousActiveNode, connection); if (ActiveGraph == null) { return; } if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
public override void OnEnter(Node previousActiveNode, Connection connection) { base.OnEnter(previousActiveNode, connection); if (ActiveGraph == null) { return; } GameEventMessage.SendEvent(SystemGameEvent.ActivateLoadedScenes); if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
public override void OnEnter(Node previousActiveNode, Connection connection) { base.OnEnter(previousActiveNode, connection); if (ActiveGraph == null) { return; } switch (SoundAction) { case SoundActions.Play: if (HasSound) { SoundyManager.Play(SoundData); } break; case SoundActions.Stop: SoundyManager.StopAllSounds(); break; case SoundActions.Pause: SoundyManager.PauseAllSounds(); break; case SoundActions.Unpause: SoundyManager.UnpauseAllSounds(); break; case SoundActions.Mute: SoundyManager.MuteAllSounds(); break; case SoundActions.Unmute: SoundyManager.UnmuteAllSounds(); break; default: throw new ArgumentOutOfRangeException(); } if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
private void SelectRandomOutputSocket() { m_selectChances.Clear(); MaxChance = 0; foreach (Socket socket in OutputSockets) { if (!socket.IsConnected) { continue; } WeightedConnection connection = WeightedConnection.GetValue(socket); if (connection.Weight <= 0) { m_selectChances.Add(-1); } else { MaxChance += connection.Weight; m_selectChances.Add(MaxChance); } } int randomSocketIndex = 0; int randomChance = Random.Range(0, MaxChance); for (int i = 0; i < m_selectChances.Count; i++) { if (m_selectChances[i] == -1) { continue; } if (m_selectChances[i] < randomChance) { continue; } randomSocketIndex = i; break; } ActiveGraph.SetActiveNodeByConnection(OutputSockets[randomSocketIndex].FirstConnection); }
public override void OnEnter(Node previousActiveNode, Connection connection) { base.OnEnter(previousActiveNode, connection); if (ActiveGraph == null) { return; } if (WaitForSceneToUnload) { SceneDirector.Instance.OnSceneUnloaded.AddListener(SceneUnloaded); } UnloadScene(); if (WaitForSceneToUnload) { return; } if (!FirstOutputSocket.IsConnected) { return; } ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection); }
public override void OnEnter(Node previousActiveNode, Connection connection) { base.OnEnter(previousActiveNode, connection); if (ActiveGraph == null) { return; } SourceInfo source = GetSource(connection); if (source == null) //entered the Switch from the Target Node { if (!string.IsNullOrEmpty(m_returnSourceOutputSocketId)) //we have a return Source OutputSocketId registered -> we need to check that it's valid { Socket socket = GetSocketFromId(m_returnSourceOutputSocketId); //try to get a reference to the socket if (socket != null) //the the output socket was found { if (socket.IsConnected) //the found socket is indeed connected -> go to the input node of this socket { ActiveGraph.SetActiveNodeByConnection(socket.FirstConnection); //go to the input node of this output socket m_returnSourceOutputSocketId = string.Empty; return; //stop here } } } //there is no return to Source OutputSocketId registered //this is a strange case where we come from the Target Node without getting there via the Switch //if we are in this particular situation, then the developer, that created this graph, made some 'uninspired' connections //look for the first available Source OutputSocketId foreach (SourceInfo s in Sources) { if (string.IsNullOrEmpty(s.OutputSocketId)) { continue; //this output socket id is null or empty -> skip this entry } Socket socket = GetSocketFromId(s.OutputSocketId); //try to get a reference to the socket if (socket == null) { continue; //the id is not valid as no socket was found } if (!socket.IsConnected) { continue; //the id was good, the socket was found, but it is not connected -> try to get the next source output socket id } ActiveGraph.SetActiveNodeByConnection(socket.FirstConnection); //go to the input node of this output socket m_returnSourceOutputSocketId = string.Empty; return; //stop here } //if we got to this point then none of the source output sockets are connected //this is very bad and we need to avoid having the UI flow blocked in this Switch //let's return to the node we came from as a last resort ActiveGraph.SetActiveNodeById(connection.OutputNodeId); //go back to the node we came from m_returnSourceOutputSocketId = string.Empty; return; //stop here } //the source is not null -> we entered the Switch from a Source Node //now we need to see if we have a Target Node output connected -> otherwise we need to go back in order to avoid having the UI flow blocked in this Switch if (!TargetOutputSocket.IsConnected) //there is no Target Node connected to the Target Output Socket -> return to the Node we came from { //---> this is not normal as the graph should not work like this, BUT we want to avoid having the UI flow blocked in this node ActiveGraph.SetActiveNodeById(connection.OutputNodeId); //go back m_returnSourceOutputSocketId = string.Empty; return; //stop here } //there is a Target Node connected to the Target Output Socket m_returnSourceOutputSocketId = !string.IsNullOrEmpty(source.OutputSocketId) ? source.OutputSocketId : string.Empty; //save the source output socket id in order to go back to it when we return from the target node ActiveGraph.SetActiveNodeByConnection(TargetOutputSocket.FirstConnection); //go to the Target Node via the Target Output Socket connection }