path

package
v1.16.5-pre Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package path implements pathfinding.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AirLikeBlock

func AirLikeBlock(bID world.BlockStatus) bool

func IsLadder

func IsLadder(bID world.BlockStatus) bool

func IsSlab

func IsSlab(bID world.BlockStatus) bool

func SlabIsBottom

func SlabIsBottom(bStateID world.BlockStatus) bool

func SteppableBlock

func SteppableBlock(bID world.BlockStatus) bool

Types

type Direction

type Direction uint8

Cardinal directions.

const (
	North Direction = iota
	South
	West
	East
)

Valid direction values.

func ChestDirection

func ChestDirection(bStateID world.BlockStatus) Direction

func LadderDirection

func LadderDirection(bStateID world.BlockStatus) Direction

func StairsDirection

func StairsDirection(bStateID world.BlockStatus) Direction

func (Direction) Offset

func (d Direction) Offset() (x, y, z int)

func (Direction) Offset2x

func (d Direction) Offset2x() (x, y, z int)

func (Direction) String

func (d Direction) String() string

type Inputs

type Inputs struct {
	Yaw, Pitch float64

	ThrottleX, ThrottleZ float64

	Jump bool
}

Inputs describes the desired movements of the player.

type Movement

type Movement uint8

Movement represents a single type of movement in a path.

const (
	Waypoint Movement = iota
	TraverseNorth
	TraverseSouth
	TraverseEast
	TraverseWest
	TraverseNorthEast
	TraverseNorthWest
	TraverseSouthEast
	TraverseSouthWest
	DropNorth
	DropSouth
	DropEast
	DropWest
	Drop2North
	Drop2South
	Drop2East
	Drop2West
	AscendNorth
	AscendSouth
	AscendEast
	AscendWest
	DescendLadder
	DescendLadderNorth
	DescendLadderSouth
	DescendLadderEast
	DescendLadderWest
	AscendLadder
	JumpCrossEast
	JumpCrossWest
	JumpCrossNorth
	JumpCrossSouth
)

Valid movement values.

func (Movement) BaseCost

func (m Movement) BaseCost() float64

func (Movement) Offset

func (m Movement) Offset() (x, y, z int)

func (Movement) Possible

func (m Movement) Possible(nav *Nav, x, y, z int, from V3, previous Movement) bool

func (Movement) String

func (m Movement) String() string
type Nav struct {
	World       *world.World
	Start, Dest V3
}

Nav represents a navigation to a position.

func (n *Nav) Path() (path []astar.Pather, distance float64, found bool)

type Point

type Point struct {
	X, Y, Z float64
}

Point represents a point in 3D space.

type Tile

type Tile struct {
	Nav *Nav

	HalfBlock   bool
	Movement    Movement
	Pos         V3
	BlockStatus world.BlockStatus
	ExtraCost   int
}

Tile represents a point in a path. All tiles in a path are adjaceent their preceeding tiles.

func (Tile) Inputs

func (t Tile) Inputs(pos, deltaPos, vel Point, runTime time.Duration) Inputs

func (Tile) IsComplete

func (t Tile) IsComplete(d Point) bool

func (Tile) PathEstimatedCost

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

func (Tile) PathNeighborCost

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

func (Tile) PathNeighbors

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

type V3

type V3 struct {
	X, Y, Z int
}

func (V3) Cost

func (v V3) Cost(other V3) float64

Jump to

Keyboard shortcuts

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