Documentation ¶
Overview ¶
Package csminify provides functions for parsing CS:GO demos and minifying them into various formats.
Index ¶
- Variables
- func Minify(r io.Reader, snapFreq float64, marshal ReplayMarshaller) ([]byte, error)
- func MinifyTo(r io.Reader, snapFreq float64, marshal ReplayMarshaller, w io.Writer) error
- func MinifyToWithConfig(r io.Reader, cfg ReplayConfig, marshal ReplayMarshaller, w io.Writer) error
- func MinifyWithConfig(r io.Reader, cfg ReplayConfig, marshal ReplayMarshaller) ([]byte, error)
- func ToReplay(r io.Reader, snapFreq float64) (rep.Replay, error)
- func ToReplayWithConfig(r io.Reader, cfg ReplayConfig) (rep.Replay, error)
- type EventCollector
- type ReplayConfig
- type ReplayMarshaller
Constants ¶
This section is empty.
Variables ¶
var DefaultReplayConfig = func(snapFreq float64) ReplayConfig { ec := new(EventCollector) EventHandlers.Default.RegisterAll(ec) return ReplayConfig{ SnapshotFrequency: snapFreq, EventCollector: ec, } }
DefaultReplayConfig returns the default configuration with a given snapshot frequency. May be overridden.
var EventHandlers eventHandlers
EventHandlers provides functions for registering the out-of-the-box provided handlers on EventCollectors. The handlers are divided into two groups: Default and Extra. Default contains the handlers that are used if no custom EventCollector is specified. Extra contains other handlers that are usually not required (i.e. a 'footstep' handler).
Functions ¶
func MinifyTo ¶
MinifyTo reads a demo from r, creates a replay and marshals it to w. See also: ToReplay
func MinifyToWithConfig ¶
func MinifyToWithConfig(r io.Reader, cfg ReplayConfig, marshal ReplayMarshaller, w io.Writer) error
MinifyToWithConfig reads a demo from r, creates a replay and marshals it to w. See also: ToReplayWithConfig
func MinifyWithConfig ¶
func MinifyWithConfig(r io.Reader, cfg ReplayConfig, marshal ReplayMarshaller) ([]byte, error)
MinifyWithConfig wraps MinifyToWithConfig with a bytes.Buffer and returns the written bytes.
func ToReplay ¶
ToReplay reads a demo from r, takes snapshots (snapFreq/sec) and records events into a Replay.
func ToReplayWithConfig ¶
ToReplayWithConfig reads a demo from r, takes snapshots and records events into a Replay with a custom configuration.
Types ¶
type EventCollector ¶
type EventCollector struct {
// contains filtered or unexported fields
}
EventCollector provides the possibility of adding custom events to replays. First all demo-event handlers must be registered via AddHandler(). The registered handlers can add replay-events to the collector via AddEvent(). The handlers can access game-state information via Parser(). After a tick ends all events that were added to the collector during the tick will be stored into the replay.
func (*EventCollector) AddEvent ¶
func (ec *EventCollector) AddEvent(event rep.Event)
AddEvent adds an event to the collector. The event will be added to the replay after the current tick ends.
func (*EventCollector) AddHandler ¶
func (ec *EventCollector) AddHandler(handler interface{})
AddHandler adds a handler which will be registered on the Parser to the collector. The handler should use EventCollector.AddEvent() and be of the type func(<EventType>) where EventType is the type of the event to be handled. The handler parameter is of type interface because lolnogenerics. See: github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs.Parser.RegisterEventHandler() GoDoc: https://pkg.go.dev/github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs?tab=doc#Parser
func (*EventCollector) Parser ¶
func (ec *EventCollector) Parser() dem.Parser
Parser returns the demo-parser through which custom handlers can access game-state information. Returns nil before minification has started - so don't call this before you need it.
type ReplayConfig ¶
type ReplayConfig struct { SnapshotFrequency float64 EventCollector *EventCollector }
ReplayConfig contains the configuration for generating a replay.
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package protobuf provides a replay marshaller for protobuf.
|
Package protobuf provides a replay marshaller for protobuf. |
gen
Package gen contains the generated protobuf code.
|
Package gen contains the generated protobuf code. |
Package replay contains all types that make up a replay.
|
Package replay contains all types that make up a replay. |
nondefault
Package nondefault is used for testing purposes only.
|
Package nondefault is used for testing purposes only. |