public static bool CanMoveFrom(this IEnvironmentObject env, IntVector3 srcLoc, Direction dir)
{
Debug.Assert(dir.IsValid());
if (env.Contains(srcLoc) == false)
return false;
var td = env.GetTileData(srcLoc);
if (td.IsUndefined)
return false;
// Perhaps this check is not needed
if (td.IsWalkable == false)
return false;
if (dir.IsPlanar())
return true;
if (dir == Direction.Up)
return td.ID == TileID.Stairs;
if (dir == Direction.Down)
return true;
if (dir.ContainsDown())
{
return true;
}
if (dir.ContainsUp() && env.Size.Depth > srcLoc.Z + 1)
{
if (env.GetTileData(srcLoc.Up).IsEmpty == false)
return false;
return true;
}
return false;
}