Пример #1
0
 static MapLighting()
 {
     vLight = vLight.Normalize();
 }
Пример #2
0
 public static void SurfaceNormal(Vector[,,] vNormal, int x, int y, int z, Vector v1, Vector v2, Vector v3)
 {
     float num = v1.m_X - v2.m_X;
     float num2 = v1.m_Y - v2.m_Y;
     float num3 = v1.m_Z - v2.m_Z;
     float num4 = v3.m_X - v1.m_X;
     float num5 = v3.m_Y - v1.m_Y;
     float num6 = v3.m_Z - v1.m_Z;
     float num7 = (num2 * num6) - (num3 * num5);
     float num8 = (num3 * num4) - (num * num6);
     float num9 = (num * num5) - (num2 * num4);
     float num10 = (float) (1.0 / Math.Sqrt((double) (((num7 * num7) + (num8 * num8)) + (num9 * num9))));
     vNormal[x, y, z].m_X = num7 * num10;
     vNormal[x, y, z].m_Y = num8 * num10;
     vNormal[x, y, z].m_Z = num9 * num10;
 }
Пример #3
0
 public Vector Cross(Vector v)
 {
     return new Vector((this.m_Y * v.m_Z) - (this.m_Z * v.m_Y), (this.m_Z * v.m_X) - (this.m_X * v.m_Z), (this.m_X * v.m_Y) - (this.m_Y * v.m_X));
 }
Пример #4
0
 public float Dot(Vector v)
 {
     return (((this.m_X * v.m_X) + (this.m_Y * v.m_Y)) + (this.m_Z * v.m_Z));
 }
Пример #5
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;
 }