예제 #1
0
파일: Map.cs 프로젝트: FreeReign/xrunuo
        public bool CanFit(int x, int y, int z, int height, bool checkBlocksFit, bool checkMobiles, bool requireSurface)
        {
            if (this == Map.Internal)
            {
                return(false);
            }

            if (x < 0 || y < 0 || x >= m_Width || y >= m_Height)
            {
                return(false);
            }

            bool hasSurface = false;

            Tile lt = Tiles.GetLandTile(x, y);
            int  lowZ = 0, avgZ = 0, topZ = 0;

            GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ);
            TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;

            if ((landFlags & TileFlag.Impassable) != 0 && avgZ > z && (z + height) > lowZ)
            {
                return(false);
            }
            else if ((landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored)
            {
                hasSurface = true;
            }

            Tile[] staticTiles = Tiles.GetStaticTiles(x, y, true);

            bool surface, impassable;

            for (int i = 0; i < staticTiles.Length; ++i)
            {
                ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];
                surface    = id.Surface;
                impassable = id.Impassable;

                if ((surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + height) > staticTiles[i].Z)
                {
                    return(false);
                }
                else if (surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight))
                {
                    hasSurface = true;
                }
            }

            Sector        sector = GetSector(x, y);
            List <Item>   items  = sector.Items;
            List <Mobile> mobs   = sector.Mobiles;

            for (int i = 0; i < items.Count; ++i)
            {
                Item item = items[i];

                if (!(item is BaseMulti) && item.ItemID <= TileData.MaxItemValue && item.AtWorldPoint(x, y))
                {
                    ItemData id = item.ItemData;
                    surface    = id.Surface;
                    impassable = id.Impassable;

                    if ((surface || impassable || (checkBlocksFit && item.BlocksFit)) && (item.Z + id.CalcHeight) > z && (z + height) > item.Z)
                    {
                        return(false);
                    }
                    else if (surface && !impassable && !item.Movable && z == (item.Z + id.CalcHeight))
                    {
                        hasSurface = true;
                    }
                }
            }

            if (checkMobiles)
            {
                for (int i = 0; i < mobs.Count; ++i)
                {
                    Mobile m = mobs[i];

                    if (m.Location.X == x && m.Location.Y == y && m.Alive && (m.AccessLevel == AccessLevel.Player || !m.Hidden))
                    {
                        if ((m.Z + 16) > z && (z + height) > m.Z)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(!requireSurface || hasSurface);
        }
예제 #2
0
        private static bool CanFit(Map map, int x, int y, int z)
        {
            bool hasSurface = false;

            LandTile lt = map.Tiles.GetLandTile(x, y);
            int      lowZ = 0, avgZ = 0, topZ = 0;

            map.GetAverageZ(x, y, ref lowZ, ref avgZ, ref topZ);
            TileFlag landFlags = TileData.LandTable[lt.ID & TileData.MaxLandValue].Flags;

            if ((landFlags & TileFlag.Impassable) != 0 && topZ > z && (z + 16) > lowZ)
            {
                return(false);
            }
            else if ((landFlags & TileFlag.Impassable) == 0 && z == avgZ && !lt.Ignored)
            {
                hasSurface = true;
            }

            StaticTile[] staticTiles = map.Tiles.GetStaticTiles(x, y);

            bool surface, impassable;

            for (int i = 0; i < staticTiles.Length; ++i)
            {
                if (IsDisplayCase(staticTiles[i].ID))
                {
                    continue;
                }

                ItemData id = TileData.ItemTable[staticTiles[i].ID & TileData.MaxItemValue];

                surface    = id.Surface;
                impassable = id.Impassable;

                if ((surface || impassable) && (staticTiles[i].Z + id.CalcHeight) > z && (z + 16) > staticTiles[i].Z)
                {
                    return(false);
                }
                else if (surface && !impassable && z == (staticTiles[i].Z + id.CalcHeight))
                {
                    hasSurface = true;
                }
            }

            Sector      sector = map.GetSector(x, y);
            List <Item> items  = sector.Items;

            for (int i = 0; i < items.Count; ++i)
            {
                Item item = items[i];

                if (item.AtWorldPoint(x, y))
                {
                    ItemData id = item.ItemData;
                    surface    = id.Surface;
                    impassable = id.Impassable;

                    if ((surface || impassable) && (item.Z + id.CalcHeight) > z && (z + 16) > item.Z)
                    {
                        return(false);
                    }
                    else if (surface && !impassable && z == (item.Z + id.CalcHeight))
                    {
                        hasSurface = true;
                    }
                }
            }

            return(hasSurface);
        }