Documentation ¶
Overview ¶
Package d2mapengine provides a map engine, something that can place diablo tile data onto a plane.
Index ¶
- type MapEngine
- func (m *MapEngine) AddDS1(fileName string)
- func (m *MapEngine) AddEntity(entity d2interface.MapEntity)
- func (m *MapEngine) Advance(tickTime float64)
- func (m *MapEngine) Entities() map[string]d2interface.MapEntity
- func (m *MapEngine) GenerateMap(regionType d2enum.RegionIdType, levelPreset, fileIndex int)
- func (m *MapEngine) GetCenterPosition() (x, y float64)
- func (m *MapEngine) GetStartPosition() (x, y float64)
- func (m *MapEngine) GetStartingPosition() (x, y int)
- func (m *MapEngine) GetTileData(style, sequence int, tileType d2enum.TileType, index byte) *d2dt1.Tile
- func (m *MapEngine) GetTiles(style, sequence int, tileType d2enum.TileType) []d2dt1.Tile
- func (m *MapEngine) LevelType() d2records.LevelTypeRecord
- func (m *MapEngine) PathFind(start, dest d2vector.Position) []d2vector.Position
- func (m *MapEngine) PlaceStamp(stamp *d2mapstamp.Stamp, tileOffsetX, tileOffsetY int)
- func (m *MapEngine) RemoveEntity(entity d2interface.MapEntity)
- func (m *MapEngine) ResetMap(levelType d2enum.RegionIdType, width, height int)
- func (m *MapEngine) Seed() int64
- func (m *MapEngine) SetSeed(seed int64)
- func (m *MapEngine) Size() d2geom.Size
- func (m *MapEngine) SubTileAt(subX, subY int) *d2dt1.SubTileFlags
- func (m *MapEngine) Tile(x, y int) *MapTile
- func (m *MapEngine) TileAt(tileX, tileY int) *MapTile
- func (m *MapEngine) TileExists(tileX, tileY int) bool
- func (m *MapEngine) Tiles() *[]MapTile
- type MapTile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MapEngine ¶
type MapEngine struct { *d2mapstamp.StampFactory *d2mapentity.MapEntityFactory // https://github.com/OpenDiablo2/OpenDiablo2/issues/789 IsLoading bool // (temp) Whether we have processed the GenerateMapPacket(only for remote client) *d2util.Logger // contains filtered or unexported fields }
MapEngine loads the tiles which make up the isometric map and the entities
func CreateMapEngine ¶
func CreateMapEngine(l d2util.LogLevel, asset *d2asset.AssetManager) *MapEngine
CreateMapEngine creates a new instance of the map engine and returns a pointer to it.
func (*MapEngine) AddDS1 ¶
AddDS1 loads DT1 files and performs string replacements on them. It appends the tile data and files to MapEngine.dt1TileData and MapEngine.dt1Files.
func (*MapEngine) AddEntity ¶
func (m *MapEngine) AddEntity(entity d2interface.MapEntity)
AddEntity adds an entity to a slice containing all entities.
func (*MapEngine) Advance ¶
Advance calls the Advance() method for all entities, processing a single tick.
func (*MapEngine) Entities ¶
func (m *MapEngine) Entities() map[string]d2interface.MapEntity
Entities returns a pointer a slice of all map entities.
func (*MapEngine) GenerateMap ¶
func (m *MapEngine) GenerateMap(regionType d2enum.RegionIdType, levelPreset, fileIndex int)
GenerateMap clears the map and places the specified stamp.
func (*MapEngine) GetCenterPosition ¶
GetCenterPosition returns the center point of the map.
func (*MapEngine) GetStartPosition ¶
GetStartPosition returns the spawn point on entering the current map.
func (*MapEngine) GetStartingPosition ¶
GetStartingPosition returns the starting position on the map in sub-tiles.
func (*MapEngine) GetTileData ¶
func (m *MapEngine) GetTileData(style, sequence int, tileType d2enum.TileType, index byte) *d2dt1.Tile
GetTileData returns the tile with the given style, sequence, tileType and index.
func (*MapEngine) GetTiles ¶
GetTiles returns a slice of all tiles matching the given style, sequence and tileType.
func (*MapEngine) LevelType ¶
func (m *MapEngine) LevelType() d2records.LevelTypeRecord
LevelType returns the level type of this map.
func (*MapEngine) PathFind ¶
PathFind finds a path between given start and dest positions and returns the positions of the path
func (*MapEngine) PlaceStamp ¶
func (m *MapEngine) PlaceStamp(stamp *d2mapstamp.Stamp, tileOffsetX, tileOffsetY int)
PlaceStamp places a map stamp at the specified location, creating both entities and tiles. Stamps are pre-defined map areas, see d2mapstamp.
func (*MapEngine) RemoveEntity ¶
func (m *MapEngine) RemoveEntity(entity d2interface.MapEntity)
RemoveEntity removes an entity from the map engine
func (*MapEngine) ResetMap ¶
func (m *MapEngine) ResetMap(levelType d2enum.RegionIdType, width, height int)
ResetMap clears all map and entity data and reloads it from the cached files.
func (*MapEngine) SubTileAt ¶
func (m *MapEngine) SubTileAt(subX, subY int) *d2dt1.SubTileFlags
SubTileAt gets the flags for the given subtile
func (*MapEngine) TileAt ¶
TileAt returns a pointer to the data for the map tile at the given x and y index.
func (*MapEngine) TileExists ¶
TileExists returns true if the tile at the given coordinates exists.
type MapTile ¶
type MapTile struct { Components d2mapstamp.Tile RegionType d2enum.RegionIdType SubTiles [25]d2dt1.SubTileFlags }
MapTile is a tile placed on the map
func (*MapTile) GetSubTileFlags ¶
func (t *MapTile) GetSubTileFlags(x, y int) *d2dt1.SubTileFlags
GetSubTileFlags returns the tile flags for the given subtile
func (*MapTile) PrepareTile ¶
PrepareTile selects which graphic to use and updates the tiles subtileflags