コード例 #1
0
ファイル: Mobile.cs プロジェクト: uotools/PlayUO
        public bool CheckGuarded()
        {
            MapPackage cache = Map.GetCache();
            int        num   = this.m_X - cache.CellX;
            int        num2  = this.m_Y - cache.CellY;

            return((((num >= 0) && (num < Renderer.cellWidth)) && ((num2 >= 0) && (num2 < Renderer.cellHeight))) && cache.landTiles[num, num2].m_Guarded);
        }
コード例 #2
0
ファイル: Multis.cs プロジェクト: Skinny1001/PlayUO
        public void Update(MapPackage map)
        {
            int count = this.m_Items.Count;
            if (count != 0)
            {
                int length = map.cells.GetLength(0);
                int num3 = map.cells.GetLength(1);
                int cellX = map.CellX;
                int cellY = map.CellY;
                int num6 = cellX + length;
                int num7 = cellY + num3;
                for (int i = 0; i < count; i++)
                {
                    Item item = (Item) this.m_Items[i];
                    if (item.InWorld && item.Visible)
                    {
                        CustomMultiEntry customMulti = CustomMultiLoader.GetCustomMulti(item.Serial, item.Revision);
                        Multi m = null;
                        if (customMulti != null)
                        {
                            m = customMulti.Multi;
                        }
                        if (m == null)
                        {
                            m = item.Multi;
                        }
                        if (m != null)
                        {
                            int num9;
                            int num10;
                            int num11;
                            int num12;
                            m.GetBounds(out num9, out num10, out num11, out num12);
                            num9 += item.X;
                            num10 += item.Y;
                            num11 += item.X;
                            num12 += item.Y;
                            if ((((num9 < num6) && (num11 >= cellX)) && (num10 < num7)) && (num12 >= cellY))
                            {
                                ArrayList list = m.List;
                                int num13 = list.Count;
                                bool flag = false;
                                Mobile player = World.Player;
                                if (player != null)
                                {
                                    flag = this.IsInMulti(item, m, player.X, player.Y, player.Z);
                                }
                                int num14 = -2147483648 | i;
                                for (int j = 0; j < num13; j++)
                                {
                                    MultiItem item2 = (MultiItem) list[j];
                                    if ((item2.Flags == 0) && (j != 0))
                                    {
                                        continue;
                                    }
                                    int num16 = item.X + item2.X;
                                    int num17 = item.Y + item2.Y;
                                    num16 -= cellX;
                                    num17 -= cellY;
                                    if ((((num16 < 0) || (num16 >= length)) || (num17 < 0)) || (num17 >= num3))
                                    {
                                        continue;
                                    }
                                    bool flag2 = true;
                                    int itemID = item2.ItemID;
                                    if (flag || (this.m_Level == 0))
                                    {
                                        goto Label_03C6;
                                    }
                                    int num19 = 7;
                                    if (customMulti == null)
                                    {
                                        switch ((m.MultiID & 0x3fff))
                                        {
                                            case 0x7a:
                                            case 0x7c:
                                            case 0x7e:
                                            case 0x98:
                                            case 0x9c:
                                                goto Label_0270;

                                            case 150:
                                            case 0xa2:
                                                goto Label_0266;

                                            case 0x9a:
                                                goto Label_0275;

                                            case 0x9e:
                                                num19 = 5;
                                                break;
                                        }
                                    }
                                    goto Label_027A;
                                Label_0266:
                                    num19 = 4;
                                    goto Label_027A;
                                Label_0270:
                                    num19 = 6;
                                    goto Label_027A;
                                Label_0275:
                                    num19 = 8;
                                Label_027A:
                                    if (Map.m_ItemFlags[itemID & 0x3fff][TileFlag.Bridge] || Map.m_ItemFlags[itemID & 0x3fff][TileFlag.Surface])
                                    {
                                        flag2 = item2.Z < (num19 + (this.m_Level * 20));
                                    }
                                    else
                                    {
                                        flag2 = item2.Z < (num19 + ((this.m_Level - 1) * 20));
                                        if ((item2.Z >= (num19 + ((this.m_Level - 1) * 20))) && (item2.Z <= ((num19 + ((this.m_Level - 1) * 20)) + 2)))
                                        {
                                            if (m_RouteMap == null)
                                            {
                                                m_RouteMap = new int[0x4000];
                                                for (int k = 0; k < m_RouteTable.GetLength(0); k++)
                                                {
                                                    m_RouteMap[m_RouteTable[k, 0]] = m_RouteTable[k, 1];
                                                }
                                            }
                                            int num21 = m_RouteMap[itemID & 0x3fff];
                                            if (num21 != 0)
                                            {
                                                itemID = num21;
                                                flag2 = true;
                                            }
                                        }
                                    }
                                    if (!flag2 && ((((itemID == 0x4001) || (itemID == 0x5796)) || ((itemID == 0x61a4) || (itemID == 0x6198))) || ((itemID == 0x61bc) || (itemID == 0x6199))))
                                    {
                                        flag2 = true;
                                    }
                                Label_03C6:
                                    if (flag2)
                                    {
                                        map.cells[num16, num17].Add(StaticItem.Instantiate((short) itemID, item2.ItemID, (sbyte) (item.Z + item2.Z), num14 | (j << 0x10)));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: MapLighting.cs プロジェクト: Skinny1001/PlayUO
 public static void GetColorMap(ref MapPackage map)
 {
     int cellWidth = Renderer.cellWidth;
     int cellHeight = Renderer.cellHeight;
     Vector[,,] normalPool = m_NormalPool;
     ArrayList[,] cells = map.cells;
     byte[,] flags = map.flags;
     byte num3 = 1;
     Vector[,] vertsPool = m_VertsPool;
     bool[,] calcPool = m_CalcPool;
     CheckStretchTable();
     if (normalPool == null)
     {
         normalPool = m_NormalPool = new Vector[cellWidth, cellHeight, 2];
     }
     if (vertsPool == null)
     {
         vertsPool = m_VertsPool = new Vector[cellWidth, cellHeight];
     }
     if (calcPool == null)
     {
         calcPool = m_CalcPool = new bool[cellWidth, cellHeight];
     }
     else
     {
         Array.Clear(calcPool, 0, cellWidth * cellHeight);
     }
     m_CalcVert_Verts = vertsPool;
     m_CalcVert_Tiles = map.landTiles;
     CalcVert(0, 0);
     calcPool[0, 0] = true;
     for (int i = 0; i < (cellWidth - 1); i++)
     {
         for (int k = 0; k < (cellHeight - 1); k++)
         {
             if (!calcPool[i + 1, k])
             {
                 CalcVert(i + 1, k);
                 calcPool[i + 1, k] = true;
             }
             CalcVert(i + 1, k + 1);
             calcPool[i + 1, k + 1] = true;
             if (!calcPool[i, k + 1])
             {
                 CalcVert(i, k + 1);
                 calcPool[i, k + 1] = true;
             }
             SurfaceNormal(normalPool, i, k, 0, *(vertsPool[i, k]), *(vertsPool[i + 1, k]), *(vertsPool[i, k + 1]));
             SurfaceNormal(normalPool, i, k, 1, *(vertsPool[i, k + 1]), *(vertsPool[i + 1, k]), *(vertsPool[i + 1, k + 1]));
         }
     }
     int[,] colorMap = m_ColorMap;
     if (colorMap == null)
     {
         colorMap = m_ColorMap = new int[cellWidth, cellHeight];
     }
     int[,] numArray2 = m_ColorMap2;
     if (numArray2 == null)
     {
         numArray2 = m_ColorMap2 = new int[cellWidth, cellHeight];
     }
     for (int j = 1; j < (cellWidth - 1); j++)
     {
         byte[,] buffer2;
         IntPtr ptr;
         IntPtr ptr2;
         int[,] numArray3;
         for (int m = 1; m < (cellHeight - 1); m++)
         {
             Vector vector = *(normalPool[j, m, 0]);
             Vector vector2 = *(normalPool[j - 1, m - 1, 1]);
             Vector vector3 = *(normalPool[j - 1, m, 0]);
             Vector vector4 = *(normalPool[j - 1, m, 1]);
             Vector vector5 = *(normalPool[j, m - 1, 0]);
             Vector vector6 = *(normalPool[j, m - 1, 1]);
             float num8 = ((((vector.m_X + vector2.m_X) + vector3.m_X) + vector4.m_X) + vector5.m_X) + vector6.m_X;
             float num9 = ((((vector.m_Y + vector2.m_Y) + vector3.m_Y) + vector4.m_Y) + vector5.m_Y) + vector6.m_Y;
             float num10 = ((((vector.m_Z + vector2.m_Z) + vector3.m_Z) + vector4.m_Z) + vector5.m_Z) + vector6.m_Z;
             num8 *= 0.1666667f;
             num9 *= 0.1666667f;
             num10 *= 0.1666667f;
             float num11 = (float) (1.0 / Math.Sqrt((double) (((num8 * num8) + (num9 * num9)) + (num10 * num10))));
             num8 *= num11;
             num9 *= num11;
             num10 *= num11;
             float num12 = ((num8 * vLight.m_X) + (num9 * vLight.m_Y)) + (num10 * vLight.m_Z);
             num12 += 0.2151413f;
             num12 += 0.8235294f;
             int num13 = (int) ((255f * num12) + 0.5f);
             if (num13 < 0x80)
             {
                 num13 = 0x80;
             }
             else if (num13 > 0xff)
             {
                 num13 = 0xff;
             }
             numArray2[j, m] = colorMap[j, m] = 0x10101 * num13;
             if (((!m_AlwaysStretch[m_CalcVert_Tiles[j - 1, m - 1].m_ID & 0x3fff] && (colorMap[j, m] == 0xd2d2d2)) && ((colorMap[j - 1, m] == 0xd2d2d2) && (colorMap[j - 1, m - 1] == 0xd2d2d2))) && (colorMap[j, m - 1] == 0xd2d2d2))
             {
                 int z = m_CalcVert_Tiles[j - 1, m - 1].m_Z;
                 int num15 = m_CalcVert_Tiles[j, m - 1].m_Z;
                 int num16 = m_CalcVert_Tiles[j, m].m_Z;
                 int num17 = m_CalcVert_Tiles[j - 1, m].m_Z;
                 if (((z == num15) && (z == num16)) && (z == num17))
                 {
                     (buffer2 = flags)[(int) (ptr = (IntPtr) (j - 1)), (int) (ptr2 = (IntPtr) (m - 1))] = (byte) (buffer2[(int) ptr, (int) ptr2] & ~num3);
                 }
                 else
                 {
                     (buffer2 = flags)[(int) (ptr = (IntPtr) (j - 1)), (int) (ptr2 = (IntPtr) (m - 1))] = (byte) (buffer2[(int) ptr, (int) ptr2] | num3);
                 }
             }
             else
             {
                 (buffer2 = flags)[(int) (ptr = (IntPtr) (j - 1)), (int) (ptr2 = (IntPtr) (m - 1))] = (byte) (buffer2[(int) ptr, (int) ptr2] | num3);
             }
         }
         (buffer2 = flags)[(int) (ptr = (IntPtr) j), 0] = (byte) (buffer2[(int) ptr, 0] | num3);
         (buffer2 = flags)[(int) (ptr = (IntPtr) j), (int) (ptr2 = (IntPtr) (cellHeight - 2))] = (byte) (buffer2[(int) ptr, (int) ptr2] | num3);
         (buffer2 = flags)[0, (int) (ptr = (IntPtr) j)] = (byte) (buffer2[0, (int) ptr] | num3);
         (buffer2 = flags)[(int) (ptr = (IntPtr) (cellWidth - 2)), (int) (ptr2 = (IntPtr) j)] = (byte) (buffer2[(int) ptr, (int) ptr2] | num3);
         numArray2[j, 0] = colorMap[j, 0] = 0;
         numArray2[j, cellHeight - 1] = colorMap[j, cellHeight - 1] = 0;
         numArray2[0, j] = (numArray3 = colorMap)[0, (int) (ptr = (IntPtr) j)] = numArray3[0, (int) ptr] | num3;
         numArray2[cellWidth - 1, j] = colorMap[cellWidth - 1, j] = 0;
     }
     map.colorMap = colorMap;
     map.realColors = colorMap;
     map.frameColors = numArray2;
     map.flags = flags;
 }
コード例 #4
0
ファイル: Map.cs プロジェクト: Skinny1001/PlayUO
 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;
 }
コード例 #5
0
ファイル: Multis.cs プロジェクト: uotools/PlayUO
        public void Update(MapPackage map)
        {
            int count = this.m_Items.Count;

            if (count != 0)
            {
                int length = map.cells.GetLength(0);
                int num3   = map.cells.GetLength(1);
                int cellX  = map.CellX;
                int cellY  = map.CellY;
                int num6   = cellX + length;
                int num7   = cellY + num3;
                for (int i = 0; i < count; i++)
                {
                    Item item = (Item)this.m_Items[i];
                    if (item.InWorld && item.Visible)
                    {
                        CustomMultiEntry customMulti = CustomMultiLoader.GetCustomMulti(item.Serial, item.Revision);
                        Multi            m           = null;
                        if (customMulti != null)
                        {
                            m = customMulti.Multi;
                        }
                        if (m == null)
                        {
                            m = item.Multi;
                        }
                        if (m != null)
                        {
                            int num9;
                            int num10;
                            int num11;
                            int num12;
                            m.GetBounds(out num9, out num10, out num11, out num12);
                            num9  += item.X;
                            num10 += item.Y;
                            num11 += item.X;
                            num12 += item.Y;
                            if ((((num9 < num6) && (num11 >= cellX)) && (num10 < num7)) && (num12 >= cellY))
                            {
                                ArrayList list   = m.List;
                                int       num13  = list.Count;
                                bool      flag   = false;
                                Mobile    player = World.Player;
                                if (player != null)
                                {
                                    flag = this.IsInMulti(item, m, player.X, player.Y, player.Z);
                                }
                                int num14 = -2147483648 | i;
                                for (int j = 0; j < num13; j++)
                                {
                                    MultiItem item2 = (MultiItem)list[j];
                                    if ((item2.Flags == 0) && (j != 0))
                                    {
                                        continue;
                                    }
                                    int num16 = item.X + item2.X;
                                    int num17 = item.Y + item2.Y;
                                    num16 -= cellX;
                                    num17 -= cellY;
                                    if ((((num16 < 0) || (num16 >= length)) || (num17 < 0)) || (num17 >= num3))
                                    {
                                        continue;
                                    }
                                    bool flag2  = true;
                                    int  itemID = item2.ItemID;
                                    if (flag || (this.m_Level == 0))
                                    {
                                        goto Label_03C6;
                                    }
                                    int num19 = 7;
                                    if (customMulti == null)
                                    {
                                        switch ((m.MultiID & 0x3fff))
                                        {
                                        case 0x7a:
                                        case 0x7c:
                                        case 0x7e:
                                        case 0x98:
                                        case 0x9c:
                                            goto Label_0270;

                                        case 150:
                                        case 0xa2:
                                            goto Label_0266;

                                        case 0x9a:
                                            goto Label_0275;

                                        case 0x9e:
                                            num19 = 5;
                                            break;
                                        }
                                    }
                                    goto Label_027A;
Label_0266:
                                    num19 = 4;
                                    goto Label_027A;
Label_0270:
                                    num19 = 6;
                                    goto Label_027A;
Label_0275:
                                    num19 = 8;
Label_027A:
                                    if (Map.m_ItemFlags[itemID & 0x3fff][TileFlag.Bridge] || Map.m_ItemFlags[itemID & 0x3fff][TileFlag.Surface])
                                    {
                                        flag2 = item2.Z < (num19 + (this.m_Level * 20));
                                    }
                                    else
                                    {
                                        flag2 = item2.Z < (num19 + ((this.m_Level - 1) * 20));
                                        if ((item2.Z >= (num19 + ((this.m_Level - 1) * 20))) && (item2.Z <= ((num19 + ((this.m_Level - 1) * 20)) + 2)))
                                        {
                                            if (m_RouteMap == null)
                                            {
                                                m_RouteMap = new int[0x4000];
                                                for (int k = 0; k < m_RouteTable.GetLength(0); k++)
                                                {
                                                    m_RouteMap[m_RouteTable[k, 0]] = m_RouteTable[k, 1];
                                                }
                                            }
                                            int num21 = m_RouteMap[itemID & 0x3fff];
                                            if (num21 != 0)
                                            {
                                                itemID = num21;
                                                flag2  = true;
                                            }
                                        }
                                    }
                                    if (!flag2 && ((((itemID == 0x4001) || (itemID == 0x5796)) || ((itemID == 0x61a4) || (itemID == 0x6198))) || ((itemID == 0x61bc) || (itemID == 0x6199))))
                                    {
                                        flag2 = true;
                                    }
Label_03C6:
                                    if (flag2)
                                    {
                                        map.cells[num16, num17].Add(StaticItem.Instantiate((short)itemID, item2.ItemID, (sbyte)(item.Z + item2.Z), num14 | (j << 0x10)));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
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);
        }
コード例 #7
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;
                }
            }
        }
コード例 #8
0
ファイル: MapLighting.cs プロジェクト: uotools/PlayUO
        public static void GetColorMap(ref MapPackage map)
        {
            int cellWidth  = Renderer.cellWidth;
            int cellHeight = Renderer.cellHeight;

            Vector[,,] normalPool = m_NormalPool;
            ArrayList[,] cells    = map.cells;
            byte[,] flags         = map.flags;
            byte num3 = 1;

            Vector[,] vertsPool = m_VertsPool;
            bool[,] calcPool    = m_CalcPool;
            CheckStretchTable();
            if (normalPool == null)
            {
                normalPool = m_NormalPool = new Vector[cellWidth, cellHeight, 2];
            }
            if (vertsPool == null)
            {
                vertsPool = m_VertsPool = new Vector[cellWidth, cellHeight];
            }
            if (calcPool == null)
            {
                calcPool = m_CalcPool = new bool[cellWidth, cellHeight];
            }
            else
            {
                Array.Clear(calcPool, 0, cellWidth * cellHeight);
            }
            m_CalcVert_Verts = vertsPool;
            m_CalcVert_Tiles = map.landTiles;
            CalcVert(0, 0);
            calcPool[0, 0] = true;
            for (int i = 0; i < (cellWidth - 1); i++)
            {
                for (int k = 0; k < (cellHeight - 1); k++)
                {
                    if (!calcPool[i + 1, k])
                    {
                        CalcVert(i + 1, k);
                        calcPool[i + 1, k] = true;
                    }
                    CalcVert(i + 1, k + 1);
                    calcPool[i + 1, k + 1] = true;
                    if (!calcPool[i, k + 1])
                    {
                        CalcVert(i, k + 1);
                        calcPool[i, k + 1] = true;
                    }
                    SurfaceNormal(normalPool, i, k, 0, *(vertsPool[i, k]), *(vertsPool[i + 1, k]), *(vertsPool[i, k + 1]));
                    SurfaceNormal(normalPool, i, k, 1, *(vertsPool[i, k + 1]), *(vertsPool[i + 1, k]), *(vertsPool[i + 1, k + 1]));
                }
            }
            int[,] colorMap = m_ColorMap;
            if (colorMap == null)
            {
                colorMap = m_ColorMap = new int[cellWidth, cellHeight];
            }
            int[,] numArray2 = m_ColorMap2;
            if (numArray2 == null)
            {
                numArray2 = m_ColorMap2 = new int[cellWidth, cellHeight];
            }
            for (int j = 1; j < (cellWidth - 1); j++)
            {
                byte[,] buffer2;
                IntPtr ptr;
                IntPtr ptr2;
                int[,] numArray3;
                for (int m = 1; m < (cellHeight - 1); m++)
                {
                    Vector vector  = *(normalPool[j, m, 0]);
                    Vector vector2 = *(normalPool[j - 1, m - 1, 1]);
                    Vector vector3 = *(normalPool[j - 1, m, 0]);
                    Vector vector4 = *(normalPool[j - 1, m, 1]);
                    Vector vector5 = *(normalPool[j, m - 1, 0]);
                    Vector vector6 = *(normalPool[j, m - 1, 1]);
                    float  num8    = ((((vector.m_X + vector2.m_X) + vector3.m_X) + vector4.m_X) + vector5.m_X) + vector6.m_X;
                    float  num9    = ((((vector.m_Y + vector2.m_Y) + vector3.m_Y) + vector4.m_Y) + vector5.m_Y) + vector6.m_Y;
                    float  num10   = ((((vector.m_Z + vector2.m_Z) + vector3.m_Z) + vector4.m_Z) + vector5.m_Z) + vector6.m_Z;
                    num8  *= 0.1666667f;
                    num9  *= 0.1666667f;
                    num10 *= 0.1666667f;
                    float num11 = (float)(1.0 / Math.Sqrt((double)(((num8 * num8) + (num9 * num9)) + (num10 * num10))));
                    num8  *= num11;
                    num9  *= num11;
                    num10 *= num11;
                    float num12 = ((num8 * vLight.m_X) + (num9 * vLight.m_Y)) + (num10 * vLight.m_Z);
                    num12 += 0.2151413f;
                    num12 += 0.8235294f;
                    int num13 = (int)((255f * num12) + 0.5f);
                    if (num13 < 0x80)
                    {
                        num13 = 0x80;
                    }
                    else if (num13 > 0xff)
                    {
                        num13 = 0xff;
                    }
                    numArray2[j, m] = colorMap[j, m] = 0x10101 * num13;
                    if (((!m_AlwaysStretch[m_CalcVert_Tiles[j - 1, m - 1].m_ID & 0x3fff] && (colorMap[j, m] == 0xd2d2d2)) && ((colorMap[j - 1, m] == 0xd2d2d2) && (colorMap[j - 1, m - 1] == 0xd2d2d2))) && (colorMap[j, m - 1] == 0xd2d2d2))
                    {
                        int z     = m_CalcVert_Tiles[j - 1, m - 1].m_Z;
                        int num15 = m_CalcVert_Tiles[j, m - 1].m_Z;
                        int num16 = m_CalcVert_Tiles[j, m].m_Z;
                        int num17 = m_CalcVert_Tiles[j - 1, m].m_Z;
                        if (((z == num15) && (z == num16)) && (z == num17))
                        {
                            (buffer2 = flags)[(int)(ptr = (IntPtr)(j - 1)), (int)(ptr2 = (IntPtr)(m - 1))] = (byte)(buffer2[(int)ptr, (int)ptr2] & ~num3);
                        }
                        else
                        {
                            (buffer2 = flags)[(int)(ptr = (IntPtr)(j - 1)), (int)(ptr2 = (IntPtr)(m - 1))] = (byte)(buffer2[(int)ptr, (int)ptr2] | num3);
                        }
                    }
                    else
                    {
                        (buffer2 = flags)[(int)(ptr = (IntPtr)(j - 1)), (int)(ptr2 = (IntPtr)(m - 1))] = (byte)(buffer2[(int)ptr, (int)ptr2] | num3);
                    }
                }
                (buffer2 = flags)[(int)(ptr = (IntPtr)j), 0] = (byte)(buffer2[(int)ptr, 0] | num3);
                (buffer2 = flags)[(int)(ptr = (IntPtr)j), (int)(ptr2 = (IntPtr)(cellHeight - 2))] = (byte)(buffer2[(int)ptr, (int)ptr2] | num3);
                (buffer2 = flags)[0, (int)(ptr = (IntPtr)j)] = (byte)(buffer2[0, (int)ptr] | num3);
                (buffer2 = flags)[(int)(ptr = (IntPtr)(cellWidth - 2)), (int)(ptr2 = (IntPtr)j)] = (byte)(buffer2[(int)ptr, (int)ptr2] | num3);
                numArray2[j, 0] = colorMap[j, 0] = 0;
                numArray2[j, cellHeight - 1] = colorMap[j, cellHeight - 1] = 0;
                numArray2[0, j]             = (numArray3 = colorMap)[0, (int)(ptr = (IntPtr)j)] = numArray3[0, (int)ptr] | num3;
                numArray2[cellWidth - 1, j] = colorMap[cellWidth - 1, j] = 0;
            }
            map.colorMap    = colorMap;
            map.realColors  = colorMap;
            map.frameColors = numArray2;
            map.flags       = flags;
        }