protected override void GenerateTree(object obj) {

            NewReleaseItem newReleaseItem = (NewReleaseItem) obj;
            NewReleaseHierarchyNode root = new NewReleaseHierarchyNode(newReleaseItem, this);
            RootNodes.Add(root);
            NodeDictionary.Add(root.NewReleaseItem.Album.Name, root);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns>Returns whether the sub-tree has been fully expanded in the hierarchy.</returns>
        public override void GenerateSubTree(IHierarchyNode node)
        {
            ArtistHierarchyNode subTreeNode       = (ArtistHierarchyNode)node;
            ArtistGroup         relatedArtistList = Client.GetRelatedArtists(subTreeNode.ArtistViewModel.Artist.ID);

            //First determine which artists are new; add those.
            int nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                {
                    continue;
                }

                if (nodesAdded < AddChildrenLimit)
                {
                    ArtistViewModel     artistViewModel   = new ArtistViewModel(relatedArtist);
                    ArtistHierarchyNode relatedArtistNode = new ArtistHierarchyNode(artistViewModel, this, subTreeNode, subTreeNode.Level + 1);
                    subTreeNode.Children.Add(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);
                    nodesAdded++;
                }
                else
                {
                    return;
                }
            }
        }
Beispiel #3
0
        public bool TryAddNode(Node node)
        {
            if (NodeDictionary.ContainsKey(node.ID) == false)
            {
                Nodes.Add(node);
                NodeDictionary.Add(node.ID, node);
                return(true);
            }

            return(false);
        }
