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);
        }
        public void Apply(StatisticReceived @event, bool active)
        {
            if (active)
            {
                LastActive = Latest(LastActive, @event.Timestamp);
            }
            else
            {
                LastInactive = Latest(LastInactive, @event.Timestamp);
            }

            var groupTime = Truncate(@event.Timestamp);

            QueryGraph.TryGetValue(groupTime, out var queryCount);
            QueryGraph[groupTime] = ++queryCount;

            if (active)
            {
                ActiveGraph.TryGetValue(groupTime, out var activeCount);
                ActiveGraph[groupTime] = ++activeCount;
            }
            else
            {
                InactiveGraph.TryGetValue(groupTime, out var inactiveCount);
                InactiveGraph[groupTime] = ++inactiveCount;
            }
        }
        public override void OnEnter(Node previousActiveNode, Connection connection)
        {
            base.OnEnter(previousActiveNode, connection);
            if (ActiveGraph == null)
            {
                return;
            }
            if (ErrorNoGraphReferenced)
            {
                return;
            }
            if (ErrorReferencedGraphIsNotSubGraph)
            {
                return;
            }
            var enterNode = m_subGraph.GetEnterNode() as EnterNode;

            if (enterNode == null)
            {
                return;
            }
            ActiveGraph.DeactivateGlobalNodes();
            ActiveGraph.ActiveSubGraph    = m_subGraph;
            m_subGraph.ParentGraph        = ActiveGraph;
            m_subGraph.ParentSubGraphNode = this;
            m_subGraph.SetActiveNode(enterNode, null);
        }
示例#4
0
 private void ContinueToNextNode()
 {
     if (!FirstOutputSocket.IsConnected)
     {
         return;
     }
     ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection);
 }
示例#5
0
        public INode CreateNode(Type type, string nodeName, Vector2 position)
        {
            var node = ActiveGraph.AddNode(type, nodeName, position);

            Save();

            return(node);
        }
示例#6
0
 private void ActivateOutputSocketInputNode(Socket socket)
 {
     if (ActiveGraph == null || socket == null)
     {
         return;                                        //sanity check
     }
     ActiveGraph.SetActiveNodeByConnection(socket.Connections[0]);
 }
 public void AddNode(Type type, string itemName, Vector2 nodePosition)
 {
     if (IsEmpty)
     {
         return;
     }
     ActiveGraph.AddNode(type, itemName, nodePosition);
     Reload();
 }
示例#8
0
 public void ExitSubGraphNode()
 {
     if (!FirstOutputSocket.IsConnected)
     {
         return;
     }
     ActiveGraph.ActiveSubGraph = null;
     ActiveGraph.SetActiveNodeByConnection(FirstOutputSocket.FirstConnection);
 }
示例#9
0
 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);
 }
示例#11
0
 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);
        }
示例#13
0
        private void UpdateGraphs(StatisticReceived @event)
        {
            var groupTime = Truncate(@event.Timestamp);

            QueryGraph.TryGetValue(groupTime, out var queryCount);
            QueryGraph[groupTime] = ++queryCount;

            if (@event.Active)
            {
                ActiveGraph.TryGetValue(groupTime, out var activeCount);
                ActiveGraph[groupTime] = ++activeCount;
            }
            else
            {
                InactiveGraph.TryGetValue(groupTime, out var inactiveCount);
                InactiveGraph[groupTime] = ++inactiveCount;
            }
        }
示例#14
0
 public override void OnEnter(Node previousActiveNode, Connection connection)
 {
     base.OnEnter(previousActiveNode, connection);
     if (ActiveGraph == null)
     {
         return;
     }
     if (ActiveGraph.ParentGraph == null)
     {
         return;
     }
     if (ActiveGraph.ParentSubGraphNode == null)
     {
         return;
     }
     ActiveGraph.DeactivateGlobalNodes();
     ActiveGraph.ParentSubGraphNode.ExitSubGraphNode();
 }
示例#15
0
        private void OnGUI()
        {
            var e = Event.current;
            var m = GUI.matrix;

            if (ActiveGraph == null ||
                e.type == EventType.Ignore ||
                e.rawType == EventType.Ignore)
            {
                return;
            }

            //Initialize(ActiveGraph);

            var editorNode = new EditorNode()
            {
                Node     = ActiveGraph,
                Parent   = null,
                Property = null,
            };

            graphEditor          = NodeGraphEditor.GetEditor(editorNode);
            graphEditor.position = position;

            if (EditorApplication.isPlayingOrWillChangePlaymode == false)
            {
                ActiveGraph.Initialize(ActiveGraph);
                ActiveGraph.Validate();
            }

            Controls();

            DrawGrid(position, Zoom, PanOffset);
            DrawZoomedNodes();
            DrawConnections();
            DrawDraggedConnection();
            DrawSelectionBox();
            DrawTooltip();
            DrawGraphsControlls();

            graphEditor.OnGUI();

            GUI.matrix = m;
        }
示例#16
0
        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);
        }
示例#17
0
 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);
 }
示例#18
0
        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
        }