コード例 #1
0
 /// <summary>
 /// Checks wether area intersects with given zone
 /// </summary>
 /// <param name="zone"></param>
 /// <returns></returns>
 public abstract bool IsIntersectingZone(Zone zone);
コード例 #2
0
		/// <summary>
		/// Gets the areas for a certain spot
		/// </summary>
		/// <param name="zone"></param>
		/// <param name="p"></param>
		/// <param name="checkZ"></param>
		/// <returns></returns>
		public override IList<IArea> GetAreasOfZone(Zone zone, IPoint3D p, bool checkZ)
		{
			Zone checkZone = zone;
			var areas = new List<IArea>();

			if (checkZone == null)
			{
				return areas;
			}

			// Players will always request the skinned zone so map it to the actual instance zone
			if (m_zoneSkinMap.ContainsKey(zone.ID))
			{
				checkZone = m_zoneSkinMap[zone.ID];
			}

			int zoneIndex = Zones.IndexOf(checkZone);

			if (zoneIndex >= 0)
			{
				lock (m_lockAreas)
				{
					try
					{
						for (int i = 0; i < m_ZoneAreasCount[zoneIndex]; i++)
						{
							IArea area = (IArea)Areas[m_ZoneAreas[zoneIndex][i]];
							if (area.IsContaining(p, checkZ))
							{
								areas.Add(area);
							}
						}
					}
					catch (Exception e)
					{
						log.Error("GetAreaOfZone: Caught exception for Zone " + zone.Description + ", Area count " + m_ZoneAreasCount[zoneIndex] + ".", e);
					}
				}
			}

			return areas;
		}
コード例 #3
0
ファイル: Instance.cs プロジェクト: Refizul/DOL-Kheldron
		public override IList GetAreasOfZone(Zone zone, int x, int y, int z)
		{
			Zone checkZone = zone;
			IList areas = new ArrayList();

			if (checkZone == null)
			{
				return areas;
			}

			// Players will always request the skinned zone so map it to the actual instance zone
			if (m_zoneSkinMap.ContainsKey(zone.ID))
			{
				checkZone = m_zoneSkinMap[zone.ID];
			}

			int zoneIndex = Zones.IndexOf(checkZone);

			if (zoneIndex >= 0)
			{
				lock (m_Areas.SyncRoot)
				{
					try
					{
						for (int i = 0; i < m_ZoneAreasCount[zoneIndex]; i++)
						{
							IArea area = (IArea)m_Areas[m_ZoneAreas[zoneIndex][i]];
							if (area.IsContaining(x, y, z))
								areas.Add(area);
						}
					}
					catch (Exception e)
					{
						log.Error("GetArea exception.Area count " + m_ZoneAreasCount[zoneIndex], e);
					}
				}
			}

			return areas;
		}
コード例 #4
0
ファイル: Area.cs プロジェクト: uvbs/Dawn-of-Light-core
            /// <summary>
            /// Checks wether area intersects with given zone
            /// </summary>
            /// <param name="zone"></param>
            /// <returns></returns>
            public override bool IsIntersectingZone(Zone zone)
            {
                if (X + Width < zone.XOffset)
                    return false;
                if (X - Width >= zone.XOffset + 65536)
                    return false;
                if (Y + Height < zone.YOffset)
                    return false;
                if (Y - Height >= zone.YOffset + 65536)
                    return false;

                return true;
            }
コード例 #5
0
ファイル: Area.cs プロジェクト: uvbs/Dawn-of-Light-core
            /// <summary>
            /// Checks wether area intersects with given zone
            /// </summary>
            /// <param name="zone"></param>
            /// <returns></returns>
            public override bool IsIntersectingZone(Zone zone)
            {
                // TODO if needed
                if (X + Radius < zone.XOffset)
                    return false;
                if (X - Radius >= zone.XOffset + 65536)
                    return false;
                if (Y + Radius < zone.YOffset)
                    return false;
                if (Y - Radius >= zone.YOffset + 65536)
                    return false;

                return true;
            }
コード例 #6
0
ファイル: Region.cs プロジェクト: mynew4/DAoC
 public virtual IList GetAreasOfZone(Zone zone, IPoint3D p)
 {
     return GetAreasOfZone(zone, p, true);
 }
