Esempio n. 1
0
        public void Register()
        {
            if (m_Registered)
            {
                return;
            }

            OnRegister();

            m_Registered = true;

            if (m_Parent != null)
            {
                m_Parent.m_Children.Add(this);
                m_Parent.OnChildAdded(this);
            }

            m_Regions.Add(this);

            m_Map.RegisterRegion(this);

            List <Sector> sectors = new List <Sector>();

            for (int i = 0; i < m_Area.Length; i++)
            {
                Rectangle3D rect = m_Area[i];

                Point2D start = m_Map.Bound(new Point2D(rect.Start));
                Point2D end   = m_Map.Bound(new Point2D(rect.End));

                Sector startSector = m_Map.GetSector(start);
                Sector endSector   = m_Map.GetSector(end);

                for (int x = startSector.X; x <= endSector.X; x++)
                {
                    for (int y = startSector.Y; y <= endSector.Y; y++)
                    {
                        Sector sector = m_Map.GetRealSector(x, y);

                        sector.OnEnter(this, rect);

                        if (!sectors.Contains(sector))
                        {
                            sectors.Add(sector);
                        }
                    }
                }
            }

            m_Sectors = sectors.ToArray();
        }