Ejemplo n.º 1
0
 public void GetStats(object obj, out int z, out int treshold, out int type, out int tiebreaker)
 {
     if (obj is MobileCell)
     {
         MobileCell mobileCell = (MobileCell)obj;
         z        = (int)mobileCell.Z;
         treshold = 2;
         type     = 3;
         if (mobileCell.m_Mobile.Player)
         {
             tiebreaker = 1073741824;
         }
         else
         {
             tiebreaker = mobileCell.Serial;
         }
     }
     else if (obj is LandTile)
     {
         LandTile landTile = (LandTile)obj;
         z          = (int)landTile.SortZ;
         treshold   = 0;
         type       = 0;
         tiebreaker = 0;
     }
     else if (obj is DynamicItem)
     {
         DynamicItem dynamicItem = (DynamicItem)obj;
         z = (int)dynamicItem.Z;
         int num = !Map.m_ItemFlags[(int)dynamicItem.ID & 16383][(TileFlag)1L] ? 1 : 0;
         treshold   = (int)dynamicItem.Height == 0 ? num : num + 1;
         type       = ((int)dynamicItem.ID & 16383) == 8198 ? 4 : 2;
         tiebreaker = dynamicItem.Serial;
     }
     else if (obj is StaticItem)
     {
         StaticItem staticItem = (StaticItem)obj;
         z = (int)staticItem.Z;
         int num = !Map.m_ItemFlags[(int)staticItem.ID & 16383][(TileFlag)1L] ? 1 : 0;
         treshold   = (int)staticItem.Height == 0 ? num : num + 1;
         type       = 1;
         tiebreaker = staticItem.m_SortInfluence;
     }
     else
     {
         z          = 0;
         treshold   = 0;
         type       = 0;
         tiebreaker = 0;
     }
 }
Ejemplo n.º 2
0
        public static bool CanFit(int x, int y, int z, int height, bool checkMobiles, bool requireSurface)
        {
            MapPackage cache  = Map.GetCache();
            int        index1 = x - cache.CellX;
            int        index2 = y - cache.CellY;

            if (index1 < 0 || index2 < 0 || (index1 >= Renderer.cellWidth || index2 >= Renderer.cellHeight))
            {
                return(false);
            }
            bool      flag1     = !requireSurface;
            ArrayList arrayList = cache.cells[index1, index2];

            for (int index3 = 0; index3 < arrayList.Count; ++index3)
            {
                object obj = arrayList[index3];
                if (obj is LandTile)
                {
                    LandTile landTile = obj as LandTile;
                    int      z1       = 0;
                    int      avg      = 0;
                    int      top      = 0;
                    Map.GetAverageZ(x, y, ref z1, ref avg, ref top);
                    TileFlags landFlags = Map.GetLandFlags((int)landTile.ID & 16383);
                    if (landFlags[(TileFlag)64L] && avg > z && z + height > z1)
                    {
                        return(false);
                    }
                    if (!landFlags[(TileFlag)64L] && z == avg && !landTile.Ignored)
                    {
                        flag1 = true;
                    }
                }
                else if (obj is StaticItem)
                {
                    StaticItem staticItem = obj as StaticItem;
                    TileFlags  tileFlags  = Map.m_ItemFlags[(int)staticItem.ID & 16383];
                    bool       flag2      = tileFlags[(TileFlag)512L];
                    bool       flag3      = tileFlags[(TileFlag)64L];
                    if ((flag2 || flag3) && ((int)staticItem.Z + (int)staticItem.CalcHeight > z && z + height > (int)staticItem.Z))
                    {
                        return(false);
                    }
                    if (flag2 && !flag3 && z == (int)staticItem.Z + (int)staticItem.CalcHeight)
                    {
                        flag1 = true;
                    }
                }
                else if (obj is DynamicItem)
                {
                    DynamicItem dynamicItem = obj as DynamicItem;
                    TileFlags   tileFlags   = Map.m_ItemFlags[(int)dynamicItem.ID & 16383];
                    bool        flag2       = tileFlags[(TileFlag)512L];
                    bool        flag3       = tileFlags[(TileFlag)64L];
                    if ((flag2 || flag3) && ((int)dynamicItem.Z + (int)dynamicItem.CalcHeight > z && z + height > (int)dynamicItem.Z))
                    {
                        return(false);
                    }
                    if (flag2 && !flag3 && z == (int)dynamicItem.Z + (int)dynamicItem.CalcHeight)
                    {
                        flag1 = true;
                    }
                }
                else if (checkMobiles && obj is MobileCell)
                {
                    MobileCell mobileCell = obj as MobileCell;
                    if ((int)mobileCell.Z + 16 > z && z + (int)mobileCell.Height > (int)mobileCell.Z)
                    {
                        return(false);
                    }
                }
            }
            return(flag1);
        }