Skip to content

Commit

Permalink
Fix missing listener notification in MapX.NewWith (#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange-42 authored Dec 26, 2024
1 parent 837c3c3 commit ad4aac7
Show file tree
Hide file tree
Showing 3 changed files with 163 additions and 94 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

## [[unpublished]](https://github.com/mlange-42/arche/compare/v0.14.1...main)
## [[v0.14.2]](https://github.com/mlange-42/arche/compare/v0.14.1...v0.14.2)

### Performance

Expand All @@ -8,6 +7,11 @@
### Documentation

* Fix method names and ordering in benchmark tables (#448)
* Document listener notification handling in `MapX.NewWith` (#450)

### Bugfixes

* Fix missing listener notification in `MapX.NewWith` when called with a relation target (#450)

## [[v0.14.1]](https://github.com/mlange-42/arche/compare/v0.14.0...v0.14.1)

Expand Down
9 changes: 7 additions & 2 deletions generic/_generate/map.go.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ func (m *Map{{ .Index }}{{ .Types }}) NewBatchQ(count int, target ...ecs.Entity)
// NewWith creates a new [ecs.Entity] with the Map{{ .Index }}'s components, using the supplied values.
//
// The optional argument can be used to set the target [ecs.Entity] for the Map{{ .Index }}'s [ecs.Relation].
// A potential [ecs.Listener] is notified about the relation target change in a separate event.
//
// See also [ecs.NewBuilderWith].
func (m *Map{{ .Index }}{{ .Types }}) NewWith({{ .Arguments }}, target ...ecs.Entity) ecs.Entity {
Expand All @@ -113,8 +114,12 @@ func (m *Map{{ .Index }}{{ .Types }}) NewWith({{ .Arguments }}, target ...ecs.En
if !m.hasRelation {
panic("map has no relation defined")
}
entity := m.world.NewEntity(m.ids...)
{{ .Assign }}
entity := m.world.NewEntityFn(
func(entity ecs.Entity) {
{{ .Assign }}
},
m.ids...,
)
m.world.Relations().Set(entity, m.relation, target[0])
return entity
}
Expand Down
Loading

0 comments on commit ad4aac7

Please sign in to comment.