Beispiel #1
0
 public static void Initialize(LandTile t, short id, sbyte z)
 {
     t.m_ID            = id;
     t.m_ID            = (short)(t.m_ID & 0x3fff);
     t.m_ID            = (short)TextureTable.m_Table[t.m_ID];
     t.m_SortZ         = t.m_Z = z;
     t.m_bDraw         = false;
     t.m_bInit         = false;
     t.m_bFilter       = false;
     t.m_Height        = 0;
     t.m_sDraw         = null;
     t.m_Guarded       = false;
     t.m_FoldLeftRight = false;
 }
Beispiel #2
0
 public static unsafe void Initialize(LandTile t, byte *pSrc)
 {
     t.m_ID            = *((short *)pSrc);
     t.m_ID            = (short)(t.m_ID & 0x3fff);
     t.m_ID            = (short)TextureTable.m_Table[t.m_ID];
     t.m_SortZ         = t.m_Z = *((sbyte *)(pSrc + 2));
     t.m_bDraw         = false;
     t.m_bInit         = false;
     t.m_bFilter       = false;
     t.m_Height        = 0;
     t.m_sDraw         = null;
     t.m_Guarded       = false;
     t.m_FoldLeftRight = false;
 }
Beispiel #3
0
 public void GetStats(object obj, out int z, out int treshold, out int type, out int tiebreaker)
 {
     if (obj is MobileCell)
     {
         MobileCell cell = (MobileCell)obj;
         z        = cell.Z;
         treshold = 2;
         type     = 3;
         if (cell.m_Mobile.Player)
         {
             tiebreaker = 0x40000000;
         }
         else
         {
             tiebreaker = cell.Serial;
         }
     }
     else if (obj is LandTile)
     {
         LandTile tile = (LandTile)obj;
         z          = tile.SortZ;
         treshold   = 0;
         type       = 0;
         tiebreaker = 0;
     }
     else if (obj is DynamicItem)
     {
         int         num;
         DynamicItem item = (DynamicItem)obj;
         z = item.Z;
         if (Map.m_ItemFlags[item.ID & 0x3fff][TileFlag.Background])
         {
             num = 0;
         }
         else
         {
             num = 1;
         }
         treshold   = (item.Height == 0) ? num : (num + 1);
         type       = ((item.ID & 0x3fff) == 0x2006) ? 4 : 2;
         tiebreaker = item.Serial;
     }
     else if (obj is StaticItem)
     {
         int        num2;
         StaticItem item2 = (StaticItem)obj;
         z = item2.Z;
         if (Map.m_ItemFlags[item2.ID & 0x3fff][TileFlag.Background])
         {
             num2 = 0;
         }
         else
         {
             num2 = 1;
         }
         treshold   = (item2.Height == 0) ? num2 : (num2 + 1);
         type       = 1;
         tiebreaker = item2.m_SortInfluence;
     }
     else
     {
         z          = 0;
         treshold   = 0;
         type       = 0;
         tiebreaker = 0;
     }
 }
Beispiel #4
0
 private static unsafe void Grid(LandTile lt, LandTile[,] landTiles, int x, int y, int bx, int by)
 {
     if (((bx + 0x2c) > Engine.GameX) && (bx < (Engine.GameX + Engine.GameWidth)))
     {
         CustomVertex.TransformedColoredTextured[] v = GeoPool(5);
         v[0].Color = v[1].Color = v[2].Color = v[3].Color = 0x4080ff;
         v[0].X = bx + 0x16;
         v[0].Y = by - (lt.m_Z << 2);
         v[1].Y = (by + 0x16) - (landTiles[x + 1, y].m_Z << 2);
         v[1].X = bx + 0x2c;
         v[2].Y = (by + 0x2c) - (landTiles[x + 1, y + 1].m_Z << 2);
         v[2].X = bx + 0x16;
         v[3].Y = (by + 0x16) - (landTiles[x, y + 1].m_Z << 2);
         v[3].X = bx;
         v[4] = v[0];
         SetTexture(null);
         if (m_AlphaEnable)
         {
             SetAlphaEnablePrecalc(false);
         }
         if (m_FilterEnable)
         {
             SetFilterEnablePrecalc(false);
         }
         AlphaTestEnable = false;
         DrawLines(v);
         int num = x & 7;
         if ((y & 7) == 0)
         {
             fixed (CustomVertex.TransformedColoredTextured* texturedRef = v)
             {
                 texturedRef->Color = texturedRef[1].Color = GetQuadColor(0xff2080);
                 PushLineStrip(texturedRef, 2);
             }
         }
         if (num == 0)
         {
             fixed (CustomVertex.TransformedColoredTextured* texturedRef2 = v)
             {
                 texturedRef2[3].Color = texturedRef2[4].Color = GetQuadColor(0xff2080);
                 PushLineStrip(texturedRef2 + 3, 2);
             }
         }
     }
 }