コード例 #7
0
ファイル: Region.cs プロジェクト: mynew4/DAoC
        public virtual IList GetAreasOfZone(Zone zone, int x, int y, int z)
        {
            lock (m_lockAreas)
            {
                int zoneIndex = Zones.IndexOf(zone);
                IList areas = new ArrayList();

                if (zoneIndex >= 0)
                {
                    try
                    {
                        for (int i = 0; i < m_ZoneAreasCount[zoneIndex]; i++)
                        {
                            IArea area = (IArea)m_Areas[m_ZoneAreas[zoneIndex][i]];
                            if (area.IsContaining(x, y, z))
                                areas.Add(area);
                        }
                    }
                    catch (Exception e)
                    {
                        log.Error("GetArea exception.Area count " + m_ZoneAreasCount[zoneIndex], e);
                    }
                }
                return areas;
            }
        }
コード例 #8
0
ファイル: Region.cs プロジェクト: mynew4/DAoC
        /// <summary>
        /// Gets objects in a radius around a point
        /// </summary>
        /// <param name="type">OBJECT_TYPE (0=item, 1=npc, 2=player)</param>
        /// <param name="x">origin X</param>
        /// <param name="y">origin Y</param>
        /// <param name="z">origin Z</param>
        /// <param name="radius">radius around origin</param>
        /// <param name="withDistance">Get an ObjectDistance enumerator</param>
        /// <returns>IEnumerable to be used with foreach</returns>
        protected IEnumerable GetInRadius(Zone.eGameObjectType type, int x, int y, int z, ushort radius, bool withDistance, bool ignoreZ)
        {
            // check if we are around borders of a zone
            Zone startingZone = GetZone(x, y);

            if (startingZone != null)
            {
                ArrayList res = startingZone.GetObjectsInRadius(type, x, y, z, radius, new ArrayList(), ignoreZ);

                uint sqRadius = (uint)radius * radius;

                foreach (var currentZone in m_zones)
                {
                    if ((currentZone != startingZone)
                        && (currentZone.TotalNumberOfObjects > 0)
                        && CheckShortestDistance(currentZone, x, y, sqRadius))
                    {
                        res = currentZone.GetObjectsInRadius(type, x, y, z, radius, res, ignoreZ);
                    }
                }

                //Return required enumerator
                IEnumerable tmp = null;
                if (withDistance)
                {
                    switch (type)
                    {
                        case Zone.eGameObjectType.ITEM:
                            tmp = new ItemDistanceEnumerator(x, y, z, res);
                            break;
                        case Zone.eGameObjectType.NPC:
                            tmp = new NPCDistanceEnumerator(x, y, z, res);
                            break;
                        case Zone.eGameObjectType.PLAYER:
                            tmp = new PlayerDistanceEnumerator(x, y, z, res);
                            break;
                        case Zone.eGameObjectType.DOOR:
                            tmp = new DoorDistanceEnumerator(x, y, z, res);
                            break;
                        default:
                            tmp = new EmptyEnumerator();
                            break;
                    }
                }
                else
                {
                    tmp = new ObjectEnumerator(res);
                }
                return tmp;
            }
            else
            {
                if (log.IsDebugEnabled)
                {
                    log.Error("GetInRadius starting zone is null for (" + type + ", " + x + ", " + y + ", " + z + ", " + radius + ") in Region ID=" + ID);
                }
                return new EmptyEnumerator();
            }
        }
コード例 #9
0
ファイル: Region.cs プロジェクト: mynew4/DAoC
        /// <summary>
        /// get the shortest distance from a point to a zone
        /// </summary>
        /// <param name="zone">The zone to check</param>
        /// <param name="x">X value of the point</param>
        /// <param name="y">Y value of the point</param>
        /// <param name="squareRadius">The square radius to compare the distance with</param>
        /// <returns>True if the distance is shorter false either</returns>
        private static bool CheckShortestDistance(Zone zone, int x, int y, uint squareRadius)
        {
            //  coordinates of zone borders
            int xLeft = zone.XOffset;
            int xRight = zone.XOffset + zone.Width;
            int yTop = zone.YOffset;
            int yBottom = zone.YOffset + zone.Height;
            long distance = 0;

            if ((y >= yTop) && (y <= yBottom))
            {
                int xdiff = Math.Min(FastMath.Abs(x - xLeft), FastMath.Abs(x - xRight));
                distance = (long)xdiff * xdiff;
            }
            else
            {
                if ((x >= xLeft) && (x <= xRight))
                {
                    int ydiff = Math.Min(FastMath.Abs(y - yTop), FastMath.Abs(y - yBottom));
                    distance = (long)ydiff * ydiff;
                }
                else
                {
                    int xdiff = Math.Min(FastMath.Abs(x - xLeft), FastMath.Abs(x - xRight));
                    int ydiff = Math.Min(FastMath.Abs(y - yTop), FastMath.Abs(y - yBottom));
                    distance = (long)xdiff * xdiff + (long)ydiff * ydiff;
                }
            }

            return (distance <= squareRadius);
        }
