Exemplo n.º 1
0
            public bool MoveNext()
            {
                while (_tmp.Count > 0)
                {
                    var minKey = _tmp.MinKey();
                    var min = _tmp.RemoveMin();
                    int child1, child2;
                    _tree.GetChildren(min, out child1, out child2);
                    if (child1 == -1)
                    {
                        Current = new NearestNodeResult(min, minKey, _tree.GetUserData <object>(min));
                        return(true);
                    }

                    Insert(child1);
                    Insert(child2);
                }

                Current = default(NearestNodeResult);
                return(false);
            }
Exemplo n.º 2
0
            public bool MoveNext()
            {
                while (_tmp.Count > 0)
                {
                    var minKey = _tmp.MinKey();
                    var min = _tmp.RemoveMin();
                    int child1, child2;
                    _tree.GetChildren(min, out child1, out child2);
                    if (child1 == -1)
                    {
                        Current = new KeyValuePair <int, double>(min, minKey);
                        return(true);
                    }

                    Insert(child1);
                    Insert(child2);
                }

                Current = default(KeyValuePair <int, double>);
                return(false);
            }
Exemplo n.º 3
0
        public void GetShieldsChangesInBox(int callerId, BoundingBoxD box, HashSet <DefenseShields> foundShields, HashSet <DefenseShields> lostShields, Dictionary <MyEntity, DefenseShields> compare)
        {
            var root      = _aabbTree.GetRoot();
            var noneFound = true;

            if (root == -1)
            {
                return;
            }

            _stack.Clear();
            _stack.Push(root);

            while (_stack.Count > 0)
            {
                int id     = _stack.Pop();
                var nodeBB = _aabbTree.GetAabb(id);

                if (!nodeBB.Intersects(box))
                {
                    continue;
                }

                int left;
                int right;
                _aabbTree.GetChildren(id, out left, out right); // GetBranches!!!

                if (left == -1)                                 // is leaf
                {
                    if (id == callerId)
                    {
                        continue;
                    }
                    noneFound = false;

                    var ds = _aabbTree.GetUserData <DefenseShields>(id);
                    if (!compare.ContainsKey(ds.MyGrid))
                    {
                        foundShields.Add(ds);
                    }
                    else
                    {
                        lostShields.Add(ds);
                    }
                }
                else
                {
                    if (left >= 0)
                    {
                        _stack.Push(left);
                    }

                    if (right >= 0)
                    {
                        _stack.Push(right);
                    }
                }
            }

            foreach (var shield in compare.Values)
            {
                if (noneFound)
                {
                    lostShields.Add(shield);
                }
                else if (lostShields.Contains(shield))
                {
                    lostShields.Remove(shield);
                }
            }
        }