You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In Ark, entities are returned to a pool when they are removed from the world.
48
-
These entities can be recycled, with the same ID ({{< api ecs Entity.ID Entity.ID >}}), but an incremented generation ({{< api ecs Entity.Gen Entity.Gen >}}).
48
+
These entities can be recycled, with the same ID ({{< api ecs Entity.ID >}}), but an incremented generation ({{< api ecs Entity.Gen >}}).
49
49
This allows to determine whether an entity held by the user is still alive, despite it was potentially recycled.
Copy file name to clipboardExpand all lines: docs/content/relations/index.md
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ for relations with different target entities.
34
34
35
35
## Relation components
36
36
37
-
To use entity relations, create components that have *embedded*an {{< api ecs RelationMarker >}} as their first member:
37
+
To use entity relations, create components that have *embedded*a {{< api ecs RelationMarker >}} as their first member:
38
38
39
39
```go
40
40
typeChildOfstruct {
@@ -48,11 +48,12 @@ The component can contain further variables, but the marker must be the first on
48
48
## Creating relations
49
49
50
50
Most methods of `MapX` (e.g. {{< api ecs Map2 >}}) provide var-args for specifying relationship targets.
51
-
These are of type {{< api Relation >}}, which is an interface with multiple implementations:
51
+
These are of type {{< api ecs Relation >}}, which specifies a component type and a target entity.
52
+
There are multiple constructors for {{< api ecs Relation >}}:
52
53
53
-
{{< api Rel >}} is safe, but has some run-time overhead for component ID lookup.
54
-
55
-
{{< api RelIdx >}} is fast but more error-prone.
54
+
-{{< api ecs Rel >}} uses a generic type parameter to identify the component. It is safe, but has some run-time overhead for component ID lookup on first usage.
55
+
- {{< api ecs RelIdx >}} uses an index to identify the component. It is fast but more error-prone.
56
+
-{{< api ecs RelID >}} uses a component ID. It is for use with the [unsafe API](../unsafe/).
56
57
57
58
See the examples below for their usage.
58
59
@@ -62,10 +63,10 @@ When creating entities, we can use a `MapX` (e.g. {{< api ecs Map2.NewEntity >}}
62
63
63
64
{{< code-func relations_test.go TestNewEntity >}}
64
65
65
-
For the faster variant {{< api RelIdx >}}, note that the first argument
66
+
For the faster variant {{< api ecs RelIdx >}}, note that the first argument
66
67
is the zero-based index of the relation component in the {{< api ecs Map2 >}}'s generic parameters.
67
68
68
-
If there are multiple relation components, multiple {{< api Rel >}}/{{< api RelIdx >}} arguments can (and must) be used.
69
+
If there are multiple relation components, multiple {{< api ecs Rel >}}/{{< api ecs RelIdx >}} arguments can (and must) be used.
69
70
70
71
### When adding components
71
72
@@ -115,9 +116,9 @@ For short-lived targets, it is better to pass them when building a query with {{
115
116
116
117
These targets are not cached, but the same filter can be used for different targets.
117
118
118
-
Filters also support both {{< api Rel >}} and {{< api RelIdx >}}.
119
-
In the filter examples above, we used the slow but safe {{< api Rel >}} when building the filter.
120
-
When getting the query, we use the faster {{< api RelIdx >}},
119
+
Filters also support both {{< api ecs Rel >}} and {{< api ecs RelIdx >}}.
120
+
In the filter examples above, we used the slow but safe {{< api ecs Rel >}} when building the filter.
121
+
When getting the query, we use the faster {{< api ecs RelIdx >}},
121
122
because in real-world use cases this is called more frequently than the one-time filter construction.
122
123
123
124
Relation targets not specified by the filter are treated as wildcard.
@@ -180,4 +181,4 @@ to represent animals of different species in multiple farms.
180
181
{{< code relations_example_test.go >}}
181
182
182
183
Note that this examples uses the safe and clear, but slower generic variant to specify relationship targets.
183
-
As an optimization, {{< api RelIdx >}} could be used instead of {{< api Rel >}}, particularly for queries.
184
+
As an optimization, {{< api ecs RelIdx >}} could be used instead of {{< api ecs Rel >}}, particularly for queries.
0 commit comments