예제 #1
0
        public GameObject Spawn(IWorldLocation where, Unit owner)
        {
            GameObject gameObject = GameObject.Create(this, where, FirstSpawnEntry, null);

            gameObject.Owner = owner;
            return(gameObject);
        }
예제 #2
0
        /// <summary>
        /// Creates a new GameObject with the given parameters
        /// </summary>
        public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
        {
            var go             = entry.GOCreator();
            var handlerCreator = entry.HandlerCreator;

            go.Init(entry, spawnEntry, spawnPoint);
            if (handlerCreator != null)
            {
                go.Handler = handlerCreator();
            }
            else
            {
                log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type);
                go.Delete();
                return(null);
            }
            go.Phase = where.Phase;
            var pos = where.Position;

            if (spawnPoint == null)
            {
                pos.Z = where.Map.Terrain.GetGroundHeightUnderneath(pos);
            }
            where.Map.AddObject(go, ref pos);

            go.MarkUpdate(GameObjectFields.DYNAMIC);
            return(go);
        }
예제 #3
0
        public GameObject Spawn(IWorldLocation where, Unit owner)
        {
            var go = GameObject.Create(this, where, FirstSpawnEntry);

            go.Owner = owner;
            return(go);
        }
예제 #4
0
        void CreatePortal(WorldObject at, IWorldLocation target)
        {
            // create portal
            var portal = Portal.Create(at, target);

            at.PlaceInFront(portal);
        }
예제 #5
0
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			var go = entry.GOCreator();
			var handlerCreator = entry.HandlerCreator;
			go.Init(entry, spawnEntry, spawnPoint);
			if (handlerCreator != null)
			{
				go.Handler = handlerCreator();
			}
			else
			{
				log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type);
				go.Delete();
				return null;
			}
			go.Phase = where.Phase;
			var pos = where.Position;
			if (spawnPoint == null)
			{
				pos.Z = where.Map.Terrain.GetGroundHeightUnderneath(pos);
			}
			where.Map.AddObject(go, ref pos);

			go.MarkUpdate(GameObjectFields.DYNAMIC);
			return go;
		}
예제 #6
0
        /// <summary>Creates a new GameObject with the given parameters</summary>
        public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null,
                                        GOSpawnPoint spawnPoint = null)
        {
            GameObject gameObject = entry.GOCreator();

            gameObject.GoId = entry.GOId;
            Func <GameObjectHandler> handlerCreator = entry.HandlerCreator;

            gameObject.Init(entry, spawnEntry, spawnPoint);
            if (handlerCreator != null)
            {
                gameObject.Handler = handlerCreator();
                gameObject.Phase   = where.Phase;
                Vector3 position = where.Position;
                if (spawnPoint == null)
                {
                    position.Z = where.Map.Terrain.GetGroundHeightUnderneath(position);
                }
                where.Map.AddObject(gameObject, ref position);
                gameObject.MarkUpdate(GameObjectFields.DYNAMIC);
                return(gameObject);
            }

            log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry,
                     entry.Type);
            gameObject.Delete();
            return(null);
        }
예제 #7
0
            private void SpawnMob(int x, int y, NPCEntry entry, IWorldLocation dest)
            {
                Vector3       pos           = new Vector3(dest.Position.X + x, dest.Position.Y + y);
                WorldLocation worldLocation = new WorldLocation(dest.Map, pos, 1U);

                entry.SpawnAt(worldLocation, false).Brain.State = BrainState.GmMove;
            }
        private void SpawnMob(int x, int y, uint npcId, IWorldLocation dest)
        {
            Vector3       pos           = new Vector3(dest.Position.X + x, dest.Position.Y + y);
            WorldLocation worldLocation = new WorldLocation(dest.Map, pos, 1U);

            NPCMgr.GetEntry(npcId).SpawnAt(worldLocation, false).Brain.State = BrainState.Roam;
        }
        private void SpawnMob(int x, int y, uint npcId, IWorldLocation dest)
        {
            var pos    = new Vector3(dest.Position.X + x, dest.Position.Y + y);
            var wl     = new WorldLocation(dest.Map, pos);
            var newNpc = NPCMgr.GetEntry(npcId).SpawnAt(wl);

            newNpc.Brain.State = BrainState.Roam;
        }
