public static unsafe RadarMapBlock?GetRadarMapBlock(int map, int blockX, int blockY) { IndexMap indexMap = GetIndex(map, blockX, blockY); if (indexMap.MapAddress == 0) { return(null); } MapBlock *mp = (MapBlock *)indexMap.MapAddress; MapCells *cells = (MapCells *)&mp->Cells; RadarMapBlock mb = new RadarMapBlock { Cells = new RadarMapcells[8, 8] }; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { ref MapCells cell = ref cells[y * 8 + x]; ref RadarMapcells outcell = ref mb.Cells[x, y]; outcell.Graphic = cell.TileID; outcell.Z = cell.Z; outcell.IsLand = true; }
public static unsafe RadarMapBlock?GetRadarMapBlock(int map, int blockX, int blockY) { IndexMap indexMap = GetIndex(map, blockX, blockY); if (indexMap == null || indexMap.MapAddress == 0) { return(null); } MapBlock block = Marshal.PtrToStructure <MapBlock>((IntPtr)indexMap.MapAddress); RadarMapBlock mb = new RadarMapBlock(); mb.Cells = new RadarMapcells[8, 8]; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { ref MapCells cell = ref block.Cells[y * 8 + x]; ref RadarMapcells outcell = ref mb.Cells[x, y]; outcell.Graphic = cell.TileID; outcell.Z = cell.Z; outcell.IsLand = true; }
private void CreateMiniMapTexture(bool force = false) { if (_gumpTexture == null || _gumpTexture.IsDisposed) { return; } ushort lastX = World.Player.X; ushort lastY = World.Player.Y; if (_x != lastX || _y != lastY) { _x = lastX; _y = lastY; } else if (!force) { return; } int blockOffsetX = Width >> 2; int blockOffsetY = Height >> 2; int gumpCenterX = Width >> 1; //int gumpCenterY = Height >> 1; //0xFF080808 - pixel32 //0x8421 - pixel16 int minBlockX = ((lastX - blockOffsetX) >> 3) - 1; int minBlockY = ((lastY - blockOffsetY) >> 3) - 1; int maxBlockX = ((lastX + blockOffsetX) >> 3) + 1; int maxBlockY = ((lastY + blockOffsetY) >> 3) + 1; if (minBlockX < 0) { minBlockX = 0; } if (minBlockY < 0) { minBlockY = 0; } int maxBlockIndex = World.Map.BlocksCount; int mapBlockHeight = MapLoader.Instance.MapBlocksSize[World.MapIndex, 1]; uint[] data = GumpsLoader.Instance.GetGumpPixels(_useLargeMap ? (uint)5011 : 5010, out _, out _); Point[] table = new Point[2] { new Point(0, 0), new Point(0, 1) }; for (int i = minBlockX; i <= maxBlockX; i++) { int blockIndexOffset = i * mapBlockHeight; for (int j = minBlockY; j <= maxBlockY; j++) { int blockIndex = blockIndexOffset + j; if (blockIndex >= maxBlockIndex) { break; } RadarMapBlock?mbbv = MapLoader.Instance.GetRadarMapBlock(World.MapIndex, i, j); if (!mbbv.HasValue) { break; } RadarMapBlock mb = mbbv.Value; Chunk block = World.Map.Chunks[blockIndex]; int realBlockX = i << 3; int realBlockY = j << 3; for (int x = 0; x < 8; x++) { int px = realBlockX + x - lastX + gumpCenterX; for (int y = 0; y < 8; y++) { int py = realBlockY + y - lastY; int gx = px - py; int gy = px + py; int color = mb.Cells[x, y].Graphic; bool island = mb.Cells[x, y].IsLand; if (block != null) { GameObject obj = block.Tiles[x, y]; while (obj?.TNext != null) { obj = obj.TNext; } for (; obj != null; obj = obj.TPrevious) { if (obj is Multi) { if (obj.Hue == 0) { color = obj.Graphic; island = false; } else { color = obj.Hue + 0x4000; } break; } } } if (!island) { color += 0x4000; } int tableSize = 2; if (island && color > 0x4000) { color = HuesLoader.Instance.GetColor16(16384, (ushort)(color - 0x4000)); //28672 is an arbitrary position in hues.mul, is the 14 position in the range } else { color = HuesLoader.Instance.GetRadarColorData(color); } CreatePixels ( data, 0x8000 | color, gx, gy, Width, Height, table, tableSize ); } } } } if (_mapTexture == null || _mapTexture.IsDisposed) { _mapTexture = new UOTexture(Width, Height); } _mapTexture.PushData(data); }
private void CreateMiniMapTexture() { if (_gumpTexture == null || _gumpTexture.IsDisposed) { return; } ushort lastX = World.Player.Position.X; ushort lastY = World.Player.Position.Y; if (_x != lastX || _y != lastY) { _x = lastX; _y = lastY; } else if (!_forceUpdate) { return; } if (_mapTexture != null && !_mapTexture.IsDisposed) { _mapTexture.Dispose(); } int blockOffsetX = Width / 4; int blockOffsetY = Height / 4; int gumpCenterX = Width / 2; int gumpCenterY = Height / 2; //0xFF080808 - pixel32 //0x8421 - pixel16 int minBlockX = (lastX - blockOffsetX) / 8 - 1; int minBlockY = (lastY - blockOffsetY) / 8 - 1; int maxBlockX = (lastX + blockOffsetX) / 8 + 1; int maxBlockY = (lastY + blockOffsetY) / 8 + 1; if (minBlockX < 0) { minBlockX = 0; } if (minBlockY < 0) { minBlockY = 0; } int maxBlockIndex = World.Map.MapBlockIndex; int mapBlockHeight = IO.Resources.Map.MapBlocksSize[World.MapIndex][1]; ushort[] data = IO.Resources.Gumps.GetGumpPixels(_useLargeMap ? 5011 : 5010, out _, out _); Point[] table = new Point[2] { new Point(0, 0), new Point(0, 1) }; for (int i = minBlockX; i <= maxBlockX; i++) { int blockIndexOffset = i * mapBlockHeight; for (int j = minBlockY; j <= maxBlockY; j++) { int blockIndex = blockIndexOffset + j; if (blockIndex >= maxBlockIndex) { break; } RadarMapBlock?mbbv = IO.Resources.Map.GetRadarMapBlock(World.MapIndex, i, j); if (!mbbv.HasValue) { break; } RadarMapBlock mb = mbbv.Value; MapChunk mapBlock = World.Map.Chunks[blockIndex]; int realBlockX = i * 8; int realBlockY = j * 8; for (int x = 0; x < 8; x++) { int px = realBlockX + x - lastX + gumpCenterX; for (int y = 0; y < 8; y++) { int py = realBlockY + y - lastY; int gx = px - py; int gy = px + py; uint color = mb.Cells[x, y].Graphic; bool island = mb.Cells[x, y].IsLand; //if (mapBlock != null) //{ // ushort multicolor = mapBlock.get //} if (!island) { color += 0x4000; } int tableSize = 2; color = (uint)(0x8000 | Hues.GetRadarColorData((int)color)); CreatePixels(data, (int)color, gx, gy, Width, Height, table, tableSize); } } } } _mapTexture = new SpriteTexture(Width, Height, false); _mapTexture.SetData(data); }
private void CreateMiniMapTexture(bool force = false) { if (_gumpTexture == null || _gumpTexture.IsDisposed) { return; } ushort lastX = World.Player.Position.X; ushort lastY = World.Player.Position.Y; if (_x != lastX || _y != lastY) { _x = lastX; _y = lastY; } else if (!force) { return; } if (_mapTexture != null && !_mapTexture.IsDisposed) { _mapTexture.Dispose(); } int blockOffsetX = Width >> 2; int blockOffsetY = Height >> 2; int gumpCenterX = Width >> 1; int gumpCenterY = Height >> 1; //0xFF080808 - pixel32 //0x8421 - pixel16 int minBlockX = ((lastX - blockOffsetX) >> 3) - 1; int minBlockY = ((lastY - blockOffsetY) >> 3) - 1; int maxBlockX = ((lastX + blockOffsetX) >> 3) + 1; int maxBlockY = ((lastY + blockOffsetY) >> 3) + 1; if (minBlockX < 0) { minBlockX = 0; } if (minBlockY < 0) { minBlockY = 0; } int maxBlockIndex = World.Map.MapBlockIndex; int mapBlockHeight = FileManager.Map.MapBlocksSize[World.MapIndex, 1]; ushort[] data = FileManager.Gumps.GetGumpPixels(_useLargeMap ? (uint)5011 : 5010, out _, out _); Point[] table = new Point[2] { new Point(0, 0), new Point(0, 1) }; for (int i = minBlockX; i <= maxBlockX; i++) { int blockIndexOffset = i * mapBlockHeight; for (int j = minBlockY; j <= maxBlockY; j++) { int blockIndex = blockIndexOffset + j; if (blockIndex >= maxBlockIndex) { break; } RadarMapBlock?mbbv = FileManager.Map.GetRadarMapBlock(World.MapIndex, i, j); if (!mbbv.HasValue) { break; } RadarMapBlock mb = mbbv.Value; Chunk block = World.Map.Chunks[blockIndex]; int realBlockX = i << 3; int realBlockY = j << 3; for (int x = 0; x < 8; x++) { int px = realBlockX + x - lastX + gumpCenterX; for (int y = 0; y < 8; y++) { int py = realBlockY + y - lastY; int gx = px - py; int gy = px + py; uint color = mb.Cells[x, y].Graphic; bool island = mb.Cells[x, y].IsLand; if (block != null) { GameObject obj = block.Tiles[x, y].FirstNode; while (obj?.Right != null) { obj = obj.Right; } for (; obj != null; obj = obj.Left) { if (obj is Multi) { color = obj.Graphic; island = false; break; } } } if (!island) { color += 0x4000; } int tableSize = 2; color = (uint)(0x8000 | FileManager.Hues.GetRadarColorData((int)color)); CreatePixels(data, (int)color, gx, gy, Width, Height, table, tableSize); } } } } _mapTexture = new UOTexture16(Width, Height); _mapTexture.PushData(data); }