Esempio n. 1
0
        protected GraphFile(IEnumerable <GraphAndUI <NodeUIData> > nodes, IEnumerable <NodeGroup> groups, ReadOnlyCollection <LoadError> errors, INodeFactory nodeFactory,
                            GenerateAudio generateAudio, Func <IDynamicEnumParameter, object, DynamicEnumParameter.Source> getDocumentSource, IAudioLibrary audioProvider)
        {
            Contract.Assert(getDocumentSource != null);
            m_nodeFactory       = nodeFactory;
            m_generateAudio     = generateAudio;
            m_getDocumentSource = a => getDocumentSource(a, this);
            m_audioProvider     = audioProvider;
            m_nodes             = new CallbackList <ConversationNode>(nodes.Select(gnu => nodeFactory.MakeNode(gnu.GraphData, gnu.UIData)));
            m_nodesLookup       = new O1LookupWrapper <ConversationNode, Id <NodeTemp> >(m_nodes, n => n.Data.NodeId);
            m_nodesOrdered      = new SortedWrapper <ConversationNode>(m_nodes);
            m_groups            = new CallbackList <NodeGroup>(groups);
            m_groupsOrdered     = new SortedWrapper <NodeGroup>(m_groups);
            m_errors            = errors;

            IEnumerable <IDynamicEnumParameter> localDynamicEnumerationParameters = m_nodes.SelectMany(n => n.Data.Parameters.OfType <IDynamicEnumParameter>());

            foreach (var ldep in localDynamicEnumerationParameters)
            {
                ldep.MergeInto(m_getDocumentSource(ldep));
            }

            m_nodes.Inserting += M_nodes_Inserting;
            m_nodes.Inserted  += M_nodes_Inserted;
            m_nodes.Removing  += M_nodes_Removing;
            m_nodes.Clearing  += M_nodes_Clearing;
        }
Esempio n. 2
0
        private void M_nodes_Clearing()
        {
            foreach (var parameter in m_nodes.SelectMany(n => n.Data.Parameters).OfType <IDynamicEnumParameter>())
            {
                //Give it a junk source so it's value stops counting towards the real source
                parameter.MergeInto(new DynamicEnumParameter.Source());
            }
            foreach (var node in m_nodes)
            {
                NodeRemoved.Execute(node);

                foreach (Output connection in node.Data.Connectors)
                {
                    m_cachedNodeUI.Remove(connection);
                }
            }
        }