Пример #1
0
        /// <summary>
        /// Adds an area to the region and updates area-zone cache
        /// </summary>
        /// <param name="area"></param>
        /// <returns></returns>
        public virtual IArea AddArea(IArea area)
        {
            lock (m_lockAreas)
            {
                ushort nextAreaID = 0;

                foreach (ushort areaID in m_Areas.Keys)
                {
                    if (areaID >= nextAreaID)
                    {
                        nextAreaID = (ushort)(areaID + 1);
                    }
                }

                area.ID = nextAreaID;
                m_Areas.Add(area.ID, area);

                int zonePos = 0;
                foreach (Zone zone in Zones)
                {
                    if (area.IsIntersectingZone(zone))
                        m_ZoneAreas[zonePos][m_ZoneAreasCount[zonePos]++] = area.ID;

                    zonePos++;
                }
                return area;
            }
        }
Пример #2
0
		/// <summary>
		/// Adds an area to the region and updates area-zone cache
		/// </summary>
		/// <param name="area"></param>
		/// <returns></returns>
		public virtual IArea AddArea(IArea area)
		{
			lock (m_Areas.SyncRoot)
			{
				m_Areas.Add(area);
				area.ID = (ushort)(m_Areas.Count - 1);

				for (int i = 0; i < Zones.Count; i++)
				{
					Zone zone = (Zone)Zones[i];
					if (!area.IsIntersectingZone(zone))
						continue;

					m_ZoneAreas[i][m_ZoneAreasCount[i]++] = area.ID;
				}
				return area;
			}
		}