Exemplo n.º 1
0
func NewWarpFromPacket(_packet *Packet) *Warp {
	toX := int(_packet.ReadInt16())
	toY := int(_packet.ReadInt16())
	toZ := int(_packet.ReadInt16())
	tp_pos := pos.NewPositionFrom(toX, toY, toZ)

	return NewWarp(tp_pos)
}
Exemplo n.º 2
0
// Gets a tile from the list. If the tile doesnt exists it will be created
// Returns the tile pointer and a boolean, true if the tile is new
// NOTE: Should only be used when loading the map, because of locking
func (m *Map) getOrAddTile(_x, _y, _z int) *Tile {
	m.tileMutex.Lock()
	defer m.tileMutex.Unlock()

	position := pos.NewPositionFrom(_x, _y, _z)
	tile, ok := m.GetTileFromPosition(position)

	if !ok {
		tile = NewTile(position)
		m.AddTile(tile)
	}

	return tile
}
Exemplo n.º 3
0
// NewTileExt creates a Position from _x, _y, _z and then calls NewTile to create a new Tile object
func NewTileExt(_x int, _y int, _z int) *Tile {
	return NewTile(pos.NewPositionFrom(_x, _y, _z))
}
Exemplo n.º 4
0
func (m *Map) GetTileFromCoordinates(_x, _y, _z int) (*Tile, bool) {
	position := pos.NewPositionFrom(_x, _y, _z)
	return m.GetTileFromPosition(position)
}