Exemplo n.º 1
0
        public IIndex <int, WorldBounds, WorldPoint> this[int index]
        {
            get
            {
                if (_trees[index] == null)
                {
#if FARMATH
                    _trees[index] = new FarCollections.SpatialHashedQuadTree <int>(_maxEntriesPerNode, _minNodeBounds, 0.1f, 2f, (p, v) => p.Write(v), p => p.ReadInt32());
#else
                    _trees[index] = new DynamicQuadTree <int>(_maxEntriesPerNode, _minNodeBounds, 0.1f, 2f, (p, v) => p.Write(v), p => p.ReadInt32());
#endif
                    _changed[index] = new HashSet <int>();
                }
                return(_trees[index]);
            }
        }
Exemplo n.º 2
0
        public void Depacketize(IReadablePacket packet)
        {
            foreach (var tree in _trees.Where(tree => tree != null))
            {
                tree.Clear();
            }
            foreach (var changed in _changed.Where(changed => changed != null))
            {
                changed.Clear();
            }

            var indexCount = packet.ReadInt32();

            for (var i = 0; i < indexCount; ++i)
            {
                var index = packet.ReadInt32();

                if (_trees[index] == null)
                {
#if FARMATH
                    _trees[index] = new FarCollections.SpatialHashedQuadTree <int>(_maxEntriesPerNode, _minNodeBounds, 0.1f, 2f, (p, v) => p.Write(v), p => p.ReadInt32());
#else
                    _trees[index] = new DynamicQuadTree <int>(_maxEntriesPerNode, _minNodeBounds, 0.1f, 2f, (p, v) => p.Write(v), p => p.ReadInt32());
#endif
                }
                if (_changed[index] == null)
                {
                    _changed[index] = new HashSet <int>();
                }

                packet.ReadPacketizableInto(_trees[index]);

                var changedCount = packet.ReadInt32();
                for (var j = 0; j < changedCount; ++j)
                {
                    _changed[index].Add(packet.ReadInt32());
                }
            }
        }