public SerializeNode(Type type, NodeCategory nodeCategory, TypeNode typeNode = null, CustomSerialierAttribute customAttr = null) : base(type) { Category = nodeCategory; TypeNode = typeNode; customAttribute = customAttr; }
public ParameterNodeFactory(string pinType, NodeCategory category, string name, string defaultValue = null) : base( NodeTypes.MakeType(NodeTypes.ParameterPrefix, pinType), name, category.ToString()) { _value = defaultValue ?? GetDefaultValue(pinType); _pinType = pinType == PinTypes.Special.Color ? PinTypes.Vec4 : pinType; _category = category; }
public NodeRecord(T node, BaseConnection <T> connection, float costSoFar, float estTotalCost, NodeCategory category) { this.node = node; this.connection = connection; this.costSoFar = costSoFar; this.estimatedTotalCost = estTotalCost; this.category = category; }
private static NodeCategory GenerateCategories(List <NodeTypeData> nodeTypeData) { nodeTypeData = nodeTypeData.ToList(); //Copy that shit because we don't want to break m_categories var nodeHeirarchy = new NodeCategory(null, DomainIDs.CategoryNone); var duplicates = nodeTypeData.GroupBy(a => a.Guid).Where(g => g.Count() > 1); if (duplicates.Any()) { throw new CategoryGenerationException("The following node types have duplicate definitions: " + string.Join(", ", duplicates.Select(g => g.Key).ToArray())); } List <NodeCategory> nodeTypes = new List <NodeCategory> { }; nodeTypes.Add(nodeHeirarchy); //foreach (var data in nodeTypeData.Where(d => d.Parent == DomainIds.CATEGORY_NONE).ToList()) //{ // var newNodeType = new NodeCategory(data.Name, data.Guid); // m_nodes.m_childTypes.Add(newNodeType); // nodeTypes.Add(newNodeType); // nodeTypeData.Remove(data); //} bool gotOne = true; while (nodeTypeData.Any() && gotOne) { gotOne = false; for (int i = 0; i < nodeTypes.Count; i++) { var parent = nodeTypes[i]; foreach (var data in nodeTypeData.Where(d => d.Parent == parent.Guid).ToList()) { var newNodeType = new NodeCategory(data.Name, data.Guid); parent.AddChildType(newNodeType); nodeTypes.Add(newNodeType); gotOne = true; nodeTypeData.Remove(data); } } } if (!gotOne) { //TODO: How to express this to the user? //throw new Exception("The following node types are ancestors of an unknown node type: " + string.Join(", ", nodeTypeData.Select(d => d.Guid).ToArray())); // MessageBox.Show("The following node types are ancestors of an unknown node type: " + string.Join(", ", nodeTypeData.Select(d => d.Guid).ToArray())); foreach (var orphan in nodeTypeData) { nodeHeirarchy.AddChildType(new NodeCategory(orphan.Name, orphan.Guid)); } } return(nodeHeirarchy); }
private void Documentation_NetTerrain_Categories_Filter_SetCategorie_Click(object sender, RoutedEventArgs e) { foreach (DataGrid_netTerrain_Entry item in list) { if (item.booleanFlag) { Documentation_NetTerrain_Categories_Filter_Textbox.Text += "\r" + item.Name; NodeType nodeType = api.getNodeTypeByName(item.Name); NodeCategory nodeCategory = api.getNodeCategoryByNodeName(Documentation_NetTerrain_Categories_Filter_Categories.SelectedValue.ToString()); nodeType.CategoryId = nodeCategory.Id; api.updateNodeType(nodeType); item.Categorie = nodeCategory.Name; } } Documentation_NetTerrain_Categories_DataGrid.Items.Refresh(); }
NodeCategory DetectCategory(GameObject go) { NodeCategory cat = DetectCategory(go.GetComponents <Component>()); if (cat != NodeCategory.None) { return(cat); } var t = go.transform; for (int i = 0; i < t.childCount; ++i) { cat = DetectCategory(t.GetChild(i).gameObject); if (cat != NodeCategory.None) { return(cat); } } return(cat); }
public UniformNodeFactory(string pinType, NodeCategory category, string name, NodeFactoryVisibility visibility = NodeFactoryVisibility.Visible) : base( NodeTypes.MakeType(NodeTypes.UniformPrefix, pinType), name, category.ToString(), visibility) { _pinType = pinType == PinTypes.Special.Color ? PinTypes.Vec4 : pinType; _category = category; }
public BuildInVariableNodeFactory(string pinType, NodeCategory category, string name) : base( name, name, category.ToString()) { _pinType = pinType == PinTypes.Special.Color ? PinTypes.Vec4 : pinType; _category = category; }
Node ExtractNodeBranch(GameObject go) { // TODO Detect if go is a prefab with PrefabUtility var componentNodes = new List <Node>(); Component[] components = go.GetComponents <Component>(); NodeCategory rootCategory = DetectCategory(go); Node rootNode = null; Rigidbody2D promoteRigidBody2D = null; float rescale2d = 1f; int scriptCount = 0; Script script = null; Dictionary <string, object> scriptVariables = null; foreach (var cmp in components) { Node node = null; if (cmp is SpriteRenderer) { var src = (SpriteRenderer)cmp; var dst = new Sprite(); node = dst; dst.selfModulate = src.color; if (src.sprite != null) { dst.texture = Util.Cast <Texture>(ConvertUnityAsset(src.sprite)); rescale2d = src.sprite.pixelsPerUnit; } } else if (cmp is Rigidbody2D) { // In Godot, bodies work best as root promoteRigidBody2D = (Rigidbody2D)cmp; } else if (cmp is Collider2D) { // TODO Proper CollisionShape2D node = new CollisionShape2D(); } else if (cmp is Camera) { var cam = (Camera)cmp; if ((rootCategory == NodeCategory.Node2D || _hint2D) && cam.orthographic) { node = new Camera2D(); } else { // TODO 3D Camera } } else if (cmp is MonoBehaviour) { var mb = (MonoBehaviour)cmp; var s = ConvertScript(mb); if (s != null) { if (scriptCount == 0) { script = s; scriptVariables = GetScriptVariables(mb); } else { node = new Node(); node.name = cmp.GetType().Name; node.script = s; node.scriptVariables = GetScriptVariables(mb); } ++scriptCount; } } else { // TODO more } if (node != null) { componentNodes.Add(node); } } if (rootCategory == NodeCategory.Node2D) { Node2D node2d = null; if (promoteRigidBody2D != null) { if (promoteRigidBody2D.isKinematic) { var n = new KinematicBody2D(); node2d = n; } else { var n = new RigidBody2D(); node2d = n; } } else { if (componentNodes.Count == 1 && componentNodes[0] is Node2D && !(script != null && componentNodes[0].script != null)) { // If there is only one component node, don't create a root node with a single child // TODO Merge transform? Not sure if relevant because this is components node2d = (Node2D)componentNodes[0]; componentNodes.Clear(); } else { node2d = new Node2D(); } } node2d.position = go.transform.position * rescale2d; node2d.position.y *= -1f; // TODO Invert Y properly // TODO Select pivot //node2d.position.y = Screen.height - node2d.position.y; node2d.scale = go.transform.localScale; // TODO Is eulerAngles in degrees or radians?? node2d.rotation = go.transform.rotation.eulerAngles.z; node2d.visible = go.activeSelf; rootNode = node2d; } else if (rootCategory == NodeCategory.Control) { var control = new Control(); control.visible = go.activeSelf; rootNode = control; } else if (rootCategory == NodeCategory.Spatial) { var spatial = new Spatial(); rootNode = spatial; } else { rootNode = new Node(); } if (rootNode != null) { rootNode.name = go.name; if (script != null) { rootNode.script = script; } if (scriptVariables != null) { rootNode.scriptVariables = scriptVariables; } foreach (var child in componentNodes) { if (child.name == null) { child.name = child.GetType().Name; } rootNode.AddChild(child); } } // Children Transform transform = go.transform; for (int i = 0; i < transform.childCount; ++i) { GameObject childGo = transform.GetChild(i).gameObject; Node childNode = ExtractNodeBranch(childGo); rootNode.AddChild(childNode); } return(rootNode); }
// Loads service tree. public void LoadXmlDoc(XmlDocument doc) { if (doc == null) { return; } if (doc.DocumentElement == null) { return; } XmlNodeList accountList; accountList = doc.SelectNodes("//Accounts"); if (accountList == null) { return; } foreach (XmlNode a in accountList) { // Loop through the top level childs. XmlNodeList serviceList = a.ChildNodes; if (serviceList == null) { continue; } foreach (XmlNode s in serviceList) { if (s.LocalName.Equals("Service")) { var accountName = s.Attributes["Name"].Value; var userName = s.Attributes["UserName"].Value; var userPassword = s.Attributes["UserPassword"].Value; var endpoint = s.Attributes["EndPoint"].Value; string api = (s.Attributes["Api"] != null) ? s.Attributes["Api"].Value : "Unknown"; // string tp = (s.Attributes["Type"] != null) ? s.Attributes["Type"].Value : "Unknown"; var selecteds = string.IsNullOrEmpty(s.Attributes["Selected"].Value) ? "" : s.Attributes["Selected"].Value; var expandeds = string.IsNullOrEmpty(s.Attributes["Expanded"].Value) ? "" : s.Attributes["Expanded"].Value; bool isSelecteds = (selecteds == "true") ? true : false; bool isExpandeds = (expandeds == "true") ? true : false; ServiceTypes stp; switch (tp) { case "AtomPub": stp = ServiceTypes.AtomPub; break; case "Feed": stp = ServiceTypes.Feed; break; case "XML-RPC": stp = ServiceTypes.XmlRpc; break; case "AtomAPI": stp = ServiceTypes.AtomApi; break; default: stp = ServiceTypes.Unknown; break; } ApiTypes at; switch (api) { case "AtomPub": at = ApiTypes.atAtomPub; break; case "AtomFeed": at = ApiTypes.atFeed; break; case "RssFeed": at = ApiTypes.atFeed; break; case "Feed": at = ApiTypes.atFeed; break; case "XML-RPC_MovableType": at = ApiTypes.atXMLRPC_MovableType; break; case "XML-RPC_WordPress": at = ApiTypes.atXMLRPC_WordPress; break; case "AtomAPI": at = ApiTypes.atAtomApi; break; default: at = ApiTypes.atUnknown; break; } string viewType = (s.Attributes["ViewType"] != null) ? s.Attributes["ViewType"].Value : "Cards"; ViewTypes vt; switch (viewType) { case "Cards": vt = ViewTypes.vtCards; break; case "Magazine": vt = ViewTypes.vtMagazine; break; case "ThreePanes": vt = ViewTypes.vtThreePanes; break; default: vt = ViewTypes.vtCards; break; } if (stp == ServiceTypes.Feed) { continue; } if ((!string.IsNullOrEmpty(accountName)) && (!string.IsNullOrEmpty(userName)) && (!string.IsNullOrEmpty(userPassword)) && (!string.IsNullOrEmpty(endpoint))) { NodeService account = new NodeService(accountName, userName, userPassword, new Uri(endpoint), at, stp); account.IsSelected = isSelecteds; account.IsExpanded = isExpandeds; account.Parent = this; account.ServiceType = stp; account.Api = at; account.ViewType = vt; XmlNodeList collectionList = s.SelectNodes("Collection"); foreach (XmlNode c in collectionList) { var collectionName = c.Attributes["Name"].Value; var selectedc = string.IsNullOrEmpty(c.Attributes["Selected"].Value) ? "" : c.Attributes["Selected"].Value; var expandedc = string.IsNullOrEmpty(c.Attributes["Expanded"].Value) ? "" : c.Attributes["Expanded"].Value; bool isSelectedc = (selectedc == "true") ? true : false; bool isExpandedc = (expandedc == "true") ? true : false; string collectionHref = (c.Attributes["Href"] != null) ? c.Attributes["Href"].Value : ""; string collectionId = (c.Attributes["Id"] != null) ? c.Attributes["Id"].Value : ""; if ((!string.IsNullOrEmpty(collectionName)) && (!string.IsNullOrEmpty(collectionHref))) { NodeEntryCollection entries = null; // TODO: switch (account.Api) { case ApiTypes.atAtomPub: entries = new NodeAtomPubEntryCollection(collectionName, new Uri(collectionHref), collectionId); break; case ApiTypes.atXMLRPC_MovableType: entries = new NodeXmlRpcEntryCollection(collectionName, new Uri(collectionHref), collectionId); break; case ApiTypes.atXMLRPC_WordPress: entries = new NodeXmlRpcEntryCollection(collectionName, new Uri(collectionHref), collectionId); break; //case ApiTypes.atAtomAPI: // break; } if (entries == null) { continue; } if (entries is NodeAtomPubEntryCollection) { if (c.Attributes["CategoriesUri"] != null) { var catsUrl = c.Attributes["CategoriesUri"].Value; if (!string.IsNullOrEmpty(catsUrl)) { try { Uri catsUri = new(catsUrl); (entries as NodeAtomPubEntryCollection).CategoriesUri = catsUri; } catch { } } } var catFixed = c.Attributes["IsCategoryFixed"].Value; if (!string.IsNullOrEmpty(catFixed)) { if (catFixed == "true") { (entries as NodeAtomPubEntryCollection).IsCategoryFixed = true; } } XmlNodeList acceptList = c.SelectNodes("Accept"); foreach (XmlNode act in acceptList) { (entries as NodeAtomPubEntryCollection).AcceptTypes.Add(act.InnerText); } } XmlNodeList categoryList = c.SelectNodes("Category"); foreach (XmlNode t in categoryList) { var categoryName = t.Attributes["Name"].Value; var selectedt = string.IsNullOrEmpty(t.Attributes["Selected"].Value) ? "" : t.Attributes["Selected"].Value; var expandedt = string.IsNullOrEmpty(t.Attributes["Expanded"].Value) ? "" : t.Attributes["Expanded"].Value; bool isSelectedt = (selectedc == "true") ? true : false; bool isExpandedt = (expandedc == "true") ? true : false; if (!string.IsNullOrEmpty(categoryName)) { NodeCategory category = null; switch (account.Api) { case ApiTypes.atAtomPub: category = new NodeAtomPubCategory(categoryName); break; case ApiTypes.atXMLRPC_MovableType: category = new NodeXmlRpcMTCategory(categoryName); break; case ApiTypes.atXMLRPC_WordPress: category = new NodeXmlRpcWPCategory(categoryName); break; //case ApiTypes.atAtomAPI: // break; } if (category == null) { return; } if (category is NodeAtomPubCategory) { (category as NodeAtomPubCategory).Term = categoryName; var categoryScheme = t.Attributes["Scheme"].Value; (category as NodeAtomPubCategory).Scheme = categoryScheme; } category.IsSelected = isSelectedc; category.IsExpanded = isExpandedc; category.Parent = entries; entries.Children.Add(category); } } entries.IsSelected = isSelectedc; entries.IsExpanded = isExpandedc; entries.Parent = account; account.Children.Add(entries); } } this.Children.Add(account); } } else if (s.LocalName.Equals("Feed")) { NodeFeed feed = LoadXmlChildFeed(s); if (feed == null) { continue; } feed.Parent = this; if (feed != null) { this.Children.Add(feed); } } else if (s.LocalName.Equals("Folder")) { var folderName = s.Attributes["Name"].Value; if (!string.IsNullOrEmpty(folderName)) { var selecteds = string.IsNullOrEmpty(s.Attributes["Selected"].Value) ? "" : s.Attributes["Selected"].Value; var expandeds = string.IsNullOrEmpty(s.Attributes["Expanded"].Value) ? "" : s.Attributes["Expanded"].Value; bool isSelecteds = (selecteds == "true") ? true : false; bool isExpandeds = (expandeds == "true") ? true : false; NodeFolder folder = new NodeFolder(folderName); folder.IsSelected = isSelecteds; folder.IsExpanded = isExpandeds; folder.Parent = this; int unreadCount = 0; var attr = s.Attributes["UnreadCount"]; if (attr != null) { if (!string.IsNullOrEmpty(s.Attributes["UnreadCount"].Value)) { unreadCount = int.Parse(s.Attributes["UnreadCount"].Value); } } folder.EntryCount = unreadCount; string viewType = (s.Attributes["ViewType"] != null) ? s.Attributes["ViewType"].Value : "Cards"; ViewTypes vt; switch (viewType) { case "Cards": vt = ViewTypes.vtCards; break; case "Magazine": vt = ViewTypes.vtMagazine; break; case "ThreePanes": vt = ViewTypes.vtThreePanes; break; default: vt = ViewTypes.vtCards; break; } folder.ViewType = vt; XmlNodeList feedList = s.SelectNodes("Feed"); foreach (XmlNode f in feedList) { NodeFeed feed = LoadXmlChildFeed(f); if (feed == null) { continue; } feed.Parent = folder; if (feed != null) { folder.Children.Add(feed); } } this.Children.Add(folder); } } } break; } }
private void applicationWindow_Loaded(object sender, RoutedEventArgs e) { MainWindowViewModel viewModel = this.DataContext as MainWindowViewModel; Dictionary <TreeViewItem, string> nodeTreeItems = new Dictionary <TreeViewItem, string>(); Dictionary <string, TreeViewItem> rootCategories = new Dictionary <string, TreeViewItem>(); // Load in all nodes foreach (var node in viewModel.LoadedNodes) { NodeCategory categoryAttribute = (NodeCategory)node.GetCustomAttribute(typeof(NodeCategory)); NodeName nameAttribute = (NodeName)node.GetCustomAttribute(typeof(NodeName)); if (categoryAttribute != null) { nodeTreeItems.Add(new TreeViewItem() { Header = nameAttribute.Name, Tag = node, FontWeight = FontWeights.Normal }, categoryAttribute.Category); } else { nodeTreeItems.Add(new TreeViewItem() { Header = nameAttribute.Name, Tag = node, FontWeight = FontWeights.Normal }, "Uncategorised"); } } // Extract categories foreach (var node in nodeTreeItems) { if (!rootCategories.ContainsKey(node.Value)) { rootCategories.Add(node.Value, new TreeViewItem() { Header = node.Value, FontWeight = FontWeights.Bold, IsExpanded = true }); } } // Display categories foreach (var category in rootCategories) { SelectableNodesTree.Items.Add(category.Value); } // Display nodes by category foreach (var node in nodeTreeItems) { if (node.Value == "Uncategorised") { foreach (var categoryItem in rootCategories.Where( categoryItem => categoryItem.Key.Equals("Uncategorised"))) { categoryItem.Value.Items.Add(node.Key); } } else { foreach (var categoryItem in rootCategories.Where( categoryItem => categoryItem.Key.Equals(node.Value))) { categoryItem.Value.Items.Add(node.Key); } } } }
public ConstantNodeFactory(string pinType, NodeCategory category, string name) : base(pinType, name, category.ToString()) { _pinType = pinType == PinTypes.Special.Color ? PinTypes.Vec4 : pinType; _category = category; }
public NodeUsageAttribute(NodeCategory category, NodePlatform platform) { Category = category; Platform = platform; }