예제 #10
0
 public static bool IsValid(this IWorldLocation location)
 {
     if ((double)location.Position.X != 0.0 && location.Map != null)
     {
         return(location.Phase != 0U);
     }
     return(false);
 }
예제 #11
0
            private void SpawnMob(int x, int y, NPCEntry entry, IWorldLocation dest)
            {
                var pos    = new Vector3(dest.Position.X + x, dest.Position.Y + y);
                var wl     = new WorldLocation(dest.Map, pos);
                var newNpc = entry.SpawnAt(wl);

                newNpc.Brain.State = BrainState.GmMove;
            }
예제 #12
0
		/// <summary>
		/// Creates the given kind of GameObject with the default Template
		/// </summary>
		public static GameObject Create(GOEntryId id, IWorldLocation location, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			var entry = GOMgr.GetEntry(id);
			if (entry == null)
			{
				return null;
			}
			return Create(entry, location, spawnEntry, spawnPoint);
		}
예제 #13
0
        /// <summary>
        /// Creates the given kind of GameObject with the default Template
        /// </summary>
        public static GameObject Create(GOEntryId id, IWorldLocation location, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
        {
            var entry = GOMgr.GetEntry(id);

            if (entry == null)
            {
                return(null);
            }
            return(Create(entry, location, spawnEntry, spawnPoint));
        }
예제 #14
0
파일: Portal.cs 프로젝트: MeaNone/WCell
		public static Portal Create(IWorldLocation where, IWorldLocation target)
		{
			var entry = GOMgr.GetEntry(GOPortalEntry.PortalId);
			if (entry == null)
			{
				return null;
			}
			var portal = (Portal)Create(entry, where);
			portal.Target = target;
			return portal;
		}
예제 #15
0
 public static bool IsValid(this IWorldLocation location, Unit user)
 {
     if (location.Position.Equals(new Vector3()))
     {
         return(false);
     }
     if (location.Map == null)
     {
         return(user.Map.Id == location.MapId);
     }
     return(true);
 }
 private void IbrakoSummon(NPC npc, IWorldLocation dest)
 {
     if (npc.HealthPct < 40 && !npc.HelperBossSummoned)
     {
         npc.HelperBossSummoned = true;
         SpawnMob(2, 2, 752, dest);
     }
     else if (npc.HealthPct >= 40)
     {
         SpawnMob(-2, -2, 751, npc);
         SpawnMob(0, -2, 747, dest);
     }
 }
예제 #17
0
 /// <summary>
 /// Iterates over all objects of the given Type within the given radius around this object.
 /// </summary>
 /// <param name="radius"></param>
 /// <param name="predicate">Returns whether to continue iteration.</param>
 /// <returns>True, if iteration should continue (usually indicating that we did not find what we were looking for).</returns>
 public static bool IterateEnvironment <O>(this IWorldLocation location, float radius, Func <O, bool> predicate)
     where O : WorldObject
 {
     return(location.Map.IterateObjects(location.Position, radius, location.Phase,
                                        (Func <WorldObject, bool>)(obj =>
     {
         if (obj is O)
         {
             return predicate((O)obj);
         }
         return true;
     })));
 }
예제 #18
0
        public NPC SpawnAt(IWorldLocation loc, bool hugGround = false)
        {
            NPC     npc      = this.Create(loc.Map.DifficultyIndex);
            Vector3 position = loc.Position;

            if (hugGround && this.InhabitType == InhabitType.Ground)
            {
                position.Z = loc.Map.Terrain.GetGroundHeightUnderneath(position);
            }
            loc.Map.AddObject((WorldObject)npc, loc.Position);
            npc.Phase = loc.Phase;
            return(npc);
        }
예제 #19
0
        public static Portal Create(IWorldLocation where, IWorldLocation target)
        {
            GOEntry entry = GOMgr.GetEntry(GOEntryId.Portal, true);

            if (entry == null)
            {
                return(null);
            }
            Portal portal = (Portal)GameObject.Create(entry, where, null, null);

            portal.Target = target;
            return(portal);
        }
예제 #20
0
        public NPC SpawnAt(IWorldLocation loc, bool hugGround = false)
        {
            var npc = Create(loc.Map.DifficultyIndex);
            var pos = loc.Position;

            if (hugGround && InhabitType == InhabitType.Ground)
            {
                pos.Z = loc.Map.Terrain.GetGroundHeightUnderneath(pos);
            }
            loc.Map.AddObject(npc, loc.Position);
            npc.Phase = loc.Phase;
            return(npc);
        }
예제 #21
0
        public static Portal Create(IWorldLocation where, IWorldLocation target)
        {
            var entry = GOMgr.GetEntry(GOPortalEntry.PortalId);

            if (entry == null)
            {
                return(null);
            }
            var portal = (Portal)Create(entry, where);

            portal.Target = target;
            return(portal);
        }
예제 #22
0
        /// <summary>
        /// Spawns the pool to which the NPCSpawnEntry belongs which is closest to the given location
        /// </summary>
        public static NPCSpawnPoint SpawnClosestSpawnEntry(IWorldLocation pos)
        {
            var entry = GetClosestSpawnEntry(pos);

            if (entry != null)
            {
                var pool = pos.Map.AddNPCSpawnPoolNow(entry.PoolTemplate);
                if (pool != null)
                {
                    return(pool.GetSpawnPoint(entry));
                }
            }
            return(null);
        }
예제 #23
0
파일: NPCMgr.cs 프로젝트: uvbs/Asda2-Server
        /// <summary>
        /// Spawns the pool to which the NPCSpawnEntry belongs which is closest to the given location
        /// </summary>
        public static NPCSpawnPoint SpawnClosestSpawnEntry(IWorldLocation pos)
        {
            NPCSpawnEntry closestSpawnEntry = NPCMgr.GetClosestSpawnEntry(pos);

            if (closestSpawnEntry != null)
            {
                NPCSpawnPool npcSpawnPool = pos.Map.AddNPCSpawnPoolNow(closestSpawnEntry.PoolTemplate);
                if (npcSpawnPool != null)
                {
                    return(npcSpawnPool.GetSpawnPoint(closestSpawnEntry));
                }
            }

            return((NPCSpawnPoint)null);
        }
 private void KaiyaSummon(NPC npc, IWorldLocation dest)
 {
     if (npc.HealthPct < 40 && !npc.HelperBossSummoned)
     {
         npc.HelperBossSummoned = true;
         SpawnMob(2, 2, 511, dest); //hysteric kaiya
     }
     else if (npc.HealthPct >= 40)
     {
         SpawnMob(-2, -2, 324, dest);
         SpawnMob(-1, -2, 325, dest);
         SpawnMob(0, -2, 326, dest);
         SpawnMob(1, -2, 327, dest);
     }
 }
 private void IbrakoSummon(NPC npc, IWorldLocation dest)
 {
     if (npc.HealthPct < 40 && !npc.HelperBossSummoned)
     {
         npc.HelperBossSummoned = true;
         SpawnMob(2, 2, 752U, dest);
     }
     else
     {
         if (npc.HealthPct < 40)
         {
             return;
         }
         SpawnMob(-2, -2, 751U, npc);
         SpawnMob(0, -2, 747U, dest);
     }
 }
 private void BlackEagleSummon(NPC npc, IWorldLocation dest)
 {
     if (npc.HealthPct < 40 && !npc.HelperBossSummoned)
     {
         npc.HelperBossSummoned = true;
         SpawnMob(2, 2, 512, dest);
     }
     else if (npc.HealthPct >= 40)
     {
         SpawnMob(-2, -2, 392, npc);
         SpawnMob(-3, -2, 392, npc);
         SpawnMob(0, -2, 392, npc);
         SpawnMob(-1, -2, 392, npc);
         SpawnMob(0, -2, 377, dest);
         SpawnMob(1, -2, 377, dest);
     }
 }
예제 #27
0
        /// <summary>
        /// Returns the Unit that is closest within the given Radius around this Object
        /// TODO: Should add visibility test?
        /// </summary>
        public static Unit GetNearestUnit(this IWorldLocation wObj, float radius)
        {
            Unit unit   = null;
            var  sqDist = float.MaxValue;

            wObj.IterateEnvironment <Unit>(radius, obj =>
            {
                var curSqDist = obj.GetDistanceSq(wObj);
                if (curSqDist < sqDist)
                {
                    sqDist = curSqDist;
                    unit   = obj;
                }
                return(true);
            }
                                           );
            return(unit);
        }
예제 #28
0
        /// <summary>
        /// Returns the Unit that is closest within the given Radius around this Object
        /// TODO: Should add visibility test?
        /// </summary>
        public static Unit GetNearestUnit(this IWorldLocation wObj, float radius)
        {
            Unit  unit   = (Unit)null;
            float sqDist = float.MaxValue;

            wObj.IterateEnvironment <Unit>(radius, (Func <Unit, bool>)(obj =>
            {
                float distanceSq = obj.GetDistanceSq((IHasPosition)wObj);
                if ((double)distanceSq < (double)sqDist)
                {
                    sqDist = distanceSq;
                    unit   = obj;
                }

                return(true);
            }));
            return(unit);
        }
 private void KaiyaSummon(NPC npc, IWorldLocation dest)
 {
     if (npc.HealthPct < 40 && !npc.HelperBossSummoned)
     {
         npc.HelperBossSummoned = true;
         SpawnMob(2, 2, 511U, dest);
     }
     else
     {
         if (npc.HealthPct < 40)
         {
             return;
         }
         SpawnMob(-2, -2, 324U, dest);
         SpawnMob(-1, -2, 325U, dest);
         SpawnMob(0, -2, 326U, dest);
         SpawnMob(1, -2, 327U, dest);
     }
 }
예제 #30
0
        /// <summary>
        /// Returns the Unit that is closest within the given Radius around this Object and passes the filter
        /// </summary>
        public static Unit GetNearestUnit(this IWorldLocation wObj, float radius, Func <Unit, bool> filter)
        {
            Unit  target = (Unit)null;
            float sqDist = float.MaxValue;

            wObj.IterateEnvironment <Unit>(radius, (Func <Unit, bool>)(unit =>
            {
                if (filter(unit))
                {
                    float distanceSq = unit.GetDistanceSq((IHasPosition)wObj);
                    if ((double)distanceSq < (double)sqDist)
                    {
                        sqDist = distanceSq;
                        target = unit;
                    }
                }

                return(true);
            }));
            return(target);
        }
예제 #31
0
        /// <summary>
        /// Returns the Unit that is closest within the given Radius around this Object and passes the filter
        /// </summary>
        public static Unit GetNearestUnit(this IWorldLocation wObj, float radius, Func <Unit, bool> filter)
        {
            Unit target = null;
            var  sqDist = float.MaxValue;

            wObj.IterateEnvironment <Unit>(radius, unit =>
            {
                if (filter(unit))
                {
                    var curSqDist = unit.GetDistanceSq(wObj);
                    if (curSqDist < sqDist)
                    {
                        sqDist = curSqDist;
                        target = unit;
                    }
                }
                return(true);
            }
                                           );
            return(target);
        }
 private void BlackEagleSummon(NPC npc, IWorldLocation dest)
 {
     if (npc.HealthPct < 40 && !npc.HelperBossSummoned)
     {
         npc.HelperBossSummoned = true;
         this.SpawnMob(2, 2, 512U, dest);
     }
     else
     {
         if (npc.HealthPct < 40)
         {
             return;
         }
         this.SpawnMob(-2, -2, 392U, (IWorldLocation)npc);
         this.SpawnMob(-3, -2, 392U, (IWorldLocation)npc);
         this.SpawnMob(0, -2, 392U, (IWorldLocation)npc);
         this.SpawnMob(-1, -2, 392U, (IWorldLocation)npc);
         this.SpawnMob(0, -2, 377U, dest);
         this.SpawnMob(1, -2, 377U, dest);
     }
 }
예제 #33
0
파일: NPCMgr.cs 프로젝트: uvbs/Asda2-Server
        public static NPCSpawnEntry GetClosestSpawnEntry(IWorldLocation pos)
        {
            NPCSpawnEntry npcSpawnEntry = (NPCSpawnEntry)null;
            float         num1          = float.MaxValue;

            foreach (SpawnPoolTemplate <NPCSpawnPoolTemplate, NPCSpawnEntry, NPC, NPCSpawnPoint, NPCSpawnPool>
                     spawnPoolTemplate in NPCMgr.SpawnPoolsByMap[(int)pos.MapId])
            {
                foreach (NPCSpawnEntry entry in spawnPoolTemplate.Entries)
                {
                    if ((int)entry.Phase == (int)pos.Phase)
                    {
                        float num2 = pos.Position.DistanceSquared(entry.Position);
                        if ((double)num2 < (double)num1)
                        {
                            num1          = num2;
                            npcSpawnEntry = entry;
                        }
                    }
                }
            }

            return(npcSpawnEntry);
        }
예제 #34
0
파일: GOEntry.cs 프로젝트: ray2006/WCell
		public GameObject Spawn(IWorldLocation location, Unit owner)
		{
			var go = Create(owner);
			go.Position = location.Position;
			location.Region.AddObject(go);
			return go;
		}
예제 #35
0
		/// <summary>
		/// Teleports the owner to the given WorldObject.
		/// </summary>
		/// <param name="location"></param>
		/// <returns></returns>
		public bool TeleportTo(IWorldLocation location)
		{
			var pos = location.Position;
			var rgn = location.Region;
			if (rgn == null)
			{
				if (Region.Id != location.RegionId)
				{
					return false;
				}
				rgn = Region;
			}

			TeleportTo(rgn, ref pos, m_orientation);
			if (location is WorldObject)
			{
				Zone = ((WorldObject)location).Zone;
			}
			return true;
		}
예제 #36
0
파일: GOEntry.cs 프로젝트: ray2006/WCell
		/// <summary>
		/// Returns the GOTemplate of this entry that is closest to the given location
		/// </summary>
		public GOTemplate GetClosestTemplate(IWorldLocation pos)
		{
			return Templates.GetClosestTemplate(pos);
		}
예제 #37
0
		/// <summary>
		/// Spawns and returns a new GameObject from this template into the given region
		/// </summary>
		/// <returns>The newly spawned GameObject or null, if the Template has no Entry associated with it.</returns>
		public GameObject Spawn(IWorldLocation pos)
		{
			var go = GameObject.Create(Entry, this);
			go.Position = pos.Position;
			pos.Region.AddObject(go);
			return go;
		}
예제 #38
0
파일: NPCEntry.cs 프로젝트: WCellFR/WCellFR
		public NPC Create(IWorldLocation loc)
		{
			var npc = NPCCreator(this);
			npc.SetupNPC(this, null);
			loc.Region.AddObject(npc, loc.Position);
			return npc;
		}
예제 #39
0
        /// <summary>
        /// Teleports the owner to the given WorldObject.
        /// </summary>
        /// <param name="location"></param>
        /// <returns></returns>
        public bool TeleportTo(IWorldLocation location)
        {
            var pos = location.Position;
            var map = location.Map;
            if (map == null)
            {
                if (Map.Id != location.MapId)
                {
                    return false;
                }
                map = Map;
            }

            TeleportTo(map, ref pos, m_orientation);
            Phase = location.Phase;

            if (location is WorldObject)
            {
                Zone = ((WorldObject)location).Zone;
            }
            return true;
        }
예제 #40
0
파일: GOMgr.cs 프로젝트: remixod/netServer
		public static GOSpawnEntry GetClosestEntry(this ICollection<GOSpawnEntry> entries, IWorldLocation pos)
		{
			if (pos == null)
			{
				return entries.First();
			}

			var closestDistSq = float.MaxValue;
			GOSpawnEntry closest = null;
			foreach (var entry in entries)
			{
				if (entry.MapId != pos.MapId || entry.Phase != pos.Phase)
				{
					continue;
				}
				var distSq = pos.Position.DistanceSquared(entry.Position);
				if (distSq < closestDistSq)
				{
					closestDistSq = distSq;
					closest = entry;
				}
			}
			return closest;
		}
예제 #41
0
		public static void CreateTeleportNPC(NPCId id, IWorldLocation loc)
		{
			CreateTeleportNPC(id, loc.Position, loc.MapId, loc.Phase);
		}
예제 #42
0
		void CreatePortal(WorldObject at, IWorldLocation target)
		{
			// create portal
			var portal = Portal.Create(target);
			at.PlaceInFront(portal);
		}
예제 #43
0
파일: GOEntry.cs 프로젝트: MeaNone/WCell
		public GameObject Spawn(IWorldLocation where, Unit owner)
		{
			var go = GameObject.Create(this, where, FirstSpawnEntry);
			go.Owner = owner;
			return go;
		}
예제 #44
0
파일: GameObject.cs 프로젝트: MeaNone/WCell
		/// <summary>
		/// Creates a new GameObject with the given parameters
		/// </summary>
		public static GameObject Create(GOEntry entry, IWorldLocation where, GOSpawnEntry spawnEntry = null, GOSpawnPoint spawnPoint = null)
		{
			var go = entry.GOCreator();
			var handlerCreator = entry.HandlerCreator;
			go.Init(entry, spawnEntry, spawnPoint);
			if (handlerCreator != null)
			{
				go.Handler = handlerCreator();
			}
			else
			{
				log.Warn("GOEntry {0} did not have a HandlerCreator set - Type: {1}", entry, entry.Type);
				go.Delete();
				return null;
			}
			go.Phase = where.Phase;
			var pos = where.Position;
			where.Map.AddObject(go, ref pos);
			return go;
		}
예제 #45
0
파일: Portal.cs 프로젝트: Zakkgard/WCell
 protected Portal(IWorldLocation target)
 {
     Target = target;
 }
예제 #46
0
파일: NPCs.cs 프로젝트: ray2006/WCell
		public static void CreateTeleportNPC(NPCId id, IWorldLocation loc)
		{
			CreateTeleportNPC(id, loc.Position, loc.RegionId);
		}
예제 #47
0
		public NPC SpawnAt(IWorldLocation loc, bool hugGround = false)
		{
			var npc = Create(loc.Map.DifficultyIndex);
			var pos = loc.Position;
			if (hugGround && InhabitType == InhabitType.Ground)
			{
				pos.Z = loc.Map.Terrain.GetGroundHeightUnderneath(pos);
			}
			loc.Map.AddObject(npc, loc.Position);
			npc.Phase = loc.Phase;
			return npc;
		}
예제 #48
0
파일: NPCEntry.cs 프로젝트: MeaNone/WCell
		public NPC SpawnAt(IWorldLocation loc)
		{
			var npc = Create(loc.Map.DifficultyIndex);
			loc.Map.AddObject(npc, loc.Position);
			npc.Phase = loc.Phase;
			return npc;
		}
예제 #49
0
파일: GOEntry.cs 프로젝트: MeaNone/WCell
		public GameObject Spawn(IWorldLocation location)
		{
			return Spawn(location, location as Unit);
		}
예제 #50
0
		/// <summary>
		/// Summons the dropped flag.
		/// </summary>
		/// <param name="location">The target location (can [and should] be a unit)</param>
		public void SummonDroppedFlag(IWorldLocation location)
		{
			_flag = DroppedFlagEntry.Spawn(location, null); // Flags never have an owner.
		}
예제 #51
0
파일: GOEntry.cs 프로젝트: MeaNone/WCell
		/// <summary>
		/// Returns the GOTemplate of this entry that is closest to the given location
		/// </summary>
		public GOSpawnEntry GetClosestTemplate(IWorldLocation pos)
		{
			return SpawnEntries.GetClosestEntry(pos);
		}
예제 #52
0
파일: GOMgr.cs 프로젝트: NVN/WCell
		public static GOSpawn GetClosestTemplate(this ICollection<GOSpawn> templates, IWorldLocation pos)
		{
			var closestDistSq = float.MaxValue;
			GOSpawn closest = null;
			if (pos == null)
			{
				return templates.First();
			}

			foreach (var template in templates)
			{
				if (template == null || template.RegionId != pos.RegionId)
				{
					continue;
				}

				var distSq = pos.Position.DistanceSquared(template.Pos);
				if (distSq < closestDistSq)
				{
					closestDistSq = distSq;
					closest = template;
				}
			}
			return closest;
		}
예제 #53
0
파일: GOMgr.cs 프로젝트: remixod/netServer
		public static GOSpawnEntry GetClosestEntry(this ICollection<GOSpawnPoolTemplate> templates, IWorldLocation pos)
		{
			if (pos == null)
			{
				return templates.First().Entries.FirstOrDefault();
			}

			var closestDistSq = float.MaxValue;
			GOSpawnEntry closest = null;
			foreach (var template in templates)
			{
				if (template == null || template.MapId != pos.MapId)
				{
					continue;
				}

				foreach (var entry in template.Entries)
				{
					if (entry.Phase != pos.Phase) continue;

					var distSq = pos.Position.DistanceSquared(entry.Position);
					if (distSq < closestDistSq)
					{
						closestDistSq = distSq;
						closest = entry;
					}
				}
			}
			return closest;
		}
예제 #54
0
파일: NPCEntry.cs 프로젝트: NVN/WCell
		public NPC SpawnAt(IWorldLocation loc)
		{
			var npc = Create(loc.Region.DifficultyIndex);
			npc.SetupNPC(this, null);
			loc.Region.AddObject(npc, loc.Position);
			return npc;
		}