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

Commit

Permalink
feat(equipment): Add equipment to entity snapshots (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: Markus Walther <[email protected]>
  • Loading branch information
LarsKoelpin and markus-wa authored Jun 8, 2020
1 parent 3cbf92a commit 82c563e
Show file tree
Hide file tree
Showing 11 changed files with 750 additions and 271 deletions.
14 changes: 14 additions & 0 deletions csminify.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

r3 "github.com/golang/geo/r3"
dem "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs"
common "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/common"
events "github.com/markus-wa/demoinfocs-golang/v2/pkg/demoinfocs/events"

rep "github.com/markus-wa/cs-demo-minifier/replay"
Expand Down Expand Up @@ -163,6 +164,7 @@ func (m *minifier) snapshot() rep.Snapshot {
AngleY: int(pl.ViewDirectionY()),
HasHelmet: pl.HasHelmet(),
HasDefuseKit: pl.HasDefuseKit(),
Equipment: toEntityEquipment(pl.Weapons()),
}

// FIXME: Smoothify Positions
Expand Down Expand Up @@ -201,3 +203,15 @@ func r3VectorToPoint(v r3.Vector) rep.Point {
func roundTo(x, precision float64) float64 {
return math.Round(x/precision) * precision
}

func toEntityEquipment(eq []*common.Equipment) []rep.EntityEquipment {
var equipmentForPlayer = make([]rep.EntityEquipment, 0, len(eq))

for _, equipment := range eq {
equipmentForPlayer = append(equipmentForPlayer, rep.EntityEquipment{
Type: int(equipment.Type),
})
}

return equipmentForPlayer
}
Loading

0 comments on commit 82c563e

Please sign in to comment.