2020-06-21 18:40:37 -04:00
|
|
|
package d2mapengine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2020-06-23 01:05:01 -04:00
|
|
|
"strings"
|
2020-06-21 18:40:37 -04:00
|
|
|
|
2020-09-20 17:52:01 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2records"
|
|
|
|
|
2020-09-12 16:51:30 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2mapentity"
|
|
|
|
|
2020-09-12 16:25:09 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2ds1"
|
2020-06-21 18:40:37 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2dt1"
|
2020-09-12 16:25:09 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2geom"
|
2020-07-04 00:48:31 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
2020-09-12 16:25:09 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2asset"
|
2020-06-21 18:40:37 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core/d2map/d2mapstamp"
|
|
|
|
)
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// MapEngine loads the tiles which make up the isometric map and the entities
|
2020-06-21 18:40:37 -04:00
|
|
|
type MapEngine struct {
|
2020-09-12 16:51:30 -04:00
|
|
|
asset *d2asset.AssetManager
|
|
|
|
*d2mapstamp.StampFactory
|
|
|
|
*d2mapentity.MapEntityFactory
|
2020-08-05 21:27:45 -04:00
|
|
|
seed int64 // The map seed
|
|
|
|
entities map[string]d2interface.MapEntity // Entities on the map
|
2020-07-21 08:50:45 -04:00
|
|
|
tiles []MapTile
|
2020-09-20 17:52:01 -04:00
|
|
|
size d2geom.Size // Size of the map, in tiles
|
|
|
|
levelType d2records.LevelTypeRecord // Level type of this map
|
|
|
|
dt1TileData []d2dt1.Tile // DT1 tile data
|
|
|
|
startSubTileX int // Starting X position
|
|
|
|
startSubTileY int // Starting Y position
|
|
|
|
dt1Files []string // List of DS1 strings
|
2020-10-10 18:47:51 -04:00
|
|
|
// TODO: remove this flag and show loading screen until the initial server packets are handled and the map is generated (only for remote client)
|
2020-10-22 01:12:06 -04:00
|
|
|
IsLoading bool // (temp) Whether we have processed the GenerateMapPacket(only for remote client)
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
|
2020-10-22 10:02:32 -04:00
|
|
|
const (
|
|
|
|
subtilesPerTile = 5
|
|
|
|
)
|
|
|
|
|
2020-07-23 12:56:50 -04:00
|
|
|
// CreateMapEngine creates a new instance of the map engine and returns a pointer to it.
|
2020-09-12 16:51:30 -04:00
|
|
|
func CreateMapEngine(asset *d2asset.AssetManager) *MapEngine {
|
2020-09-20 17:52:01 -04:00
|
|
|
entity, _ := d2mapentity.NewMapEntityFactory(asset)
|
2020-09-12 16:51:30 -04:00
|
|
|
stamp := d2mapstamp.NewStampFactory(asset, entity)
|
|
|
|
|
|
|
|
engine := &MapEngine{
|
|
|
|
asset: asset,
|
|
|
|
MapEntityFactory: entity,
|
|
|
|
StampFactory: stamp,
|
2020-10-10 18:47:51 -04:00
|
|
|
// This will be set to true when we are using a remote client connection, and then set to false after we process the GenerateMapPacket
|
2020-10-22 01:12:06 -04:00
|
|
|
IsLoading: false,
|
2020-09-12 16:51:30 -04:00
|
|
|
}
|
|
|
|
|
2020-06-21 18:40:37 -04:00
|
|
|
return engine
|
|
|
|
}
|
|
|
|
|
2020-07-23 12:56:50 -04:00
|
|
|
// GetStartingPosition returns the starting position on the map in sub-tiles.
|
|
|
|
func (m *MapEngine) GetStartingPosition() (x, y int) {
|
2020-06-21 18:40:37 -04:00
|
|
|
return m.startSubTileX, m.startSubTileY
|
|
|
|
}
|
|
|
|
|
2020-07-23 12:56:50 -04:00
|
|
|
// ResetMap clears all map and entity data and reloads it from the cached files.
|
2020-06-21 23:23:00 -04:00
|
|
|
func (m *MapEngine) ResetMap(levelType d2enum.RegionIdType, width, height int) {
|
2020-08-05 21:27:45 -04:00
|
|
|
m.entities = make(map[string]d2interface.MapEntity)
|
2020-09-20 17:52:01 -04:00
|
|
|
m.levelType = *m.asset.Records.Level.Types[levelType]
|
2020-09-08 15:58:35 -04:00
|
|
|
m.size = d2geom.Size{Width: width, Height: height}
|
2020-07-21 08:50:45 -04:00
|
|
|
m.tiles = make([]MapTile, width*height)
|
2020-06-21 18:40:37 -04:00
|
|
|
m.dt1TileData = make([]d2dt1.Tile, 0)
|
2020-06-23 01:05:01 -04:00
|
|
|
m.dt1Files = make([]string, 0)
|
2020-06-21 18:40:37 -04:00
|
|
|
|
2020-06-24 14:35:49 -04:00
|
|
|
for idx := range m.levelType.Files {
|
|
|
|
m.addDT1(m.levelType.Files[idx])
|
2020-06-23 01:05:01 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (m *MapEngine) addDT1(fileName string) {
|
2020-07-21 08:50:45 -04:00
|
|
|
if fileName == "" || fileName == "0" {
|
2020-06-23 01:05:01 -04:00
|
|
|
return
|
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-23 01:05:01 -04:00
|
|
|
fileName = strings.ToLower(fileName)
|
|
|
|
for i := 0; i < len(m.dt1Files); i++ {
|
|
|
|
if m.dt1Files[i] == fileName {
|
|
|
|
return
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
}
|
2020-06-22 19:33:12 -04:00
|
|
|
|
2020-09-12 16:51:30 -04:00
|
|
|
fileData, err := m.asset.LoadFile("/data/global/tiles/" + fileName)
|
2020-06-23 01:05:01 -04:00
|
|
|
if err != nil {
|
2020-06-24 00:04:27 -04:00
|
|
|
log.Printf("Could not load /data/global/tiles/%s", fileName)
|
2020-07-09 16:11:01 -04:00
|
|
|
// panic(err)
|
2020-07-21 08:50:45 -04:00
|
|
|
return
|
2020-06-23 01:05:01 -04:00
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-09-23 13:30:54 -04:00
|
|
|
dt1, err := d2dt1.LoadDT1(fileData)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
2020-10-22 01:12:06 -04:00
|
|
|
|
2020-06-23 01:05:01 -04:00
|
|
|
m.dt1TileData = append(m.dt1TileData, dt1.Tiles...)
|
|
|
|
m.dt1Files = append(m.dt1Files, fileName)
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// AddDS1 loads DT1 files and performs string replacements on them. It
|
|
|
|
// appends the tile data and files to MapEngine.dt1TileData and
|
|
|
|
// MapEngine.dt1Files.
|
2020-06-23 01:05:01 -04:00
|
|
|
func (m *MapEngine) AddDS1(fileName string) {
|
2020-07-21 08:50:45 -04:00
|
|
|
if fileName == "" || fileName == "0" {
|
2020-06-23 01:05:01 -04:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-09-12 16:51:30 -04:00
|
|
|
fileData, err := m.asset.LoadFile("/data/global/tiles/" + fileName)
|
2020-06-23 01:05:01 -04:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-09-23 13:30:54 -04:00
|
|
|
ds1, err := d2ds1.LoadDS1(fileData)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-24 14:35:49 -04:00
|
|
|
for idx := range ds1.Files {
|
|
|
|
dt1File := ds1.Files[idx]
|
|
|
|
dt1File = strings.ToLower(dt1File)
|
2020-07-21 08:50:45 -04:00
|
|
|
dt1File = strings.ReplaceAll(dt1File, "c:", "") // Yes they did...
|
|
|
|
dt1File = strings.ReplaceAll(dt1File, ".tg1", ".dt1") // Yes they did...
|
|
|
|
dt1File = strings.ReplaceAll(dt1File, "\\d2\\data\\global\\tiles\\", "")
|
|
|
|
m.addDT1(strings.ReplaceAll(dt1File, "\\", "/"))
|
2020-06-23 01:05:01 -04:00
|
|
|
}
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// LevelType returns the level type of this map.
|
2020-09-20 17:52:01 -04:00
|
|
|
func (m *MapEngine) LevelType() d2records.LevelTypeRecord {
|
2020-06-21 18:40:37 -04:00
|
|
|
return m.levelType
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// SetSeed sets the seed of the map for generation.
|
2020-06-21 18:40:37 -04:00
|
|
|
func (m *MapEngine) SetSeed(seed int64) {
|
|
|
|
log.Printf("Setting map engine seed to %d", seed)
|
|
|
|
m.seed = seed
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// Size returns the size of the map in sub-tiles.
|
2020-09-08 15:58:35 -04:00
|
|
|
func (m *MapEngine) Size() d2geom.Size {
|
2020-06-21 18:40:37 -04:00
|
|
|
return m.size
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// Tile returns the TileRecord containing the data
|
|
|
|
// for a single map tile.
|
2020-07-21 08:50:45 -04:00
|
|
|
func (m *MapEngine) Tile(x, y int) *MapTile {
|
2020-06-24 00:04:27 -04:00
|
|
|
return &m.tiles[x+(y*m.size.Width)]
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// Tiles returns a pointer to a slice contaning all
|
|
|
|
// map tile data.
|
2020-07-21 08:50:45 -04:00
|
|
|
func (m *MapEngine) Tiles() *[]MapTile {
|
2020-06-21 18:40:37 -04:00
|
|
|
return &m.tiles
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// PlaceStamp places a map stamp at the specified location, creating both entities
|
|
|
|
// and tiles. Stamps are pre-defined map areas, see d2mapstamp.
|
2020-06-21 18:40:37 -04:00
|
|
|
func (m *MapEngine) PlaceStamp(stamp *d2mapstamp.Stamp, tileOffsetX, tileOffsetY int) {
|
|
|
|
stampSize := stamp.Size()
|
2020-06-24 08:10:48 -04:00
|
|
|
stampW := stampSize.Width
|
|
|
|
stampH := stampSize.Height
|
|
|
|
|
|
|
|
mapW := m.size.Width
|
|
|
|
mapH := m.size.Height
|
|
|
|
|
|
|
|
xMin := tileOffsetX
|
|
|
|
yMin := tileOffsetY
|
|
|
|
xMax := xMin + stampSize.Width
|
|
|
|
yMax := yMin + stampSize.Height
|
|
|
|
|
|
|
|
if (xMin < 0) || (yMin < 0) || (xMax > mapW) || (yMax > mapH) {
|
2020-06-21 18:40:37 -04:00
|
|
|
panic("Tried placing a stamp outside the bounds of the map")
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy over the map tile data
|
2020-06-24 08:10:48 -04:00
|
|
|
for y := 0; y < stampH; y++ {
|
|
|
|
for x := 0; x < stampW; x++ {
|
2020-08-05 21:27:45 -04:00
|
|
|
targetTileIndex := m.tileCoordinateToIndex(x+xMin, y+yMin)
|
2020-06-24 08:10:48 -04:00
|
|
|
stampTile := *stamp.Tile(x, y)
|
2020-07-21 08:50:45 -04:00
|
|
|
m.tiles[targetTileIndex].RegionType = stamp.RegionID()
|
|
|
|
m.tiles[targetTileIndex].Components = stampTile
|
|
|
|
m.tiles[targetTileIndex].PrepareTile(x, y, m)
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy over the entities
|
2020-08-05 21:27:45 -04:00
|
|
|
stampEntities := stamp.Entities(tileOffsetX, tileOffsetY)
|
|
|
|
for idx := range stampEntities {
|
|
|
|
e := stampEntities[idx]
|
|
|
|
m.entities[e.ID()] = e
|
|
|
|
}
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
|
2020-06-24 08:10:48 -04:00
|
|
|
// converts x,y tile coordinate into index in MapEngine.tiles
|
|
|
|
func (m *MapEngine) tileCoordinateToIndex(x, y int) int {
|
2020-06-24 14:35:49 -04:00
|
|
|
return x + (y * m.size.Width)
|
2020-06-24 08:10:48 -04:00
|
|
|
}
|
|
|
|
|
2020-08-05 21:27:45 -04:00
|
|
|
// tileIndexToCoordinate converts tile index from MapEngine.tiles to x,y coordinate
|
2020-07-23 12:56:50 -04:00
|
|
|
func (m *MapEngine) tileIndexToCoordinate(index int) (x, y int) {
|
|
|
|
return index % m.size.Width, index / m.size.Width
|
2020-06-24 08:10:48 -04:00
|
|
|
}
|
|
|
|
|
2020-07-21 08:50:45 -04:00
|
|
|
// SubTileAt gets the flags for the given subtile
|
|
|
|
func (m *MapEngine) SubTileAt(subX, subY int) *d2dt1.SubTileFlags {
|
2020-10-22 10:02:32 -04:00
|
|
|
tile := m.TileAt(subX/subtilesPerTile, subY/subtilesPerTile)
|
2020-07-21 08:50:45 -04:00
|
|
|
|
2020-10-22 10:02:32 -04:00
|
|
|
return tile.GetSubTileFlags(subX%subtilesPerTile, subY%subtilesPerTile)
|
2020-07-21 08:50:45 -04:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// TileAt returns a pointer to the data for the map tile at the given
|
|
|
|
// x and y index.
|
2020-07-21 08:50:45 -04:00
|
|
|
func (m *MapEngine) TileAt(tileX, tileY int) *MapTile {
|
2020-06-24 08:10:48 -04:00
|
|
|
idx := m.tileCoordinateToIndex(tileX, tileY)
|
2020-06-21 18:40:37 -04:00
|
|
|
if idx < 0 || idx >= len(m.tiles) {
|
|
|
|
return nil
|
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-21 18:40:37 -04:00
|
|
|
return &m.tiles[idx]
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// Entities returns a pointer a slice of all map entities.
|
2020-08-05 21:27:45 -04:00
|
|
|
func (m *MapEngine) Entities() map[string]d2interface.MapEntity {
|
|
|
|
return m.entities
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// Seed returns the map generation seed.
|
2020-06-21 18:40:37 -04:00
|
|
|
func (m *MapEngine) Seed() int64 {
|
|
|
|
return m.seed
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// AddEntity adds an entity to a slice containing all entities.
|
2020-07-04 00:48:31 -04:00
|
|
|
func (m *MapEngine) AddEntity(entity d2interface.MapEntity) {
|
2020-08-05 21:27:45 -04:00
|
|
|
m.entities[entity.ID()] = entity
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
|
2020-08-05 21:27:45 -04:00
|
|
|
// RemoveEntity removes an entity from the map engine
|
2020-07-04 00:48:31 -04:00
|
|
|
func (m *MapEngine) RemoveEntity(entity d2interface.MapEntity) {
|
2020-06-21 18:40:37 -04:00
|
|
|
if entity == nil {
|
|
|
|
return
|
|
|
|
}
|
2020-08-05 21:27:45 -04:00
|
|
|
|
|
|
|
delete(m.entities, entity.ID())
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// GetTiles returns a slice of all tiles matching the given style,
|
|
|
|
// sequence and tileType.
|
2020-10-25 03:42:31 -04:00
|
|
|
func (m *MapEngine) GetTiles(style, sequence int, tileType d2enum.TileType) []d2dt1.Tile {
|
2020-07-23 12:56:50 -04:00
|
|
|
tiles := make([]d2dt1.Tile, 0, len(m.dt1TileData))
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-24 14:35:49 -04:00
|
|
|
for idx := range m.dt1TileData {
|
2020-07-21 08:50:45 -04:00
|
|
|
if m.dt1TileData[idx].Style != int32(style) || m.dt1TileData[idx].Sequence != int32(sequence) ||
|
|
|
|
m.dt1TileData[idx].Type != int32(tileType) {
|
2020-06-21 18:40:37 -04:00
|
|
|
continue
|
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-24 14:35:49 -04:00
|
|
|
tiles = append(tiles, m.dt1TileData[idx])
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-21 18:40:37 -04:00
|
|
|
if len(tiles) == 0 {
|
|
|
|
log.Printf("Unknown tile ID [%d %d %d]\n", style, sequence, tileType)
|
|
|
|
return nil
|
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-21 18:40:37 -04:00
|
|
|
return tiles
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// GetStartPosition returns the spawn point on entering the current map.
|
2020-07-23 12:56:50 -04:00
|
|
|
func (m *MapEngine) GetStartPosition() (x, y float64) {
|
2020-06-21 18:40:37 -04:00
|
|
|
for tileY := 0; tileY < m.size.Height; tileY++ {
|
|
|
|
for tileX := 0; tileX < m.size.Width; tileX++ {
|
2020-07-21 08:50:45 -04:00
|
|
|
tile := m.tiles[tileX+(tileY*m.size.Width)].Components
|
2020-06-24 14:35:49 -04:00
|
|
|
for idx := range tile.Walls {
|
|
|
|
if tile.Walls[idx].Type.Special() && tile.Walls[idx].Style == 30 {
|
2020-06-21 18:40:37 -04:00
|
|
|
return float64(tileX) + 0.5, float64(tileY) + 0.5
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return m.GetCenterPosition()
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// GetCenterPosition returns the center point of the map.
|
2020-07-23 12:56:50 -04:00
|
|
|
func (m *MapEngine) GetCenterPosition() (x, y float64) {
|
2020-06-21 18:40:37 -04:00
|
|
|
return float64(m.size.Width) / 2.0, float64(m.size.Height) / 2.0
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// Advance calls the Advance() method for all entities,
|
|
|
|
// processing a single tick.
|
2020-06-21 18:40:37 -04:00
|
|
|
func (m *MapEngine) Advance(tickTime float64) {
|
2020-10-10 18:47:51 -04:00
|
|
|
// TODO:(temp hack) prevents concurrent map read & write exceptions that occur when we join a TCP game as a remote client
|
|
|
|
// due to the engine updating entities before handling the GenerateMapPacket
|
|
|
|
if m.IsLoading {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2020-08-05 21:27:45 -04:00
|
|
|
for ID := range m.entities {
|
|
|
|
m.entities[ID].Advance(tickTime)
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// TileExists returns true if the tile at the given coordinates exists.
|
2020-06-21 18:40:37 -04:00
|
|
|
func (m *MapEngine) TileExists(tileX, tileY int) bool {
|
2020-06-24 08:10:48 -04:00
|
|
|
tileIndex := m.tileCoordinateToIndex(tileX, tileY)
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-24 08:10:48 -04:00
|
|
|
if valid := (tileIndex >= 0) && (tileIndex <= len(m.tiles)); valid {
|
2020-07-21 08:50:45 -04:00
|
|
|
tile := m.tiles[tileIndex].Components
|
2020-06-24 08:10:48 -04:00
|
|
|
numFeatures := len(tile.Floors)
|
|
|
|
numFeatures += len(tile.Shadows)
|
|
|
|
numFeatures += len(tile.Walls)
|
|
|
|
numFeatures += len(tile.Substitutions)
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-24 08:10:48 -04:00
|
|
|
return numFeatures > 0
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-24 08:10:48 -04:00
|
|
|
return false
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// GenerateMap clears the map and places the specified stamp.
|
2020-07-23 12:56:50 -04:00
|
|
|
func (m *MapEngine) GenerateMap(regionType d2enum.RegionIdType, levelPreset, fileIndex int) {
|
2020-09-12 16:51:30 -04:00
|
|
|
region := m.LoadStamp(regionType, levelPreset, fileIndex)
|
2020-06-21 18:40:37 -04:00
|
|
|
regionSize := region.Size()
|
2020-06-21 23:23:00 -04:00
|
|
|
m.ResetMap(regionType, regionSize.Width, regionSize.Height)
|
2020-06-21 18:40:37 -04:00
|
|
|
m.PlaceStamp(region, 0, 0)
|
|
|
|
}
|
|
|
|
|
2020-07-21 08:50:45 -04:00
|
|
|
// GetTileData returns the tile with the given style, sequence, tileType and index.
|
|
|
|
func (m *MapEngine) GetTileData(style, sequence int, tileType d2enum.TileType, index byte) *d2dt1.Tile {
|
2020-06-24 14:35:49 -04:00
|
|
|
for idx := range m.dt1TileData {
|
2020-07-21 08:50:45 -04:00
|
|
|
if m.dt1TileData[idx].Style == int32(style) && m.dt1TileData[idx].Sequence == int32(sequence) &&
|
|
|
|
m.dt1TileData[idx].Type == int32(tileType) && m.dt1TileData[idx].RarityFrameIndex == int32(index) {
|
2020-06-24 14:35:49 -04:00
|
|
|
return &m.dt1TileData[idx]
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-21 18:40:37 -04:00
|
|
|
return nil
|
|
|
|
}
|