Skip to content

Commit e9dd5fd

Browse files
committed
inferno/Fires: add List() to return raw list of fires
1 parent 2c9b7f9 commit e9dd5fd

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

pkg/demoinfocs/common/inferno.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ func (f Fires) Active() Fires {
105105
return Fires{s: active}
106106
}
107107

108+
// List returns fires a list of the raw Fire entities. This can be useful
109+
// if you need to do custom calculations on the fires.
110+
func (f Fires) List() []Fire {
111+
return f.s
112+
}
113+
108114
// ConvexHull2D returns clockwise sorted corner points making up the 2D convex hull of all the fires in the inferno.
109115
// Useful for drawing on 2D maps.
110116
func (f Fires) ConvexHull2D() []r2.Point {

pkg/demoinfocs/common/inferno_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,26 @@ func TestInferno_Thrower(t *testing.T) {
121121

122122
assert.Equal(t, player, NewInferno(provider, entity, nil).Thrower())
123123
}
124+
125+
func TestInferno_List(t *testing.T) {
126+
expected := []Fire{
127+
{
128+
Vector: r3.Vector{X: 1, Y: 2, Z: 3},
129+
},
130+
{
131+
Vector: r3.Vector{X: 4, Y: 7, Z: 6},
132+
},
133+
{
134+
Vector: r3.Vector{X: 7, Y: 2, Z: 9},
135+
},
136+
{
137+
Vector: r3.Vector{X: 4, Y: 4, Z: 12},
138+
},
139+
}
140+
fires := Fires{
141+
s: expected,
142+
}
143+
144+
got := fires.List()
145+
assert.ElementsMatch(t, expected, got, "List() should return the fires contained in Fires")
146+
}

0 commit comments

Comments
 (0)