Skip to content
This repository has been archived by the owner on Jan 22, 2024. It is now read-only.

Commit

Permalink
add match_started event and hasHelmet + hasDefuseKit (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
markus-wa committed Apr 15, 2020
1 parent b2e89f8 commit a2e187c
Show file tree
Hide file tree
Showing 13 changed files with 418 additions and 238 deletions.
2 changes: 2 additions & 0 deletions csminify.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func (m *minifier) snapshot() rep.Snapshot {
Positions: []rep.Point{r3VectorToPoint(pl.Position)},
AngleX: int(pl.ViewDirectionX),
AngleY: int(pl.ViewDirectionY),
HasHelmet: pl.HasHelmet,
HasDefuseKit: pl.HasDefuseKit,
}

// FIXME: Smoothify Positions
Expand Down
17 changes: 17 additions & 0 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ type eventHandlers struct {
type defaultEventHandlers struct{}

func (defaultEventHandlers) RegisterAll(ec *EventCollector) {
EventHandlers.Default.RegisterMatchStarted(ec)
EventHandlers.Default.RegisterGamePhaseChanged(ec)
EventHandlers.Default.RegisterRoundStarted(ec)
EventHandlers.Default.RegisterRoundEnded(ec)
EventHandlers.Default.RegisterPlayerKilled(ec)
Expand All @@ -65,6 +67,21 @@ func (defaultEventHandlers) RegisterAll(ec *EventCollector) {
EventHandlers.Default.RegisterChatMessage(ec)
}

func (defaultEventHandlers) RegisterMatchStarted(ec *EventCollector) {
ec.AddHandler(func(e events.MatchStart) {
ec.AddEvent(createEvent(rep.EventMatchStarted))
})
}

func (defaultEventHandlers) RegisterGamePhaseChanged(ec *EventCollector) {
ec.AddHandler(func(e events.GamePhaseChanged) {
eb := buildEvent(rep.EventGamePhaseChanged)
eb.intAttr("oldGamePhase", int(e.OldGamePhase))
eb.intAttr("newGamePhase", int(e.NewGamePhase))
ec.AddEvent(eb.build())
})
}

func (defaultEventHandlers) RegisterRoundStarted(ec *EventCollector) {
ec.AddHandler(func(e events.RoundStart) {
ec.AddEvent(createEvent(rep.EventRoundStarted))
Expand Down
Loading

0 comments on commit a2e187c

Please sign in to comment.