phy

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: 5 Imported by: 0

Documentation

Overview

Package phy implements a minimal physics simulation necessary for realistic bot behavior.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AABB

type AABB struct {
	X, Y, Z MinMax
	Block   world.BlockStatus
}

AABB implements Axis Aligned Bounding Box operations.

func (AABB) Contract

func (bb AABB) Contract(x, y, z float64) AABB

Contract reduces the difference between the min/max bounds (for positive values) for each dimension.

func (AABB) Expand

func (bb AABB) Expand(x, y, z float64) AABB

Expand increases both the minimum and maximum bounds by the provided amount (for positive values) for each dimension.

func (AABB) Extend

func (bb AABB) Extend(dx, dy, dz float64) AABB

Extend adjusts the minimum (for negative values) or maximum bounds (for positive values) by the provided scalar for each dimension.

func (AABB) Intersects

func (bb AABB) Intersects(o AABB) bool

func (AABB) Offset

func (bb AABB) Offset(x, y, z float64) AABB

Offset moves both the minimum and maximum bound by the provided value for each dimension.

func (AABB) XOffset

func (bb AABB) XOffset(o AABB, xOffset float64) float64

func (AABB) YOffset

func (bb AABB) YOffset(o AABB, yOffset float64) float64

func (AABB) ZOffset

func (bb AABB) ZOffset(o AABB, zOffset float64) float64

type MinMax

type MinMax struct {
	Min, Max float64
}

func (MinMax) Contract

func (mm MinMax) Contract(amt float64) MinMax

Contract reduces both the minimum and maximum bound by the provided amount, such that the difference between the bounds decreases for positive values.

func (MinMax) Expand

func (mm MinMax) Expand(amt float64) MinMax

Expand changes the minimum and maximum bounds by the provided amount, such that the difference between the bounds increases for positive values.

func (MinMax) Extend

func (mm MinMax) Extend(delta float64) MinMax

Extends adjusts the bounds of the MinMax. A negative number will reduce the minimum bound, whereas a positive number will increase the maximum bound.

func (MinMax) Offset

func (mm MinMax) Offset(amt float64) MinMax

Offset adds the provided value to both the minimum and maximum value.

type State

type State struct {
	// player state.
	Pos        path.Point
	Vel        path.Point
	Yaw, Pitch float64

	Run bool
	// contains filtered or unexported fields
}

State tracks physics state.

func (*State) AtLookTarget

func (s *State) AtLookTarget(yaw, pitch float64) bool

AtLookTarget returns true if the player look position is actually at the given pitch and yaw.

func (*State) BB

func (s *State) BB() AABB

func (*State) Position

func (s *State) Position() player.Pos

func (*State) ServerPositionUpdate

func (s *State) ServerPositionUpdate(player player.Pos, w World) error

func (*State) Tick

func (s *State) Tick(input path.Inputs, w World) error

type Surrounds

type Surrounds []AABB

Surrounds represents the blocks surrounding the player (Y, Z, X).

type World

type World interface {
	GetBlockStatus(x, y, z int) world.BlockStatus
}

World represents a provider of information about the surrounding world.

Jump to

Keyboard shortcuts

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