d2mapengine

package
v0.0.0-...-7f92c57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package d2mapengine provides a map engine, something that can place diablo tile data onto a plane.

Index

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

func (m *MapEngine) AddDS1(fileName string)

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

func (m *MapEngine) Advance(tickTime float64)

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

func (m *MapEngine) GetCenterPosition() (x, y float64)

GetCenterPosition returns the center point of the map.

func (*MapEngine) GetStartPosition

func (m *MapEngine) GetStartPosition() (x, y float64)

GetStartPosition returns the spawn point on entering the current map.

func (*MapEngine) GetStartingPosition

func (m *MapEngine) GetStartingPosition() (x, y int)

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

func (m *MapEngine) GetTiles(style, sequence int, tileType d2enum.TileType) []d2dt1.Tile

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

func (m *MapEngine) PathFind(start, dest d2vector.Position) []d2vector.Position

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) Seed

func (m *MapEngine) Seed() int64

Seed returns the map generation seed.

func (*MapEngine) SetSeed

func (m *MapEngine) SetSeed(seed int64)

SetSeed sets the seed of the map for generation.

func (*MapEngine) Size

func (m *MapEngine) Size() d2geom.Size

Size returns the size of the map in sub-tiles.

func (*MapEngine) SubTileAt

func (m *MapEngine) SubTileAt(subX, subY int) *d2dt1.SubTileFlags

SubTileAt gets the flags for the given subtile

func (*MapEngine) Tile

func (m *MapEngine) Tile(x, y int) *MapTile

Tile returns the TileRecord containing the data for a single map tile.

func (*MapEngine) TileAt

func (m *MapEngine) TileAt(tileX, tileY int) *MapTile

TileAt returns a pointer to the data for the map tile at the given x and y index.

func (*MapEngine) TileExists

func (m *MapEngine) TileExists(tileX, tileY int) bool

TileExists returns true if the tile at the given coordinates exists.

func (*MapEngine) Tiles

func (m *MapEngine) Tiles() *[]MapTile

Tiles returns a pointer to a slice contaning all map tile data.

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

func (t *MapTile) PrepareTile(x, y int, me *MapEngine)

PrepareTile selects which graphic to use and updates the tiles subtileflags

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL