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; }
private unsafe void Load() { int size = FileManager.Map.MapsDefaultSize[World.MapIndex, 0] * FileManager.Map.MapsDefaultSize[World.MapIndex, 1]; ushort[] buffer = new ushort[size]; int maxBlock = size - 1; for (int bx = 0; bx < FileManager.Map.MapBlocksSize[World.MapIndex, 0]; bx++) { int mapX = bx << 3; for (int by = 0; by < FileManager.Map.MapBlocksSize[World.MapIndex, 1]; by++) { IndexMap indexMap = World.Map.GetIndex(bx, by); if (indexMap.MapAddress == 0) { continue; } int mapY = by << 3; MapBlock info = new MapBlock(); MapCells *infoCells = (MapCells *)&info.Cells; MapBlock *mapBlock = (MapBlock *)indexMap.MapAddress; MapCells *cells = (MapCells *)&mapBlock->Cells; int pos = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { ref MapCells cell = ref cells[pos]; ref MapCells infoCell = ref infoCells[pos]; infoCell.TileID = cell.TileID; infoCell.Z = cell.Z; pos++; } } StaticsBlock *sb = (StaticsBlock *)indexMap.StaticAddress; if (sb != null) { int count = (int)indexMap.StaticCount; for (int c = 0; c < count; c++) { ref readonly StaticsBlock staticBlock = ref sb[c];
public unsafe void LoadLand(int map) { IndexMap im = GetIndex(map); if (im.MapAddress != 0) { MapBlock *block = (MapBlock *)im.MapAddress; MapCells *cells = (MapCells *)&block->Cells; int bx = X * 8; int by = Y * 8; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int pos = y * 8 + x; ushort tileID = (ushort)(cells[pos].TileID & 0x3FFF); sbyte z = cells[pos].Z; Land land = new Land(tileID) { Graphic = tileID, AverageZ = z, MinZ = z, }; ushort tileX = (ushort)(bx + x); ushort tileY = (ushort)(by + y); land.Calculate(tileX, tileY, z); land.Position = new Position(tileX, tileY, z); land.AddToTile(Tiles[x, y]); } } } }
private unsafe void Load() { int size = IO.Resources.Map.MapsDefaultSize[World.MapIndex][0] * IO.Resources.Map.MapsDefaultSize[World.MapIndex][1]; ushort[] buffer = new ushort[size]; int maxBlock = size - 1; for (int bx = 0; bx < IO.Resources.Map.MapBlocksSize[World.MapIndex][0]; bx++) { int mapX = bx * 8; for (int by = 0; by < IO.Resources.Map.MapBlocksSize[World.MapIndex][1]; by++) { IndexMap indexMap = World.Map.GetIndex(bx, by); if (indexMap.MapAddress == 0) { continue; } int mapY = by * 8; MapBlock info = new MapBlock(); MapCells *infoCells = (MapCells *)&info.Cells; MapBlock *mapBlock = (MapBlock *)indexMap.MapAddress; MapCells *cells = (MapCells *)&mapBlock->Cells; int pos = 0; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { ref MapCells cell = ref cells[pos]; ref MapCells infoCell = ref infoCells[pos]; infoCell.TileID = cell.TileID; infoCell.Z = cell.Z; pos++; } } StaticsBlock *sb = (StaticsBlock *)indexMap.StaticAddress; if (sb != null) { int count = (int)indexMap.StaticCount; for (int c = 0; c < count; c++) { StaticsBlock staticBlock = sb[c]; if (staticBlock.Color > 0 && staticBlock.Color != 0xFFFF && !View.IsNoDrawable(staticBlock.Color)) { pos = staticBlock.Y * 8 + staticBlock.X; ref MapCells cell = ref infoCells[pos]; if (cell.Z <= staticBlock.Z) { cell.TileID = (ushort)(staticBlock.Color + 0x4000); cell.Z = staticBlock.Z; } } } }
public unsafe void Load(int map) { IndexMap im = GetIndex(map); if (im.MapAddress != 0) { MapBlock *block = (MapBlock *)im.MapAddress; MapCells *cells = (MapCells *)&block->Cells; int bx = X * 8; int by = Y * 8; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int pos = y * 8 + x; ushort tileID = (ushort)(cells[pos].TileID & 0x3FFF); sbyte z = cells[pos].Z; Land land = new Land(tileID) { Graphic = tileID, AverageZ = z, MinZ = z, }; ushort tileX = (ushort)(bx + x); ushort tileY = (ushort)(by + y); land.Calculate(tileX, tileY, z); land.Position = new Position(tileX, tileY, z); land.AddToTile(Tiles[x, y]); } } if (im.StaticAddress != 0) { StaticsBlock *sb = (StaticsBlock *)im.StaticAddress; if (sb != null) { int count = (int)im.StaticCount; for (int i = 0; i < count; i++, sb++) { if (sb->Color != 0 && sb->Color != 0xFFFF) { ushort x = sb->X; ushort y = sb->Y; int pos = y * 8 + x; if (pos >= 64) { continue; } sbyte z = sb->Z; ushort staticX = (ushort)(bx + x); ushort staticY = (ushort)(by + y); Static staticObject = new Static(sb->Color, sb->Hue, pos) { Position = new Position(staticX, staticY, z) }; if (staticObject.ItemData.IsAnimated) { World.AddEffect(new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1)); } else { staticObject.AddToTile(Tiles[x, y]); } } } } } //CreateLand(); } }
public unsafe void Load(int map) { IndexMap im = GetIndex(map); if (im.MapAddress != 0) { MapBlock *block = (MapBlock *)im.MapAddress; MapCells *cells = (MapCells *)&block->Cells; int bx = X * 8; int by = Y * 8; for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int pos = y * 8 + x; ushort tileID = (ushort)(cells[pos].TileID & 0x3FFF); sbyte z = cells[pos].Z; LandTiles info = TileData.LandData[tileID]; Land land = new Land(tileID) { Graphic = tileID, AverageZ = z, MinZ = z, IsStretched = info.TexID == 0 && TileData.IsWet(info.Flags), }; ushort tileX = (ushort)(bx + x); ushort tileY = (ushort)(by + y); land.Calculate(tileX, tileY, z); land.Position = new Position(tileX, tileY, z); } } if (im.StaticAddress != 0) { StaticsBlock *sb = (StaticsBlock *)im.StaticAddress; if (sb != null) { int count = (int)im.StaticCount; for (int i = 0; i < count; i++, sb++) { if (sb->Color > 0 && sb->Color != 0xFFFF) { ushort x = sb->X; ushort y = sb->Y; int pos = y * 8 + x; if (pos >= 64) { continue; } sbyte z = sb->Z; Static staticObject = new Static(sb->Color, sb->Hue, pos) { Position = new Position((ushort)(bx + x), (ushort)(by + y), z) }; if (TileData.IsAnimated(staticObject.ItemData.Flags)) { staticObject.Effect = new AnimatedItemEffect(staticObject, staticObject.Graphic, staticObject.Hue, -1); } } } } } } }
private unsafe 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]; int index = _useLargeMap ? 1 : 0; _blankGumpsPixels[index].CopyTo(_blankGumpsPixels[index + 2], 0); uint[] data = _blankGumpsPixels[index + 2]; Point *table = stackalloc Point[2]; table[0].X = 0; table[0].Y = 0; table[1].X = 0; table[1].Y = 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; } ref IndexMap indexMap = ref World.Map.GetIndex(i, j); if (indexMap.MapAddress == 0) { break; } MapBlock * mp = (MapBlock *)indexMap.MapAddress; MapCells * cells = (MapCells *)&mp->Cells; StaticsBlock *sb = (StaticsBlock *)indexMap.StaticAddress; uint staticCount = indexMap.StaticCount; Chunk block = World.Map.GetChunk(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++) { ref MapCells cell = ref cells[(y << 3) + x]; int color = cell.TileID; bool isLand = true; int z = cell.Z; for (int c = 0; c < staticCount; ++c) { ref StaticsBlock stblock = ref sb[c]; if (stblock.X == x && stblock.Y == y && stblock.Color > 0 && stblock.Color != 0xFFFF && GameObject.CanBeDrawn(stblock.Color)) { if (stblock.Z >= z) { color = stblock.Hue > 0 ? (ushort)(stblock.Hue + 0x4000) : stblock.Color; isLand = stblock.Hue > 0; z = stblock.Z; } } } 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); } int py = realBlockY + y - lastY; int gx = px - py; int gy = px + py; CreatePixels ( data, 0x8000 | color, gx, gy, Width, Height, table, tableSize ); } }