Documentation
¶
Index ¶
- Variables
- type Action
- type ActionBuffer
- func (buffer *ActionBuffer) Add(action StampedAction)
- func (buffer *ActionBuffer) AddBatch(actions []StampedAction)
- func (buffer *ActionBuffer) Clear()
- func (buffer *ActionBuffer) Clone() ActionBuffer
- func (buffer *ActionBuffer) ConsumeAction(target Action) (StampedAction, bool)
- func (buffer *ActionBuffer) ForceAdd(action StampedAction)
- func (buffer *ActionBuffer) GetActionsInTimeRange(startTick, endTick int) []StampedAction
- func (buffer *ActionBuffer) GetSortedByTime() []StampedAction
- func (buffer *ActionBuffer) GetTimeRange() (earliest int, latest int)
- func (buffer *ActionBuffer) HasAction(target Action) bool
- func (buffer *ActionBuffer) IsEmpty() bool
- func (buffer *ActionBuffer) PeekLatest() (StampedAction, bool)
- func (buffer *ActionBuffer) PeekLatestOfType(target Action) (StampedAction, bool)
- func (buffer *ActionBuffer) SetActions(actions []StampedAction)
- func (buffer *ActionBuffer) Size() int
- func (buffer *ActionBuffer) String() string
- type ClientActionMessage
- type StampedAction
Constants ¶
This section is empty.
Variables ¶
var Components = defaultComponents{ ActionBuffer: warehouse.FactoryNewComponent[ActionBuffer](), }
Functions ¶
This section is empty.
Types ¶
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