Documentation
¶
Index ¶
- type MovementConfig
- type MovementController
- func (m *MovementController) AbortAndSnap(x, y, z, o float32)
- func (m *MovementController) AbortSilent()
- func (m *MovementController) CurrentPosition() (x, y, z, o float32)
- func (m *MovementController) Destination() (x, y, z float32, ok bool)
- func (m *MovementController) InitPositionFromWorld(x, y, z, o float32)
- func (m *MovementController) IsMoving() bool
- func (m *MovementController) SetInitialJumpInfo(zspeed, sinAngle, cosAngle, xyspeed float32)
- func (m *MovementController) SetNavigator(nav navigation.Navigator)
- func (m *MovementController) SetPath(path []navigation.Point3D, startTime time.Time, initialO float32, mapID uint32)
- func (m *MovementController) Stop(now time.Time)
- func (m *MovementController) TravelDist() float32
- func (m *MovementController) Update(now time.Time)
- type MovementSender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MovementConfig ¶
type MovementConfig struct {
// HeartbeatInterval is the target interval between movement heartbeats while moving.
HeartbeatInterval time.Duration
// TurnThresholdRad is the angle difference at which we consider a turn at waypoint.
TurnThresholdRad float32
// WaypointRadius is how close we must be to advance to next waypoint.
WaypointRadius float32
// StopForTurns emits a stop/facing/restart sequence at sharp waypoints.
// It is useful for replaying manual traces, but disabled by default because
// sparse server extrapolation can make stops at corners look like tiny rewinds.
StopForTurns bool
// StopAtEnd sends a final MoveStop when path completes.
StopAtEnd bool
}
MovementConfig tunes the client-like movement behavior.
func DefaultMovementConfig ¶
func DefaultMovementConfig() MovementConfig
DefaultMovementConfig returns conservative load-test defaults that avoid flooding movement heartbeats while still keeping the server position fresh.
type MovementController ¶
type MovementController struct {
// contains filtered or unexported fields
}
MovementController is the separate struct responsible for all player movement logic. It manages path following, position interpolation over simulated time, and decides exactly when and what movement packets to emit to match real client patterns (heartbeats, stops, facing changes at turns, etc).
func NewMovementController ¶
func NewMovementController(sender MovementSender, speed float32, nav navigation.Navigator, cfg MovementConfig) *MovementController
NewMovementController creates a movement controller.
func (*MovementController) AbortAndSnap ¶
func (m *MovementController) AbortAndSnap(x, y, z, o float32)
AbortAndSnap aborts any path (no MoveStop) and snaps the controller pose to the post-teleport world position so later Update() cannot overwrite the new coords.
func (*MovementController) AbortSilent ¶
func (m *MovementController) AbortSilent()
AbortSilent cancels any active path without emitting MoveStop. Used when the server already relocated the player (teleport/summon): stopping at the pre-teleport pose would fight the server position.
func (*MovementController) CurrentPosition ¶
func (m *MovementController) CurrentPosition() (x, y, z, o float32)
CurrentPosition returns the controller's view of current location (for assertions in tests).
func (*MovementController) Destination ¶
func (m *MovementController) Destination() (x, y, z float32, ok bool)
Destination returns the final path waypoint when a path is installed.
func (*MovementController) InitPositionFromWorld ¶
func (m *MovementController) InitPositionFromWorld(x, y, z, o float32)
InitPositionFromWorld seeds the controller's internal position with the current world position right after creation / login. This prevents zeroing out the spawn location before the first path.
func (*MovementController) IsMoving ¶
func (m *MovementController) IsMoving() bool
IsMoving reports if still following path.
func (*MovementController) SetInitialJumpInfo ¶
func (m *MovementController) SetInitialJumpInfo(zspeed, sinAngle, cosAngle, xyspeed float32)
SetInitialJumpInfo configures the jump/fall trajectory data to be sent with the very first movement heartbeat (reproduces the special first HB with j_* fields seen in manual movement logs when a small drop/fall occurs right after starting forward).
func (*MovementController) SetNavigator ¶
func (m *MovementController) SetNavigator(nav navigation.Navigator)
func (*MovementController) SetPath ¶
func (m *MovementController) SetPath(path []navigation.Point3D, startTime time.Time, initialO float32, mapID uint32)
SetPath installs a new path (from pathfinder) and starts movement from the first point. The caller is responsible for providing a path that starts near current position. mapID is used (when > 0 and nav is available) to snap Z to real ground height on elevation.
func (*MovementController) Stop ¶
func (m *MovementController) Stop(now time.Time)
Stop forces a stop.
func (*MovementController) TravelDist ¶
func (m *MovementController) TravelDist() float32
TravelDist returns how far along the path (2D) we have simulated.
func (*MovementController) Update ¶
func (m *MovementController) Update(now time.Time)
Update advances simulated position to the time 'now' and emits any due packets (HB, turns, stops). Call this regularly with monotonically increasing simulated time.
type MovementSender ¶
type MovementSender interface {
MoveStartForward(at time.Time, x, y, z, o float32)
MoveStop(at time.Time, x, y, z, o float32)
SetFacing(at time.Time, x, y, z, o float32)
SetFacingMoving(at time.Time, x, y, z, o float32)
SendHeartbeat(at time.Time, x, y, z, o float32)
SendMovementHeartbeat(at time.Time, x, y, z, o float32)
// SendMovementHeartbeatWithJump sends a moving heartbeat with MOVEMENTFLAG_FALLING set
// and the extra jump info (used for the initial move in the observed manual log).
SendMovementHeartbeatWithJump(at time.Time, x, y, z, o float32, fallTime uint32, zspeed, sinAngle, cosAngle, xyspeed float32)
SendFallLand(at time.Time, x, y, z, o float32)
}
MovementSender is the interface used by MovementController to emit movement packets. This decouples the movement logic from the concrete WorldClient.
func NewWorldMovementSender ¶
func NewWorldMovementSender(w *client.WorldClient) MovementSender
NewWorldMovementSender returns a MovementSender backed by a WorldClient. Used by bot to attach a movement controller without duplicating adapter logic.