-
Notifications
You must be signed in to change notification settings - Fork 0
/
row_to_table.go
37 lines (30 loc) · 931 Bytes
/
row_to_table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package observer
import "github.com/mlange-42/arche/ecs"
// RowToTable creates an observer that serves as adapter from a [Row] observer to a [Table] observer.
func RowToTable(row Row) Table {
return &rowToTable{
Observer: row,
}
}
// rowToTable is an observer that serves as adapter from a [Row] observer to a [Table] observer.
type rowToTable struct {
Observer Row
values [1][]float64
}
// Initialize the child observer.
func (o *rowToTable) Initialize(w *ecs.World) {
o.Observer.Initialize(w)
}
// Update the child observer.
func (o *rowToTable) Update(w *ecs.World) {
o.Observer.Update(w)
}
// Header / column names of the child observer in the same order as data values.
func (o *rowToTable) Header() []string {
return o.Observer.Header()
}
// Values for the current model tick in table format.
func (o *rowToTable) Values(w *ecs.World) [][]float64 {
o.values[0] = o.Observer.Values(w)
return o.values[:]
}