Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix user guide for deprecated methods #447

Merged
merged 3 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 0 additions & 27 deletions docs/content/guide/entities/entities_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
22 changes: 6 additions & 16 deletions docs/content/guide/entities/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`.
Expand Down Expand Up @@ -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

Expand Down
Loading