示例#1
0
        public int Load(string filename)
        {
            DDObject dd = null;

            try
            {
                dd = DDObject.Load(filename);
            }
            catch
            {
                // The file can be busy at the moment
                System.Threading.Thread.Sleep(250);
                dd = DDObject.Load(filename);
            }

            if (null == dd)
            {
                return(-1);
            }

            if (null == dd.StartNode)
            {
                return(-2);
            }

            dd.Init();

            m_Object = dd;

            m_OutputFolder = Path.GetDirectoryName(filename) + Path.DirectorySeparatorChar;
            m_OutputFile   = m_OutputFolder + dd.file_name + ".rpy";

            return(0);
        }
示例#2
0
        /// <summary>
        /// Initialize node. Main outcome is count of inputs to the node.
        /// It is summary count of nodes, choices and branches who have curret node as a next one.
        /// </summary>
        /// <param name="owner"></param>
        public void Init(DDObject owner)
        {
            m_Owner = owner;

            InputsCount = owner.nodes.Count(n => node_name.Equals(n.next))
                          + owner.nodes.Count(n => n.choices?.Any(c => node_name.Equals(c.next)) ?? false)
                          + owner.nodes.Count(n => (n.branches is JsonElement jBranches)? jBranches.EnumerateObject()
                                              .Any(c => node_name.Equals(c.ToString())): false);
        }