public void SpawnSeeker(bool addToList, string name) { if (currentLevel == null) { return; } if (currentLevel.Bounds.Width / 8 > 659 || currentLevel.Bounds.Height / 8 > 407) { return; } if (!extendedPathfinder) { extendedPathfinder = true; currentLevel.Pathfinder = new Pathfinder(currentLevel); } for (int i = 0; i < 100; i++) { int x = rand.Next(currentLevel.Bounds.Width) + currentLevel.Bounds.X; int y = rand.Next(currentLevel.Bounds.Height) + currentLevel.Bounds.Y; // should be at least 100 pixels from the player double playerDistance = Math.Sqrt(Math.Pow(MathHelper.Distance(x, ply.X), 2) + Math.Pow(MathHelper.Distance(y, ply.Y), 2)); // also check if we are not spawning in a wall, that would be a shame Rectangle collideRectangle = new Rectangle(x - 8, y - 8, 16, 16); if (playerDistance > 50 && !currentLevel.CollideCheck <Solid>(collideRectangle) && !currentLevel.CollideCheck <Seeker>(collideRectangle)) { // build a Seeker with a proper EntityID to make Speedrun Tool happy (this is useless in vanilla Celeste but the constructor call is intercepted by Speedrun Tool) EntityData seekerData = generateBasicEntityData(currentLevel, 10 + 1); seekerData.Position = new Vector2(x, y); Seeker seeker = new Seeker(seekerData, Vector2.Zero); SeekerName seekerName = new SeekerName(true, true, name); seeker.Add(seekerName); if (addToList) { spawnedSeekers.Add(seeker); } currentLevel.Add(seeker); break; } } }