Beispiel #4
0
        void BuildNodeDictionary()
        {
            NodeDictionary.Clear();

            foreach (var node in Nodes)
            {
                if (NodeDictionary.ContainsKey(node.ID) == false)
                {
                    NodeDictionary.Add(node.ID, node);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// add node to net
        /// </summary>
        /// <param name="node">node</param>
        /// <param name="generateID">generate a new ID?</param>
        public void AddNode(Node node, bool generateID = true)
        {
            if (generateID)
            {
                node.id = GenerateNodeID();
            }
            else
            {
                uniqueID = Mathf.Max(uniqueID, node.id + 1);
            }

            nodes.Add(node.id, node);
        }
        protected virtual SiteMapNode CreateNodeFromElement(XElement element, int currentLevel)
        {
            var attributes = new NameValueCollection();

            foreach (var a in element.Attributes())
            {
                attributes.Add(a.Name.ToString(), a.Value);
            }

            string uri;

            try
            {
                if (element.Attribute("uri") != null)
                {
                    uri = element.Attribute("uri").Value;
                }
                else if (element.Attribute("pageId") != null)
                {
                    uri = element.Attribute("pageId").Value;
                }
                else
                {
                    uri = "";
                }
            }
            catch
            {
                _logger.Debug("exception while retrieving uri", LoggingCategory.General);
                uri = "";
            }
            SiteMapNode childNode = new TridionSiteMapNode(this,
                                                           element.Attribute("id").Value,          //key
                                                           uri,
                                                           element.Attribute("url").Value,         //url
                                                           element.Attribute("title").Value,       //title
                                                           element.Attribute("description").Value, //description
                                                           null,                                   //roles
                                                           attributes,                             //attributes
                                                           null,                                   //explicitresourceKeys
                                                           null)
            {
                Level = currentLevel
            };                                  // implicitresourceKey

            NodeDictionary.Add(childNode.Key, childNode);

            return(childNode);
        }
Beispiel #7
0
        public Boolean Add([CanBeNull] T item)
        {
            if (item is null)
            {
                return(false);
            }

            if (NodeDictionary.ContainsKey(item))
            {
                return(false);
            }

            LinkedListNode <T> node = LinkedList.AddLast(item);

            NodeDictionary.Add(item, node);
            return(true);
        }
Beispiel #8
0
        /// <summary>
        /// Generates the tree from the root artist.
        /// </summary>
        /// <param name="artist"></param>
        protected override void GenerateTree(object obj)
        {
            Artist artist = (Artist)obj;

            if (NodeDictionary.ContainsKey(artist.Name))
            {
                return;
            }

            ArtistViewModel     rootViewModel = new ArtistViewModel(artist);
            ArtistHierarchyNode root          = new ArtistHierarchyNode(rootViewModel, this, null, 0);

            RootNodes.Add(root);
            NodeDictionary.Add(artist.Name, root);

            ArtistGroup relatedArtistList = Client.GetRelatedArtists(artist.ID);

            //First determine which artists are new; add those.
            List <Artist> newArtists = new List <Artist>();
            int           nodesAdded = 0;

            foreach (Artist relatedArtist in relatedArtistList.Artists)
            {
                if (NodeDictionary.ContainsKey(relatedArtist.Name))
                {
                    continue;
                }

                if (nodesAdded < AddChildrenLimit)
                {
                    newArtists.Add(relatedArtist);

                    ArtistViewModel     artistViewModel   = new ArtistViewModel(relatedArtist);
                    ArtistHierarchyNode relatedArtistNode = new ArtistHierarchyNode(artistViewModel, this, root, 1);
                    root.Children.Add(relatedArtistNode);
                    NodeDictionary.Add(relatedArtist.Name, relatedArtistNode);

                    nodesAdded++;
                }
                else
                {
                    break;
                }
            }
        }
Beispiel #9
0
        // Event handlers
        public override void _Ready()
        {
            this.Initialize();

            // Register interact targets
            foreach (var target in GetTree().GetNodesInGroup(Constants.RegisterInteractable).Cast <Node>())
            {
                Debug.Assert(target is IProp);
                InteractTargets.Add(target.Name, target);
            }

            if (this.GetNetworkMode() == NetworkMode.Server)
            {
                // Connect signals
                GetTree().Connect(SceneTreeSignals.NetworkPeerConnected, this, nameof(_PeerConnected));
                GetTree().Connect(SceneTreeSignals.NetworkPeerDisconnected, this, nameof(_PeerDisconnected));
            }
        }
Beispiel #10
0
        public void _PeerConnected(int peerId)
        {
            GD.Print(peerId, " connected!");

            // Create player
            var player = (PlayerRoot)_playerPrefab.Instance();

            player.Name = $"player_{peerId}";
            Entities.AddChild(player);
            player.State.OwnerPeerId = peerId;
            player.State.DisplayName = $"user_{peerId}";
            player.Shared.OnSetupComplete();

            // Replicate to already existent peers
            Entities.ReplicateEntity(player);              // The peer doesn't yet have visibility over the scene and thus won't get the entity replicated by this method.

            // Replicate to the new peer
            OnlinePlayers.Add(peerId, player);                                  // The replicated scene is now visible to that peer
            RpcId(peerId, nameof(_LoggedIn), this.GenerateCatchupInfo(peerId)); // And thus, when catching up the scene, the peer will receive everything.
        }
        private void AddToHistory(Node previousNode, Node currentCandidateNode)
        {
            if (previousNode == currentCandidateNode)
            {
                return;
            }

            // Add node to dictionary first
            NodeDictionary.Add(previousNode.Id, previousNode);


            if (NodeHistory.ContainsKey(previousNode.Id))
            {
                NodeHistory[previousNode.Id].Add(currentCandidateNode.Id);
            }
            else
            {
                NodeHistory[previousNode.Id] = new List <string>();
            }

            NodeHistory[previousNode.Id].Add(currentCandidateNode.Id);
        }
Beispiel #12
0
        public Boolean Insert(Int32 index, T?item)
        {
            if (index < 0 || index >= Count)
            {
                throw new ArgumentNullException(nameof(index));
            }

            if (item is null)
            {
                return(false);
            }

            if (NodeDictionary.ContainsKey(item))
            {
                return(false);
            }

            LinkedListNode <T> node = LinkedList.Insert(index, item);

            NodeDictionary.Add(item, node);
            return(true);
        }
Beispiel #13
0
        public void BuildGraph()
        {
            PropertyDictionary = new PropertyDictionary();
            foreach (var property in Properties)
            {
                PropertyDictionary.Add(property.Guid, property);
            }

            NodeDictionary = new NodeDictionary();
            foreach (var node in Nodes)
            {
                NodeDictionary.Add(node.Guid, node);
            }

            // Link node lines with actual properties, find previous node and actor node where necessary
            var propertyNodes = Nodes.Where(node => node.Type == NodeType.PROP).ToDictionary(node => node.Guid, node => node);

            // convert each conversation line reference from port to property lists using edge list
            foreach (var node in Nodes)
            {
                if (node.Type != NodeType.SELF && node.Type != NodeType.NPC)
                {
                    continue;
                }
                foreach (var line in node.Lines)
                {
                    line.Checks   = new List <string>();
                    line.Triggers = new List <string>();
                    string setNext = null;
                    foreach (var edge in Edges)
                    {
                        // Find triggers
                        if (line.TriggerPort == edge.FromPort)
                        {
                            var nodeGuid = edge.ToNode;
                            line.Triggers.Add(propertyNodes[nodeGuid].Temp_PropertyNodeGuid);
                        }

                        // Find checks, only for NPC nodes
                        if (node.Type == NodeType.NPC && line.CheckPort == edge.ToPort && NodeDictionary[edge.FromNode].Type == NodeType.PROP)
                        {
                            var nodeGuid = edge.FromNode;
                            line.Checks.Add(propertyNodes[nodeGuid].Temp_PropertyNodeGuid);
                        }

                        // Find next node
                        if (edge.FromNode == node.Guid && line.Next == edge.FromPort)
                        {
                            setNext = edge.ToNode;
                        }
                    }

                    line.Next = setNext;
                }

                foreach (var edge in Edges)
                {
                    // Find actor node
                    if (edge.ToNode == node.Guid && node.Type == NodeType.NPC && propertyNodes.ContainsKey(edge.FromNode) && PropertyDictionary[propertyNodes[edge.FromNode].Temp_PropertyNodeGuid].Type == PropertyType.Actor)
                    {
                        node.ActorGuid = propertyNodes[edge.FromNode].Temp_PropertyNodeGuid;
                    }

                    // Find previous node
                    if (edge.ToNode == node.Guid && (NodeDictionary[edge.FromNode].Type == NodeType.NPC || NodeDictionary[edge.FromNode].Type == NodeType.SELF))
                    {
                        node.Previous = edge.FromNode;
                    }
                }
            }

            // Remove property nodes from Nodes and NodeDictionary
            var copyOfNodes = Nodes.ToList();

            copyOfNodes.ForEach(node => {
                if (node.Type == NodeType.NPC || node.Type == NodeType.SELF)
                {
                    return;
                }
                NodeDictionary.Remove(node.Guid);
                Nodes.Remove(node);
            });

            // Find start node
            foreach (var node in Nodes)
            {
                if (!string.IsNullOrEmpty(node.Previous))
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(StartNode) && StartNode != node.Guid)
                {
                    Debug.LogWarning("Multiple nodes without a previous node detected! Defaulting to the first one found to be the start node.");
                    continue;
                }

                StartNode = node.Guid;
            }
        }