From 05e2f04a346721574ca96c007f9aa16de772dade Mon Sep 17 00:00:00 2001 From: Markus Walther Date: Wed, 20 Sep 2023 18:36:25 +0100 Subject: [PATCH] add PropertyValue.R3VecOrNil() --- pkg/demoinfocs/sendtables/propdecoder.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/demoinfocs/sendtables/propdecoder.go b/pkg/demoinfocs/sendtables/propdecoder.go index 990d44d4..bc2db024 100644 --- a/pkg/demoinfocs/sendtables/propdecoder.go +++ b/pkg/demoinfocs/sendtables/propdecoder.go @@ -114,6 +114,24 @@ func (v PropertyValue) R3Vec() r3.Vector { return v.VectorVal } +func (v PropertyValue) R3VecOrNil() *r3.Vector { + if v.S2 { + if v.Any == nil { + return nil + } + + fs := v.Any.([]float32) + + return &r3.Vector{ + X: float64(fs[0]), + Y: float64(fs[1]), + Z: float64(fs[2]), + } + } + + return &v.VectorVal +} + func (v PropertyValue) Int() int { if v.S2 { return int(v.Any.(int32))