Beispiel #5
0
 public static unsafe void Initialize(LandTile t, byte* pSrc)
 {
     t.m_ID = *((short*) pSrc);
     t.m_ID = (short) (t.m_ID & 0x3fff);
     t.m_ID = (short) TextureTable.m_Table[t.m_ID];
     t.m_SortZ = t.m_Z = *((sbyte*) (pSrc + 2));
     t.m_bDraw = false;
     t.m_bInit = false;
     t.m_bFilter = false;
     t.m_Height = 0;
     t.m_sDraw = null;
     t.m_Guarded = false;
     t.m_FoldLeftRight = false;
 }
Beispiel #6
0
 public static void DrawMapLine(LandTile[,] landTiles, int bx, int by, int x, int y, int x2, int y2)
 {
     SetTexture(null);
     if (m_AlphaEnable)
     {
         SetAlphaEnablePrecalc(false);
     }
     if (m_FilterEnable)
     {
         SetFilterEnablePrecalc(false);
     }
     AlphaTestEnable = false;
     DrawLine(bx + 0x16, by - (landTiles[x, y].m_Z << 2), (bx + 0x16) + ((x2 - y2) * 0x16), (by + 0x16) - (landTiles[x + x2, y + y2].m_Z << 2), 0x40ff40);
 }
Beispiel #7
0
 public static void Initialize(LandTile t, short id, sbyte z)
 {
     t.m_ID = id;
     t.m_ID = (short) (t.m_ID & 0x3fff);
     t.m_ID = (short) TextureTable.m_Table[t.m_ID];
     t.m_SortZ = t.m_Z = z;
     t.m_bDraw = false;
     t.m_bInit = false;
     t.m_bFilter = false;
     t.m_Height = 0;
     t.m_sDraw = null;
     t.m_Guarded = false;
     t.m_FoldLeftRight = false;
 }
