protected int FindObjectCore(int x, int y)
{
byte a;
int mask = (Game.Version <= 2) ? (int)ObjectStateV2.State8 : 0xF;
for (int i = 1; i < _objs.Length; i++)
{
if ((_objs[i].Number < 1) || GetClass(_objs[i].Number, ObjectClass.Untouchable))
continue;
if ((Game.Version == 0 && OBJECT_V0_TYPE(_objs[i].Number) == ObjectV0Type.Foreground) ||
(Game.Version > 0 && Game.Version <= 2))
{
if ((_objs[i].State & (byte)ObjectStateV2.Untouchable) != 0)
continue;
}
var b = i;
do
{
a = _objs[b].ParentState;
b = _objs[b].Parent;
if (b == 0)
{
if (_objs[i].Position.X <= x && (_objs[i].Width + _objs[i].Position.X) > x &&
_objs[i].Position.Y <= y && (_objs[i].Height + _objs[i].Position.Y) > y)
{
return _objs[i].Number;
}
break;
}
} while ((_objs[b].State & mask) == a);
}
return 0;
}