From 3597b3e48bb09cef32fa6b04a3f16d5347f96284 Mon Sep 17 00:00:00 2001 From: Martin Lange <44003176+mlange-42@users.noreply.github.com> Date: Mon, 23 Dec 2024 02:28:54 +0100 Subject: [PATCH] Fix user guide for deprecated methods (#447) --- CHANGELOG.md | 4 +++ docs/content/guide/entities/entities_test.go | 27 -------------------- docs/content/guide/entities/index.md | 22 +++++----------- 3 files changed, 10 insertions(+), 43 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b91f27fe..8265441a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ * Fixes generic `MapX.Assign` and `MapX.NewWith` notifying listeners before setting components (#445, issue #443) +### Documentation + +* Removes references to deprecated methods from the user guide (#447) + ### Other * Retract version v0.14.0 due to issue #443 and required features (#446) diff --git a/docs/content/guide/entities/entities_test.go b/docs/content/guide/entities/entities_test.go index 6ed434c3..cbcbcd47 100644 --- a/docs/content/guide/entities/entities_test.go +++ b/docs/content/guide/entities/entities_test.go @@ -53,18 +53,6 @@ func TestEntitiesCreateComponents(t *testing.T) { _ = world.NewEntity(posID, headID) } -func TestEntitiesCreateWithComponents(t *testing.T) { - world := ecs.NewWorld() - - posID := ecs.ComponentID[Position](&world) - headID := ecs.ComponentID[Heading](&world) - - _ = world.NewEntityWith( - ecs.Component{ID: posID, Comp: &Position{X: 1, Y: 2}}, - ecs.Component{ID: headID, Comp: &Heading{Angle: 180}}, - ) -} - func TestEntitiesCreateGeneric(t *testing.T) { world := ecs.NewWorld() @@ -134,21 +122,6 @@ func TestEntitiesExchangeGeneric(t *testing.T) { exchange.Exchange(entity) } -func TestEntitiesAssign(t *testing.T) { - world := ecs.NewWorld() - - posID := ecs.ComponentID[Position](&world) - headID := ecs.ComponentID[Heading](&world) - - entity := world.NewEntity() - - world.Assign( - entity, - ecs.Component{ID: posID, Comp: &Position{X: 1, Y: 2}}, - ecs.Component{ID: headID, Comp: &Heading{Angle: 180}}, - ) -} - func TestEntitiesAssignGeneric(t *testing.T) { world := ecs.NewWorld() diff --git a/docs/content/guide/entities/index.md b/docs/content/guide/entities/index.md index 7a0a5cb9..ab01f839 100644 --- a/docs/content/guide/entities/index.md +++ b/docs/content/guide/entities/index.md @@ -62,12 +62,7 @@ However, {{< api ecs World.NewEntity NewEntity >}} takes an arbitrary number of {{< code-func entities_test.go TestEntitiesCreateComponents >}} We get an entity with `Position`, and another one with `Position` and `Heading`. -In this case, the components are initialized with their zero value. -Alternatively, entities can be created with initialized components through {{< api ecs World.NewEntityWith >}}: - -{{< code-func entities_test.go TestEntitiesCreateWithComponents >}} - -We get an entity with `Position` and `Heading`, initialized according to the passed pointers. +The components of the entity are initialized with their zero values. ### Generic API @@ -77,10 +72,12 @@ Creating entities using the [generic API](./apis) requires a generic *MapX*, lik We get an entity with `Position` and `Heading`, initialized to their zero values. -Equivalent to {{< api ecs World.NewEntityWith >}}, generic MapX's have {{< api generic Map2.NewWith NewWith >}}: +Alternatively, entities can be created with initialized components through {{< api generic Map2.NewWith Map2.NewWith >}}: {{< code-func entities_test.go TestEntitiesCreateWithComponentsGeneric >}} +We get an entity with `Position` and `Heading`, initialized according to values behind the passed pointers. + {{% notice style="blue" icon="lightbulb" title="Note" %}} The `2` in `Map2` stands for the number of components. In the generic API, there are also `FilterX` and `QueryX`. @@ -112,17 +109,10 @@ First, we add `Position` and `Heading` to the entity, then we remove both. Note that generic types like *MapX* should be stored and re-used where possible, particularly over time steps. {{% /notice %}} -It is also possible to assign initialized components with {{< api ecs World.Assign >}}/{{< api generic Map2.Assign >}}, -similar to {{< api ecs World.NewWith >}}: +Using the generic API, it is also possible to assign initialized components with +{{< api generic Map2.Assign >}}, similar to {{< api generic Map2.NewWith Map2.NewWith >}}: -{{< tabs >}} -{{< tab title="generic" >}} {{< code-func entities_test.go TestEntitiesAssignGeneric >}} -{{< /tab >}} -{{< tab title="ID-based" >}} -{{< code-func entities_test.go TestEntitiesAssign >}} -{{< /tab >}} -{{< /tabs >}} ## Exchange components