Beispiel #8
0
 public static MapPackage GetMap(int X, int Y, int W, int H)
 {
     LandTile tile;
     int num28;
     int num29;
     if ((((m_X == X) && (m_Y == Y)) && ((m_Width == W) && (m_Height == H))) && (((m_World == Engine.m_World) && (m_vLight == MapLighting.vLight)) && (m_IsCached && !m_QueueInvalidate)))
     {
         return m_Cached;
     }
     m_QueueInvalidate = false;
     if (m_Cached.cells != null)
     {
         int length = m_Cached.cells.GetLength(0);
         int num2 = m_Cached.cells.GetLength(1);
         for (int num3 = 0; num3 < length; num3++)
         {
             for (int num4 = 0; num4 < num2; num4++)
             {
                 ArrayList list = m_Cached.cells[num3, num4];
                 if (list != null)
                 {
                     int count = list.Count;
                     for (int num6 = 0; num6 < count; num6++)
                     {
                         ((ICell) list[num6]).Dispose();
                     }
                 }
             }
         }
     }
     m_X = X;
     m_Y = Y;
     m_Width = W;
     m_Height = H;
     m_World = Engine.m_World;
     m_vLight = MapLighting.vLight;
     if (m_StrongReferences == null)
     {
         m_StrongReferences = new MapBlock[W * H];
     }
     int num7 = W << 3;
     int num8 = H << 3;
     if (m_CellPool == null)
     {
         m_CellPool = new ArrayList[num7, num8];
         for (int num9 = 0; num9 < num7; num9++)
         {
             for (int num10 = 0; num10 < num8; num10++)
             {
                 m_CellPool[num9, num10] = new ArrayList(4);
             }
         }
     }
     else
     {
         for (int num11 = 0; num11 < num7; num11++)
         {
             for (int num12 = 0; num12 < num8; num12++)
             {
                 m_CellPool[num11, num12].Clear();
             }
         }
     }
     if (m_LandTiles == null)
     {
         m_LandTiles = new LandTile[num7, num8];
         for (int num13 = 0; num13 < num7; num13++)
         {
             for (int num14 = 0; num14 < num8; num14++)
             {
                 m_LandTiles[num13, num14] = new LandTile();
             }
         }
     }
     if (m_IndexPool == null)
     {
         m_IndexPool = new byte[num7, num8];
     }
     if (m_FlagPool == null)
     {
         m_FlagPool = new byte[num7, num8];
     }
     ArrayList[,] cellPool = m_CellPool;
     IComparer comparer = TileSorter.Comparer;
     MapPackage map = new MapPackage {
         cells = cellPool,
         CellX = X << 3,
         CellY = Y << 3,
         landTiles = m_LandTiles
     };
     Engine.Multis.Update(map);
     TileMatrix matrix = GetMatrix(Engine.m_World);
     int num15 = 0;
     for (int i = X; num15 < W; i++)
     {
         int num17 = 0;
         for (int num18 = Y; num17 < H; num18++)
         {
             MapBlock block = matrix.GetBlock(i, num18);
             m_StrongReferences[(num17 * W) + num15] = block;
             HuedTile[][][] tileArray = (block == null) ? matrix.EmptyStaticBlock : block.m_StaticTiles;
             Tile[] tileArray2 = (block == null) ? matrix.InvalidLandBlock : block.m_LandTiles;
             int index = 0;
             int num20 = i << 3;
             for (int num21 = num15 << 3; index < 8; num21++)
             {
                 int num22 = 0;
                 int num23 = num18 << 3;
                 for (int num24 = num17 << 3; num22 < 8; num24++)
                 {
                     HuedTile[] tileArray3 = tileArray[index][num22];
                     for (int num25 = 0; num25 < tileArray3.Length; num25++)
                     {
                         cellPool[num21, num24].Add(StaticItem.Instantiate(tileArray3[num25], num25, ((num20 * matrix.Height) + num23) | (num25 << 0x19)));
                     }
                     tile = m_LandTiles[num21, num24];
                     Tile tile2 = tileArray2[(num22 * 8) + index];
                     LandTile.Initialize(tile, (short) tile2.ID, (sbyte) tile2.Z);
                     cellPool[num21, num24].Add(tile);
                     num22++;
                     num23++;
                 }
                 index++;
                 num20++;
             }
             num17++;
         }
         num15++;
     }
     int num26 = X << 3;
     int num27 = Y << 3;
     IEnumerator enumerator = World.Items.Values.GetEnumerator();
     while (enumerator.MoveNext())
     {
         Item current = (Item) enumerator.Current;
         if (current.Serial == 0x40000430)
         {
             int num30 = 0;
             num30++;
         }
         if ((current.Visible && current.InWorld) && !current.IsMulti)
         {
             num28 = current.X - num26;
             num29 = current.Y - num27;
             if (((num28 >= 0) && (num28 < num7)) && ((num29 >= 0) && (num29 < num8)))
             {
                 current.OldMapX = current.X;
                 current.OldMapY = current.Y;
                 cellPool[num28, num29].Add(DynamicItem.Instantiate(current));
             }
         }
     }
     enumerator = World.Mobiles.Values.GetEnumerator();
     while (enumerator.MoveNext())
     {
         Mobile mobile = (Mobile) enumerator.Current;
         if (mobile.Visible)
         {
             num28 = mobile.X - num26;
             num29 = mobile.Y - num27;
             if (((num28 >= 0) && (num28 < num7)) && ((num29 >= 0) && (num29 < num8)))
             {
                 mobile.OldMapX = mobile.X;
                 mobile.OldMapY = mobile.Y;
                 cellPool[num28, num29].Add(MobileCell.Instantiate(mobile));
             }
         }
     }
     for (int j = 0; j < num7; j++)
     {
         for (int num32 = 0; num32 < num8; num32++)
         {
             int num34;
             int z;
             int num36;
             tile = m_LandTiles[j, num32];
             int num33 = num34 = z = num36 = tile.m_Z;
             if (j < (num7 - 1))
             {
                 z = m_LandTiles[j + 1, num32].m_Z;
             }
             if (num32 < (num8 - 1))
             {
                 num34 = m_LandTiles[j, num32 + 1].m_Z;
             }
             if ((j < (num7 - 1)) && (num32 < (num8 - 1)))
             {
                 num36 = m_LandTiles[j + 1, num32 + 1].m_Z;
             }
             if (tile.m_FoldLeftRight = Math.Abs((int) (num33 - num36)) <= Math.Abs((int) (num34 - z)))
             {
                 tile.SortZ = (sbyte) Math.Floor((double) (((double) (num33 + num36)) / 2.0));
             }
             else
             {
                 tile.SortZ = (sbyte) Math.Floor((double) (((double) (num34 + z)) / 2.0));
             }
             tile.m_Guarded = !GetLandFlags(tile.m_ID)[TileFlag.Impassable] && (Region.Find(Region.GuardedRegions, j + num26, num32 + num27, tile.SortZ, Engine.m_World) != null);
             ArrayList list2 = cellPool[j, num32];
             if (list2.Count > 1)
             {
                 list2.Sort(comparer);
             }
         }
     }
     map = new MapPackage {
         flags = m_FlagPool,
         cells = cellPool,
         CellX = X << 3,
         CellY = Y << 3,
         landTiles = m_LandTiles
     };
     MapLighting.GetColorMap(ref map);
     m_Cached = map;
     m_IsCached = true;
     for (int k = -1; k <= H; k++)
     {
         Engine.QueueMapLoad(X - 1, Y + k, matrix);
     }
     for (int m = 0; m < W; m++)
     {
         Engine.QueueMapLoad(X + m, Y - 1, matrix);
         Engine.QueueMapLoad(X + m, Y + H, matrix);
     }
     for (int n = -1; n <= H; n++)
     {
         Engine.QueueMapLoad(X + W, Y + n, matrix);
     }
     return map;
 }
