Esempio n. 1
0
        // This puts a thing in the blockmap
        public void AddThing(Thing t)
        {
            Point            p     = GetBlockCoordinates(t.Position);
            VisualBlockEntry block = GetBlock(p);

            block.Things.Add(t);
        }
Esempio n. 2
0
        // This returns the block with the given coordinates
        // Creates the block if it doesn't exist yet
        public VisualBlockEntry GetBlock(Point p)
        {
            ulong k = GetBlockKey(p);

            if (blockmap.ContainsKey(k))
            {
                return(blockmap[k]);
            }
            else
            {
                return(blockmap[k] = new VisualBlockEntry());
            }
        }
Esempio n. 3
0
        // This puts a sector in the blockmap
        public void AddSector(Sector s)
        {
            Point p1 = GetBlockCoordinates(new Vector2D(s.BBox.Left, s.BBox.Top));
            Point p2 = GetBlockCoordinates(new Vector2D(s.BBox.Right, s.BBox.Bottom));

            for (int x = p1.X; x <= p2.X; x++)
            {
                for (int y = p1.Y; y <= p2.Y; y++)
                {
                    VisualBlockEntry block = GetBlock(new Point(x, y));
                    block.Sectors.Add(s);
                }
            }
        }