Documentation
¶
Index ¶
- Variables
- type Input
- type InputBuffer
- func (buffer *InputBuffer) Add(input StampedInput)
- func (buffer *InputBuffer) AddBatch(inputs []StampedInput)
- func (buffer *InputBuffer) Clear()
- func (buffer *InputBuffer) Clone() InputBuffer
- func (buffer *InputBuffer) ConsumeInput(target Input) (StampedInput, bool)
- func (buffer *InputBuffer) ForceAdd(input StampedInput)
- func (buffer *InputBuffer) GetInputsInTimeRange(startTick, endTick int) []StampedInput
- func (buffer *InputBuffer) GetSortedByTime() []StampedInput
- func (buffer *InputBuffer) GetTimeRange() (earliest int, latest int)
- func (buffer *InputBuffer) HasInput(target Input) bool
- func (buffer *InputBuffer) IsEmpty() bool
- func (buffer *InputBuffer) PeekLatest() (StampedInput, bool)
- func (buffer *InputBuffer) PeekLatestOfType(target Input) (StampedInput, bool)
- func (buffer *InputBuffer) SetInputs(inputs []StampedInput)
- func (buffer *InputBuffer) Size() int
- func (buffer *InputBuffer) String() string
- type StampedInput
Constants ¶
This section is empty.
Variables ¶
var Components = defaultComponents{ InputBuffer: warehouse.FactoryNewComponent[InputBuffer](), }
Functions ¶
This section is empty.
Types ¶
type InputBuffer ¶
type InputBuffer struct { Values []StampedInput ReceiverIndex int }
InputBuffer represents a buffer of timestamped inputs with automatic deduplication. It maintains only the most recent input of each type.
func (*InputBuffer) Add ¶
func (buffer *InputBuffer) Add(input StampedInput)
Add appends a new stamped input to the buffer, automatically deduplicating by keeping only the most recent input of each type
func (*InputBuffer) AddBatch ¶
func (buffer *InputBuffer) AddBatch(inputs []StampedInput)
AddBatch adds multiple stamped inputs to the buffer with automatic deduplication
func (*InputBuffer) Clear ¶
func (buffer *InputBuffer) Clear()
Clear removes all inputs from the buffer
func (*InputBuffer) Clone ¶
func (buffer *InputBuffer) Clone() InputBuffer
Clone returns a new InputBuffer with a copy of all current inputs
func (*InputBuffer) ConsumeInput ¶
func (buffer *InputBuffer) ConsumeInput(target Input) (StampedInput, bool)
ConsumeInput finds and removes the most recent occurrence of the target input. Returns the consumed input and whether it was found.
func (*InputBuffer) ForceAdd ¶
func (buffer *InputBuffer) ForceAdd(input StampedInput)
ForceAdd appends a new stamped input to the buffer, without deduplicating
func (*InputBuffer) GetInputsInTimeRange ¶
func (buffer *InputBuffer) GetInputsInTimeRange(startTick, endTick int) []StampedInput
GetInputsInTimeRange returns all inputs between startTick and endTick (inclusive)
func (*InputBuffer) GetSortedByTime ¶
func (buffer *InputBuffer) GetSortedByTime() []StampedInput
GetSortedByTime returns all inputs sorted by their tick values
func (*InputBuffer) GetTimeRange ¶
func (buffer *InputBuffer) GetTimeRange() (earliest int, latest int)
GetTimeRange returns the earliest and latest ticks in the buffer. Returns (0, 0) if the buffer is empty.
func (*InputBuffer) HasInput ¶
func (buffer *InputBuffer) HasInput(target Input) bool
HasInput returns true if the buffer contains the specified input type
func (*InputBuffer) IsEmpty ¶
func (buffer *InputBuffer) IsEmpty() bool
IsEmpty returns true if the buffer contains no inputs
func (*InputBuffer) PeekLatest ¶
func (buffer *InputBuffer) PeekLatest() (StampedInput, bool)
PeekLatest returns the most recent input in the buffer without removing it. Returns false if the buffer is empty.
func (*InputBuffer) PeekLatestOfType ¶
func (buffer *InputBuffer) PeekLatestOfType(target Input) (StampedInput, bool)
PeekLatestOfType returns the most recent input of a specific type without removing it. Returns false if no input of that type exists.
func (*InputBuffer) SetInputs ¶
func (buffer *InputBuffer) SetInputs(inputs []StampedInput)
SetInputs replaces all inputs in the buffer with the provided inputs, automatically deduplicating them
func (*InputBuffer) Size ¶
func (buffer *InputBuffer) Size() int
Size returns the current number of inputs in the buffer
func (*InputBuffer) String ¶
func (buffer *InputBuffer) String() string
String returns a human-readable representation of the buffer
type StampedInput ¶
type StampedInput struct { Tick int // Tick when the input occurred Val Input // The input identifier X, Y int // Screen coordinates where the input occurred LocalX, LocalY int // Position relative to an entity's camera view }
StampedInput contains input data along with position and timing information