Ejemplo n.º 1
0
 public static Node CreateNode(NodeKind kind, string text = "")
 {
     return(CreateNode(
                "{ " +
                "kind: \"" + kind.ToString() + "\", " +
                "text: \"" + text + "\" " +
                "}"));
 }
Ejemplo n.º 2
0
        public static bool IsContext(NodeKind kind)
        {
            var type       = typeof(NodeKind);
            var memberInfo = type.GetMember(kind.ToString());
            var attrs      = memberInfo [0].GetCustomAttributes(typeof(ContextAttribute), false);

            return(attrs != null && attrs.Length == 1);
        }
Ejemplo n.º 3
0
        /**
         * Serialize to JSON dictionary
         */
        public Dictionary <string, object> ToJsonDictionary()
        {
            var nodeDict = new Dictionary <string, object>();

            nodeDict[NODE_NAME] = m_name;
            nodeDict[NODE_ID]   = m_id;
            nodeDict[NODE_KIND] = m_kind.ToString();

            if (!string.IsNullOrEmpty(m_scriptClassName))
            {
                nodeDict[NODE_SCRIPT_CLASSNAME] = m_scriptClassName;
            }

            var inputs  = new List <object>();
            var outputs = new List <object>();

            foreach (var p in m_inputPoints)
            {
                inputs.Add(p.ToJsonDictionary());
            }

            foreach (var p in m_outputPoints)
            {
                outputs.Add(p.ToJsonDictionary());
            }

            nodeDict[NODE_INPUTPOINTS]  = inputs;
            nodeDict[NODE_OUTPUTPOINTS] = outputs;

            nodeDict[NODE_POS] = new Dictionary <string, object>()
            {
                { NODE_POS_X, m_x },
                { NODE_POS_Y, m_y }
            };

            switch (m_kind)
            {
            case NodeKind.PREFABBUILDER_GUI:
                nodeDict[NODE_PREFABBUILDER_REPLACEPREFABOPTIONS] = m_prefabBuilderReplacePrefabOptions;
                nodeDict[NODE_SCRIPT_INSTANCE_DATA] = m_scriptInstanceData.ToJsonDictionary();
                break;

            case NodeKind.MODIFIER_GUI:
                nodeDict[NODE_SCRIPT_INSTANCE_DATA] = m_scriptInstanceData.ToJsonDictionary();
                break;

            case NodeKind.LOADER_GUI:
                nodeDict[NODE_LOADER_LOAD_PATH] = m_loaderLoadPath.ToJsonDictionary();
                break;

            case NodeKind.FILTER_GUI:
                var filterDict = new List <object>();
                foreach (var f in m_filter)
                {
                    var df = new Dictionary <string, object>();
                    df[NODE_FILTER_KEYWORD] = f.FilterKeyword;
                    df[NODE_FILTER_KEYTYPE] = f.FilterKeytype;
                    df[NODE_FILTER_POINTID] = f.ConnectionPoint.Id;
                    filterDict.Add(df);
                }
                nodeDict[NODE_FILTER] = filterDict;
                break;

            case NodeKind.GROUPING_GUI:
                nodeDict[NODE_GROUPING_KEYWORD] = m_groupingKeyword.ToJsonDictionary();
                break;

            case NodeKind.BUNDLECONFIG_GUI:
                nodeDict[NODE_BUNDLECONFIG_BUNDLENAME_TEMPLATE] = m_bundleConfigBundleNameTemplate.ToJsonDictionary();
                nodeDict[NODE_BUNDLECONFIG_USE_GROUPASVARIANTS] = m_bundleConfigUseGroupAsVariants;
                var variantsDict = new List <object>();
                foreach (var v in m_variants)
                {
                    var dv = new Dictionary <string, object>();
                    dv[NODE_BUNDLECONFIG_VARIANTS_NAME]    = v.Name;
                    dv[NODE_BUNDLECONFIG_VARIANTS_POINTID] = v.ConnectionPoint.Id;
                    variantsDict.Add(dv);
                }
                nodeDict[NODE_BUNDLECONFIG_VARIANTS] = variantsDict;
                break;

            case NodeKind.BUNDLEBUILDER_GUI:
                nodeDict[NODE_BUNDLEBUILDER_ENABLEDBUNDLEOPTIONS] = m_bundleBuilderEnabledBundleOptions.ToJsonDictionary();
                break;

            case NodeKind.EXPORTER_GUI:
                nodeDict[NODE_EXPORTER_EXPORT_PATH]   = m_exporterExportPath.ToJsonDictionary();
                nodeDict[NODE_EXPORTER_EXPORT_OPTION] = m_exporterExportOption.ToJsonDictionary();
                break;

            case NodeKind.IMPORTSETTING_GUI:
                // nothing to do
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(nodeDict);
        }
Ejemplo n.º 4
0
 public Node FindAbove(NodeKind kind)
 {
     Node first = this;
     while (first != null)
     {
         if (first.Kind == kind)
             return first;
         first = first.Above;
     }
     throw new System.Exception("Search for " + kind.ToString() + " node failed");
 }