197 {
198 float num = float.MaxValue;
199 int nearestNPCIndex = -1;
200 float num2 = float.MaxValue;
201 float nearestTankDistance = float.MaxValue;
202 int nearestTankIndex = -1;
203 TargetType tankType = TargetType.Player;
205 {
206 for (
int i = 0;
i < 200;
i++)
207 {
208 NPC nPC = Main.npc[
i];
209 if (nPC.active && nPC.whoAmI != searcher.whoAmI && (npcFilter == null || npcFilter(nPC)))
210 {
212 if (num3 < num)
213 {
215 num = num3;
216 }
217 }
218 }
219 }
221 {
222 for (int j = 0; j < 255; j++)
223 {
224 Player player = Main.player[j];
225 if (!player.active || player.dead || player.ghost || (playerFilter != null && !playerFilter(player)))
226 {
227 continue;
228 }
230 float num5 = num4 - (float)player.aggro;
231 bool flag = searcher != null && player.npcTypeNoAggro[searcher.type];
232 if (searcher != null && flag && searcher.direction == 0)
233 {
234 num5 += 1000f;
235 }
236 if (num5 < num2)
237 {
238 nearestTankIndex = j;
239 num2 = num5;
240 nearestTankDistance = num4;
241 tankType = TargetType.Player;
242 }
243 if (player.tankPet >= 0 && !flag)
244 {
245 Vector2 center = Main.projectile[player.tankPet].Center;
247 num5 = num4 - 200f;
248 if (num5 < num2 && num5 < 200f && Collision.CanHit(position, 0, 0, center, 0, 0))
249 {
250 nearestTankIndex = j;
251 num2 = num5;
252 nearestTankDistance = num4;
253 tankType = TargetType.TankPet;
254 }
255 }
256 }
257 }
258 return new TargetSearchResults(searcher, nearestNPCIndex, (
float)
Math.
Sqrt(num), nearestTankIndex, nearestTankDistance, num2, tankType);
259 }
static double Sqrt(double d)
static float DistanceSquared(Vector2 value1, Vector2 value2)
static float Distance(Vector2 value1, Vector2 value2)