コード例 #10
0
        /// <summary>
        /// Gets the areas for a certain spot
        /// </summary>
        /// <param name="zone"></param>
        /// <param name="p"></param>
        /// <param name="checkZ"></param>
        /// <returns></returns>
        public virtual IList<IArea> GetAreasOfZone(Zone zone, IPoint3D p, bool checkZ)
        {
            lock (m_lockAreas)
            {
                int zoneIndex = Zones.IndexOf(zone);
                var areas = new List<IArea>();

                if (zoneIndex >= 0)
                {
                    try
                    {
                        for (int i = 0; i < m_ZoneAreasCount[zoneIndex]; i++)
                        {
                            IArea area = (IArea)m_Areas[m_ZoneAreas[zoneIndex][i]];
                            if (area.IsContaining(p, checkZ))
                            {
                                areas.Add(area);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        log.Error("GetArea exception.Area count " + m_ZoneAreasCount[zoneIndex], e);
                    }
                }

                return areas;
            }
        }
コード例 #11
0
ファイル: WorldMgr.cs プロジェクト: Refizul/DOL-Kheldron
		/// <summary>
		/// Registers a Zone into a Region
		/// </summary>
		public static void RegisterZone(ZoneData zoneData, ushort zoneID, ushort regionID, string zoneName, int xpBonus, int rpBonus, int bpBonus, int coinBonus, byte realm)
		{
			Region region = GetRegion(regionID);
			if (region == null)
			{
				if (log.IsWarnEnabled)
				{
					log.Warn("Could not find Region " + regionID + " for Zone " + zoneData.Description);
				}
				return;
			}
			
			// Making an assumption that a zone waterlevel of 0 means it is not set and we should use the regions waterlevel - Tolakram
			if (zoneData.WaterLevel == 0)
			{
				zoneData.WaterLevel = region.WaterLevel;
			}

			bool isDivingEnabled = region.IsRegionDivingEnabled;

			if (zoneData.DivingFlag == 1)
				isDivingEnabled = true;
			else if (zoneData.DivingFlag == 2)
				isDivingEnabled = false;
			
			Zone zone = new Zone(region,
			                     zoneID,
			                     zoneName,
			                     zoneData.OffX * 8192,
			                     zoneData.OffY * 8192,
			                     zoneData.Width * 8192,
			                     zoneData.Height * 8192,
			                     zoneData.ZoneID,
			                     isDivingEnabled,
			                     zoneData.WaterLevel,
			                     zoneData.IsLava,
			                     xpBonus,
			                     rpBonus,
			                     bpBonus,
			                     coinBonus,
			                     realm);

			//Dinberg:Instances
			//ZoneID will always be constant as last parameter, because ZoneSkinID will effectively be a bluff, to remember
			//the original region that spawned this one!

			/*reg,
                    zoneID,
                    desc,
                    offx * 8192,
                    offy * 8192,
                    width * 8192,
                    height * 8192);*/

			lock (region.Zones.SyncRoot)
			{
				region.Zones.Add(zone);
			}
			lock (m_zones.SyncRoot)
			{
				m_zones.Add(zoneID, zone);
			}

			log.Info("Added a zone, " + zoneData.Description + ", to region " + region.Name);
		}
コード例 #12
0
 public bool HasNavmesh(Zone zone)
 {
     return(false);
 }
コード例 #13
0
 public Task <Vector3?> GetClosestPointAsync(Zone zone, Vector3 position, float xRange = 256, float yRange = 256, float zRange = 256)
 {
     return(Task.FromResult <Vector3?>(position));
 }
コード例 #14
0
 public Task <Vector3?> GetRandomPointAsync(Zone zone, Vector3 position, float radius)
 {
     return(Task.FromResult <Vector3?>(null));
 }