// Description: Spawn as close-to or on-top-of the 'trash item' as possible.
// Note1: you can for instance spawn atop a 'recall rune', but not a 'small crate'. This is because
// CanSpawnMobile() checks for the impassable flag when testing the destination point. the 'small crate' has impassable
// flags (i.e., you can't walk over it.) and the recall rune does not.
// Note2: When spawning a groundskeeper on a roof to pick up trash, you want the groundskeeper on the same Z and as close
// to the item as possible else they may be spawned over-the-edge placing them on the gtound and unable to pick up the item.
// It is for this reasons that we work so hard to place the groundskeeper as close to the 'trash' item as possible.
private static Point3D SpawnClose(Item ix, object o)
{
Point3D location;
// try 5 times at the same Z - starting close and moving outward
for (int ir = 0; ir < 5; ir++)
{
location = Spawner.GetSpawnPosition(ix.Map, ix.Location, ir, true, o);
if (location != ix.Location)
{
return(location);
}
}
// try 5 times at any Z - starting close and moving outward
for (int ir = 0; ir < 5; ir++)
{
location = Spawner.GetSpawnPosition(ix.Map, ix.Location, ir, false, o);
if (location != ix.Location)
{
return(location);
}
}
// give up
return(ix.Location);
}