pather

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KindPlain (.) is a plain tile with a movement cost of 1.
	KindPlain uint8 = iota
	// KindSoftBlocker (S) is a tile to fake some blocking areas with increased cost of moving, like Arcane Sanctuary platforms
	KindSoftBlocker
	// KindBlocker (X) is a tile which blocks movement.
	KindBlocker
)

Kind* constants refer to tile kinds for input and output.

Variables

View Source
var KindCosts = map[uint8]float64{
	KindPlain:       1.0,
	KindSoftBlocker: 1000,
}

KindCosts map tile kinds to movement costs.

Functions

func DistanceFromMe

func DistanceFromMe(d game.Data, p data.Position) int

func DistanceFromPoint

func DistanceFromPoint(from data.Position, to data.Position) int

func FindFirstWalkable added in v0.4.0

func FindFirstWalkable(from data.Position, areaOriginPos data.Position, grid [][]bool, radius int) (int, int)

FindFirstWalkable finds the first walkable position from a given position and radius

func IsNarrowMap added in v0.3.0

func IsNarrowMap(a area.ID) bool

func IsWalkable added in v0.4.0

func IsWalkable(pos data.Position, areaOriginPos data.Position, collisionGrid [][]bool) bool

func LineOfSight added in v0.5.0

func LineOfSight(d game.Data, origin data.Position, destination data.Position) bool

Types

type PathFinder added in v0.4.0

type PathFinder struct {
	// contains filtered or unexported fields
}

func NewPathFinder added in v0.4.0

func NewPathFinder(gr *game.MemoryReader, hid *game.HID, cfg *config.CharacterCfg) *PathFinder

func (*PathFinder) GameCoordsToScreenCords added in v0.4.0

func (pf *PathFinder) GameCoordsToScreenCords(playerX, playerY, destinationX, destinationY int) (int, int)

func (*PathFinder) GetClosestWalkablePath added in v0.4.0

func (pf *PathFinder) GetClosestWalkablePath(d game.Data, dest data.Position, blacklistedCoords ...[2]int) (path Pather, distance int, found bool)

func (*PathFinder) GetPath added in v0.4.0

func (pf *PathFinder) GetPath(d game.Data, to data.Position, blacklistedCoords ...[2]int) (path Pather, distance int, found bool)

The GetPath method definition, combined and corrected

func (*PathFinder) GetWalkableRooms added in v0.5.0

func (pf *PathFinder) GetWalkableRooms(d game.Data) []data.Position

func (*PathFinder) MoveCharacter added in v0.4.0

func (pf *PathFinder) MoveCharacter(d game.Data, x, y int)

func (*PathFinder) MoveThroughPath added in v0.4.0

func (pf *PathFinder) MoveThroughPath(d game.Data, p Pather, distance int)

func (*PathFinder) RandomMovement added in v0.4.0

func (pf *PathFinder) RandomMovement(d game.Data)

type Pather

type Pather []astar.Pather

func (Pather) Distance

func (p Pather) Distance() int

func (Pather) Intersects added in v0.3.0

func (p Pather) Intersects(d game.Data, position data.Position, padding int) bool

Intersects checks if the given position intersects with the path, padding parameter is used to increase the area

type Tile

type Tile struct {
	Walkable bool
	Cost     float64
	X, Y     int
	Kind     uint8
	W        *World
}

A Tile is a tile in a grid which implements Pather.

func (*Tile) PathEstimatedCost

func (t *Tile) PathEstimatedCost(to astar.Pather) float64

PathEstimatedCost uses Manhattan distance to estimate orthogonal distance between non-adjacent nodes.

func (*Tile) PathNeighborCost

func (t *Tile) PathNeighborCost(to astar.Pather) float64

PathNeighborCost returns the movement cost of the directly neighboring tile.

func (*Tile) PathNeighbors

func (t *Tile) PathNeighbors() []astar.Pather

PathNeighbors returns the neighbors of the tile, excluding blockers and tiles off the edge of the board.

type World

type World struct {
	World [][]*Tile
	// contains filtered or unexported fields
}

func (*World) From

func (w *World) From() *Tile

func (*World) NewTile

func (w *World) NewTile(kind uint8, x, y int) *Tile

func (*World) SetFrom added in v0.4.0

func (w *World) SetFrom(position data.Position)

func (*World) SetTile

func (w *World) SetTile(t *Tile)

SetTile sets a tile at the given coordinates in the World, if the World is big enough.

func (*World) SetTo added in v0.4.0

func (w *World) SetTo(position data.Position)

func (*World) Tile

func (w *World) Tile(x, y int) *Tile

Tile gets the tile at the given coordinates in the World.

func (*World) To

func (w *World) To() *Tile

Jump to

Keyboard shortcuts

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