Beispiel #9
0
 public static LandTile GetCell(int xCell, int yCell, int world)
 {
     Tile landTile = GetMatrix(world).GetLandTile(xCell, yCell);
     LandTile t = new LandTile();
     LandTile.Initialize(t, (short) landTile.ID, (sbyte) landTile.Z);
     return t;
 }
Beispiel #10
0
        public static bool CheckMovement(int xStart, int yStart, int zStart, int dir, out int zNew)
        {
            int    num8;
            int    num9;
            Mobile player = World.Player;

            if (player == null)
            {
                zNew = 0;
                return(false);
            }
            int x = xStart;
            int y = yStart;

            Offset(dir, ref x, ref y);
            MapPackage cache = Map.GetCache();
            int        num3  = x - cache.CellX;
            int        num4  = y - cache.CellY;

            if (!Map.IsValid(num3, num4))
            {
                zNew = 0;
                return(false);
            }
            LandTile  tile  = cache.landTiles[num3, num4];
            ArrayList tiles = cache.cells[num3, num4];

            try
            {
                if (((player.Notoriety == Notoriety.Murderer) && tile.m_Guarded) && (!cache.landTiles[xStart - cache.CellX, yStart - cache.CellY].m_Guarded && ((Control.ModifierKeys & (Keys.Control | Keys.Shift)) != (Keys.Control | Keys.Shift))))
                {
                    zNew = 0;
                    return(false);
                }
            }
            catch
            {
            }
            bool flag  = Map.GetLandFlags(tile.m_ID)[TileFlag.Impassable];
            bool flag2 = ((tile.m_ID != 2) && (tile.m_ID != 0x1db)) && ((tile.m_ID < 430) || (tile.m_ID > 0x1b5));
            int  z     = 0;
            int  avg   = 0;
            int  top   = 0;

            Map.GetAverageZ(x, y, ref z, ref avg, ref top);
            GetStartZ(xStart, yStart, zStart, out num8, out num9);
            zNew = num8;
            bool flag3       = false;
            int  num10       = num9 + 2;
            int  num11       = num8 + 0x10;
            bool ignoreDoors = player.Ghost || (player.Body == 0x3db);
            bool ignoreMobs  = (ignoreDoors || (player.StamCur == player.StamMax)) || (Engine.m_World != 0);

            if (Engine.m_Stealth)
            {
                ignoreMobs = false;
            }
            for (int i = 0; i < tiles.Count; i++)
            {
                ICell cell = (ICell)tiles[i];
                if (cell is StaticItem)
                {
                    StaticItem item  = (StaticItem)cell;
                    TileFlags  flags = Map.m_ItemFlags[item.m_RealID & 0x3fff];
                    if (flags[TileFlag.Surface] && !flags[TileFlag.Impassable])
                    {
                        int num13  = item.m_Z;
                        int num14  = num13;
                        int ourZ   = num13 + item.CalcHeight;
                        int num16  = ourZ + 0x10;
                        int ourTop = num11;
                        if (flag3)
                        {
                            int num18 = Math.Abs((int)(ourZ - player.Z)) - Math.Abs((int)(zNew - player.Z));
                            if ((num18 > 0) || ((num18 == 0) && (ourZ > zNew)))
                            {
                                continue;
                            }
                        }
                        if ((ourZ + 0x10) > ourTop)
                        {
                            ourTop = ourZ + 0x10;
                        }
                        if (!flags[TileFlag.Bridge])
                        {
                            num14 += item.Height;
                        }
                        if (num10 >= num14)
                        {
                            int num19 = num13;
                            if (item.Height >= 2)
                            {
                                num19 += 2;
                            }
                            else
                            {
                                num19 += item.Height;
                            }
                            if (((!flag2 || (num19 >= avg)) || ((avg <= ourZ) || (ourTop <= z))) && IsOk(ignoreMobs, ignoreDoors, ourZ, ourTop, tiles))
                            {
                                zNew  = ourZ;
                                flag3 = true;
                            }
                        }
                    }
                }
                else if (cell is DynamicItem)
                {
                    Item      item2  = ((DynamicItem)cell).m_Item;
                    TileFlags flags2 = Map.m_ItemFlags[item2.ID & 0x3fff];
                    if (flags2[TileFlag.Surface] && !flags2[TileFlag.Impassable])
                    {
                        int num20  = item2.Z;
                        int num21  = num20;
                        int num22  = num20;
                        int height = Map.GetHeight((item2.ID & 0x3fff) + 0x4000);
                        if (flags2[TileFlag.Bridge])
                        {
                            num22 += height / 2;
                        }
                        else
                        {
                            num22 += height;
                        }
                        if (flag3)
                        {
                            int num24 = Math.Abs((int)(num22 - player.Z)) - Math.Abs((int)(zNew - player.Z));
                            if ((num24 > 0) || ((num24 == 0) && (num22 > zNew)))
                            {
                                continue;
                            }
                        }
                        int num25 = num22 + 0x10;
                        int num26 = num11;
                        if ((num22 + 0x10) > num26)
                        {
                            num26 = num22 + 0x10;
                        }
                        if (!flags2[TileFlag.Bridge])
                        {
                            num21 += height;
                        }
                        if (num10 >= num21)
                        {
                            int num27 = num20;
                            if (height >= 2)
                            {
                                num27 += 2;
                            }
                            else
                            {
                                num27 += height;
                            }
                            if (((!flag2 || (num27 >= avg)) || ((avg <= num22) || (num26 <= z))) && IsOk(ignoreMobs, ignoreDoors, num22, num26, tiles))
                            {
                                zNew  = num22;
                                flag3 = true;
                            }
                        }
                    }
                }
            }
            if ((flag2 && !flag) && (num10 >= z))
            {
                int num28 = avg;
                int num29 = num28 + 0x10;
                int num30 = num11;
                if ((num28 + 0x10) > num30)
                {
                    num30 = num28 + 0x10;
                }
                bool flag6 = true;
                if (flag3)
                {
                    int num31 = Math.Abs((int)(num28 - player.Z)) - Math.Abs((int)(zNew - player.Z));
                    if ((num31 > 0) || ((num31 == 0) && (num28 > zNew)))
                    {
                        flag6 = false;
                    }
                }
                if (flag6 && IsOk(ignoreMobs, ignoreDoors, num28, num30, tiles))
                {
                    zNew  = num28;
                    flag3 = true;
                }
            }
            return(flag3);
        }
