示例#1
0
        public void ExecuteEvent(NodeGraph graph, string eventName)
        {
            NodeGraphEvent startNode = null;

            if (_graphEventCache.ContainsKey(eventName))
            {
                startNode = _graphEventCache[eventName];
            }
            else
            {
                var eventNodes = graph.Helper.GetNodes <NodeGraphEvent>(eventName);

                if (eventNodes.Count == 0)
                {
                    _logger.LogWarning <NodeGraphRunner>("Cannot run graph as no node was found for event '{0}'.", eventName);
                    return;
                }

                if (eventNodes.Count > 1)
                {
                    _logger.LogWarning <NodeGraphRunner>("Found multiple nodes for event '{0}'. Using the first found node...", eventName);
                }

                startNode = eventNodes[0];
            }

            _logger.Log <NodeGraphRunner>("Executing...");

            _currentNode = startNode;
            MoveNext();
        }
        void Log(string message, params object[] args)
        {
            var prefix = string.Format("Depth: {0} - ", Depth);

            _logger.Log <NodeExecutionGroup>(prefix + message, args);
        }