Example #1
0
            private NodeAndLinks ReadEditable(XElement node, IDataSource datasource, INodeFactory <ConversationNode <TNodeUI, TTransitionUI>, TTransitionUI, TUIRawData> nodeFactory)
            {
                NodeID id   = NodeID.Parse(node.Attribute("Id").Value);
                Guid   guid = Guid.Parse(node.Attribute("Guid").Value);

                Func <NodeID, ExternalFunction> nodeGenerator = datasource.GetNode(guid);
                IEditable editable = nodeGenerator(id);

                List <Tuple <Parameter, Func <bool> > > failedParameters = new List <Tuple <Parameter, Func <bool> > >();

                foreach (Parameter p in editable.Parameters)
                {
                    var         pp    = p;
                    Func <bool> retry = () =>
                    {
                        try
                        {
                            return(pp.TryDeserialiseValue(node.Elements("Parameter").Where(n => Guid.Parse(n.Attribute("guid").Value) == pp.Guid).Select(n => n.Attribute("value").Value).Single()));
                        }
                        catch
                        {
                            return(false);
                        }
                    };
                    if (!retry())
                    {
                        failedParameters.Add(Tuple.Create(pp, retry));
                    }
                }
                ConversationNode <TNodeUI, TTransitionUI> a = !failedParameters.Any() ? nodeFactory.MakeNode(editable, m_nodeUISerializer.Read(node))
                                                            : nodeFactory.MakeCorruptedNode(editable, m_nodeUISerializer.Read(node), failedParameters);

                return(MakeNodeAndLinks(a, node));
            }
Example #2
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;
        }
Example #3
0
 private Node MakeNewNode(string nodeName, NodeGroupID groupID, IEntity owner)
 {
     return(_nodeFactory.MakeNode(nodeName, groupID, owner));
 }
Example #4
0
 public ConversationNode MakeNode(IConversationNodeData e, NodeUIData uiData)
 {
     return(m_nodeFactory.MakeNode(e, uiData));
 }