Beispiel #11
0
        private static void GetStartZ(int xStart, int yStart, int zStart, out int zLow, out int zTop)
        {
            MapPackage cache = Map.GetCache();
            int        x     = xStart - cache.CellX;
            int        y     = yStart - cache.CellY;

            if (!Map.IsValid(x, y))
            {
                zLow = zStart;
                zTop = zStart;
            }
            else
            {
                int       num12;
                LandTile  tile  = cache.landTiles[x, y];
                ArrayList list  = cache.cells[x, y];
                bool      flag  = Map.GetLandFlags(tile.m_ID)[TileFlag.Impassable];
                bool      flag2 = ((tile.m_ID != 2) && (tile.m_ID != 0x1db)) && ((tile.m_ID < 430) || (tile.m_ID > 0x1b5));
                int       z     = 0;
                int       avg   = 0;
                int       top   = 0;
                Map.GetAverageZ(xStart, yStart, ref z, ref avg, ref top);
                zTop = num12 = 0;
                int  num6  = zLow = num12;
                bool flag3 = false;
                if (((flag2 && !flag) && (zStart >= avg)) && (!flag3 || (avg >= num6)))
                {
                    zLow = z;
                    num6 = avg;
                    if (!flag3 || (top > zTop))
                    {
                        zTop = top;
                    }
                    flag3 = true;
                }
                for (int i = 0; i < list.Count; i++)
                {
                    ICell cell = (ICell)list[i];
                    if (cell is StaticItem)
                    {
                        StaticItem item  = (StaticItem)cell;
                        TileFlags  flags = Map.m_ItemFlags[item.m_RealID & 0x3fff];
                        int        num8  = item.m_Z + item.CalcHeight;
                        if ((flags[TileFlag.Surface] && (zStart >= num8)) && (!flag3 || (num8 >= num6)))
                        {
                            num6 = num8;
                            int num9 = item.m_Z + item.m_Height;
                            if (!flag3 || (num9 > zTop))
                            {
                                zTop = num9;
                            }
                            zLow  = item.m_Z;
                            flag3 = true;
                        }
                    }
                    else if (cell is DynamicItem)
                    {
                        Item      item2  = ((DynamicItem)cell).m_Item;
                        TileFlags flags2 = Map.m_ItemFlags[item2.ID & 0x3fff];
                        int       num10  = item2.Z;
                        if (flags2[TileFlag.Bridge])
                        {
                            num10 += Map.GetHeight((item2.ID & 0x3fff) + 0x4000) / 2;
                        }
                        else
                        {
                            num10 += Map.GetHeight((item2.ID & 0x3fff) + 0x4000);
                        }
                        if ((flags2[TileFlag.Surface] && (zStart >= num10)) && (!flag3 || (num10 >= num6)))
                        {
                            num6 = num10;
                            int num11 = item2.Z + Map.GetHeight((item2.ID & 0x3fff) + 0x4000);
                            if (!flag3 || (num11 > zTop))
                            {
                                zTop = num11;
                            }
                            zLow  = item2.Z;
                            flag3 = true;
                        }
                    }
                }
                if (!flag3)
                {
                    zLow = zTop = zStart;
                }
                else if (zStart > zTop)
                {
                    zTop = zStart;
                }
            }
        }