Skip to content

Commit

Permalink
Fix for opaque Arche 0.10 component and resource IDs (#47)
Browse files Browse the repository at this point in the history
* fix for opaque component and resource IDs in Arche 0.10
* add a test for resource inspector
* upgrade Arche to latest dev version
  • Loading branch information
mlange-42 committed Jan 18, 2024
1 parent 3311d41 commit 6c9e59a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.21.3
require (
github.com/gopxl/pixel/v2 v2.1.0
github.com/mazznoer/colorgrad v0.9.1
github.com/mlange-42/arche v0.9.0
github.com/mlange-42/arche v0.9.1-0.20240118110009-5c05233583b6
github.com/mlange-42/arche-model v0.5.0
github.com/stretchr/testify v1.8.4
golang.org/x/image v0.13.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ github.com/mazznoer/colorgrad v0.9.1 h1:MB80JYVndKWSMEM1beNqnuOowWGhoQc3DXWXkFp6
github.com/mazznoer/colorgrad v0.9.1/go.mod h1:WX2R9wt9B47+txJZVVpM9LY+LAGIdi4lTI5wIyreDH4=
github.com/mazznoer/csscolorparser v0.1.2 h1:/UBHuQg792ePmGFzTQAC9u+XbFr7/HzP/Gj70Phyz2A=
github.com/mazznoer/csscolorparser v0.1.2/go.mod h1:Aj22+L/rYN/Y6bj3bYqO3N6g1dtdHtGfQ32xZ5PJQic=
github.com/mlange-42/arche v0.9.0 h1:I4hWp1qqWJbhNdd4+IpUcFwLQA/Gi4ZiTmeX0iEIfvA=
github.com/mlange-42/arche v0.9.0/go.mod h1:Bc4xbLsOifSzotIeXOvIKwsrwgzxyDhH3UIxE7vh1q0=
github.com/mlange-42/arche v0.9.1-0.20240118110009-5c05233583b6 h1:cWfjYtsUkj0qzXYsXorcVxFbE98ojr4F4OhWWchiuog=
github.com/mlange-42/arche v0.9.1-0.20240118110009-5c05233583b6/go.mod h1:Bc4xbLsOifSzotIeXOvIKwsrwgzxyDhH3UIxE7vh1q0=
github.com/mlange-42/arche-model v0.5.0 h1:xDR1sEADfJZbqNXbgBAzpq513LT/6prHY1x6E0/yDBE=
github.com/mlange-42/arche-model v0.5.0/go.mod h1:j1EsJOoJs931fr2OQLvISaPdXFeCIEXULAYsZiVvdv8=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down
4 changes: 2 additions & 2 deletions plot/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ func (i *Inspector) Draw(w *ecs.World, win *opengl.Window) {

scroll := i.scroll

for j := 0; j < ecs.MaskTotalBits && bits > 0; j++ {
id := ecs.ID(j)
allComp := ecs.ComponentIDs(w)
for _, id := range allComp {
if mask.Get(id) {
tp, _ := w.ComponentType(id)
ptr := w.Get(sel, id)
Expand Down
4 changes: 2 additions & 2 deletions plot/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func (i *Resources) Draw(w *ecs.World, win *opengl.Window) {
scroll := i.scroll

res := w.Resources()
for j := 0; j < ecs.MaskTotalBits; j++ {
id := ecs.ResID(j)
allRes := ecs.ResourceIDs(w)
for _, id := range allRes {
if !res.Has(id) {
continue
}
Expand Down
21 changes: 21 additions & 0 deletions plot/resources_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package plot_test

import (
"testing"

"github.com/mlange-42/arche-model/model"
"github.com/mlange-42/arche-model/system"
"github.com/mlange-42/arche-pixel/plot"
"github.com/mlange-42/arche-pixel/window"
"github.com/mlange-42/arche/ecs"
)

func ExampleResources() {
Expand Down Expand Up @@ -33,3 +36,21 @@ func ExampleResources() {

// Output:
}

func TestResources(t *testing.T) {
m := model.New()

_ = ecs.AddResource[Position](&m.World, &Position{})
_ = ecs.ResourceID[Velocity](&m.World)

m.TPS = 30

m.AddUISystem((&window.Window{}).
With(&plot.Resources{}))

m.AddSystem(&system.FixedTermination{
Steps: 10,
})

m.Run()
}

0 comments on commit 6c9e59a

Please sign in to comment.