input

package
v0.0.0-...-5a25bdc Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: MIT Imports: 3 Imported by: 27

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Components = defaultComponents{
	ActionBuffer: warehouse.FactoryNewComponent[ActionBuffer](),
}

Functions

This section is empty.

Types

type Action

type Action uint32

Action represents a unique identifier for an action event

func NewAction

func NewAction() Action

NewAction generates a new unique Input identifier

type ActionBuffer

type ActionBuffer struct {
	Values        []StampedAction
	ReceiverIndex int
}

ActionBuffer represents a buffer of timestamped inputs with automatic deduplication.

func (*ActionBuffer) Add

func (buffer *ActionBuffer) Add(action StampedAction)

Add appends a new stamped action to the buffer, automatically deduplicating by keeping only the most recent action of each type

func (*ActionBuffer) AddBatch

func (buffer *ActionBuffer) AddBatch(actions []StampedAction)

AddBatch adds multiple stamped actions to the buffer with automatic deduplication

func (*ActionBuffer) Clear

func (buffer *ActionBuffer) Clear()

Clear removes all actions from the buffer

func (*ActionBuffer) Clone

func (buffer *ActionBuffer) Clone() ActionBuffer

Clone returns a new ActionBuffer with a copy of all current inputs

func (*ActionBuffer) ConsumeAction

func (buffer *ActionBuffer) ConsumeAction(target Action) (StampedAction, bool)

ConsumeAction finds and removes the most recent occurrence of the target input. Returns the consumed input and whether it was found.

func (*ActionBuffer) ForceAdd

func (buffer *ActionBuffer) ForceAdd(action StampedAction)

ForceAdd appends a new stamped action to the buffer, without deduplicating

func (*ActionBuffer) GetActionsInTimeRange

func (buffer *ActionBuffer) GetActionsInTimeRange(startTick, endTick int) []StampedAction

GetActionsInTimeRange returns all actions between startTick and endTick (inclusive)

func (*ActionBuffer) GetSortedByTime

func (buffer *ActionBuffer) GetSortedByTime() []StampedAction

GetSortedByTime returns all actions sorted by their tick values

func (*ActionBuffer) GetTimeRange

func (buffer *ActionBuffer) GetTimeRange() (earliest int, latest int)

GetTimeRange returns the earliest and latest ticks in the buffer. Returns (0, 0) if the buffer is empty.

func (*ActionBuffer) HasAction

func (buffer *ActionBuffer) HasAction(target Action) bool

HasAction returns true if the buffer contains the specified input type

func (*ActionBuffer) IsEmpty

func (buffer *ActionBuffer) IsEmpty() bool

IsEmpty returns true if the buffer contains no actions

func (*ActionBuffer) PeekLatest

func (buffer *ActionBuffer) PeekLatest() (StampedAction, bool)

PeekLatest returns the most recent action in the buffer without removing it. Returns false if the buffer is empty.

func (*ActionBuffer) PeekLatestOfType

func (buffer *ActionBuffer) PeekLatestOfType(target Action) (StampedAction, bool)

PeekLatestOfType returns the most recent action of a specific type without removing it. Returns false if no action of that type exists.

func (*ActionBuffer) SetActions

func (buffer *ActionBuffer) SetActions(actions []StampedAction)

SetActions replaces all actions in the buffer with the provided actions, automatically deduplicating them

func (*ActionBuffer) Size

func (buffer *ActionBuffer) Size() int

Size returns the current number of actions in the buffer

func (*ActionBuffer) String

func (buffer *ActionBuffer) String() string

String returns a human-readable representation of the buffer

type ClientActionMessage

type ClientActionMessage struct {
	// ReceiverIndex indicates which action-set this message corresponds to,
	// particularly if a single connection controls multiple inputs for its entity.
	ReceiverIndex int `json:"receiver_index"`

	// Actions contains the actual stamped action events recorded by the client.
	Actions []StampedAction `json:"actions"`
}

ClientActionMessage holds actions from a client connection for a specific receiver index. The server determines the target entity based on the connection sending this message.

type StampedAction

type StampedAction struct {
	Tick           int    // Tick when the input occurred
	Val            Action // The action identifier
	X, Y           int    // Screen coordinates where the action occurred
	LocalX, LocalY int    // Position relative to an entity's camera view
}

StampedAction contains input data along with position and timing information

Jump to

Keyboard shortcuts

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