public VMPlacementResult GetAvatarPlace(VMEntity target, LotTilePos pos, Direction dir)
{
//avatars cannot be placed in slots under any circumstances, so we skip a few steps.
VMObstacle footprint = target.GetObstacle(pos, dir);
ushort room = GetRoomAt(pos);
VMPlacementError status = VMPlacementError.Success;
VMEntity statusObj = null;
if (footprint == null || pos.Level < 1)
{
return new VMPlacementResult(status);
}
var objs = RoomInfo[room].Entities;
foreach (var obj in objs)
{
if (obj.MultitileGroup == target.MultitileGroup) continue;
var oFoot = obj.Footprint;
if (oFoot != null && oFoot.Intersects(footprint)
&& (!(target.ExecuteEntryPoint(5, this, true, obj, new short[] { obj.ObjectID, 0, 0, 0 })
|| obj.ExecuteEntryPoint(5, this, true, target, new short[] { target.ObjectID, 0, 0, 0 })))
)
{
var flags = (VMEntityFlags)obj.GetValue(VMStackObjectVariable.Flags);
bool allowAvatars = ((flags & VMEntityFlags.DisallowPersonIntersection) == 0) && ((flags & VMEntityFlags.AllowPersonIntersection) > 0);
if (!allowAvatars)
{
status = VMPlacementError.CantIntersectOtherObjects;
statusObj = obj;
if (obj.EntryPoints[26].ActionFunction != 0) break; //select chairs immediately.
}
}
}
return new VMPlacementResult(status, statusObj);
}