Skip to content

Commit 766f7b9

Browse files
committed
update README
1 parent e364aaa commit 766f7b9

1 file changed

Lines changed: 38 additions & 38 deletions

File tree

README.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,15 @@
4545
- [Batch Operations](#batch-operations)
4646
- [Systems](#systems)
4747
- [Processing Payloads](#processing-payloads)
48-
- [Predefined Traits](#predefined-traits)
48+
- [Predefined Fragments](#predefined-fragments)
49+
- [Entity Names](#entity-names)
4950
- [Fragment Tags](#fragment-tags)
5051
- [Fragment Hooks](#fragment-hooks)
5152
- [Unique Fragments](#unique-fragments)
5253
- [Explicit Fragments](#explicit-fragments)
5354
- [Internal Fragments](#internal-fragments)
5455
- [Shared Components](#shared-components)
5556
- [Fragment Requirements](#fragment-requirements)
56-
- [Id Names](#id-names)
5757
- [Destruction Policies](#destruction-policies)
5858
- [Custom Component Storages](#custom-component-storages)
5959
- [Garbage Collection](#garbage-collection)
@@ -983,7 +983,42 @@ evolved.process_with(physics_system, delta_time)
983983

984984
`delta_time` in this example is passed as a processing payload to the system's execution callback. Payloads can be of any type and can be multiple values. Also, payloads are passed to prologue and epilogue callbacks if they are defined. Every subsystem in a group will receive the same payload when the group is processed with [`evolved.process_with`](#evolvedprocess_with).
985985

986-
### Predefined Traits
986+
### Predefined Fragments
987+
988+
#### Entity Names
989+
990+
The library provides a way to assign names to any id using the [`evolved.NAME`](#evolvedname) fragment. This is useful for debugging and development purposes, as it allows you to identify entities or fragments by their names instead of their identifiers. The name of an entity can be retrieved using the [`evolved.name`](#evolvedname-1) function.
991+
992+
```lua
993+
local evolved = require 'evolved'
994+
995+
local player = evolved.builder()
996+
:name('Player')
997+
:build()
998+
999+
assert(evolved.name(player) == 'Player')
1000+
```
1001+
1002+
Names are not unique, so multiple entities can have the same name. Also, the name of an entity can be changed at any time by setting a new name using the [`evolved.NAME`](#evolvedname) fragment as a usual component.
1003+
1004+
You can find entities by their names using the [`evolved.lookup`](#evolvedlookup) and [`evolved.multi_lookup`](#evolvedmulti_lookup) functions. The [`evolved.lookup`](#evolvedlookup) function returns the first entity with the specified name, while the [`evolved.multi_lookup`](#evolvedmulti_lookup) function returns a list of all entities with the specified name.
1005+
1006+
```lua
1007+
local evolved = require 'evolved'
1008+
1009+
local player1 = evolved.builder()
1010+
:name('Player')
1011+
:build()
1012+
1013+
local player2 = evolved.builder()
1014+
:name('Player')
1015+
:build()
1016+
1017+
assert(evolved.lookup('Player') == player1)
1018+
1019+
local player_list, player_count = evolved.multi_lookup('Player')
1020+
assert(player_count == 2 and player_list[1] == player1 and player_list[2] == player2)
1021+
```
9871022

9881023
#### Fragment Tags
9891024

@@ -1163,41 +1198,6 @@ local enemy = evolved.builder()
11631198
assert(evolved.has_all(enemy, position, velocity))
11641199
```
11651200

1166-
#### Id Names
1167-
1168-
The library provides a way to assign names to any id using the [`evolved.NAME`](#evolvedname) fragment. This is useful for debugging and development purposes, as it allows you to identify entities or fragments by their names instead of their identifiers. The name of an entity can be retrieved using the [`evolved.name`](#evolvedname-1) function.
1169-
1170-
```lua
1171-
local evolved = require 'evolved'
1172-
1173-
local player = evolved.builder()
1174-
:name('Player')
1175-
:build()
1176-
1177-
assert(evolved.name(player) == 'Player')
1178-
```
1179-
1180-
Names are not unique, so multiple entities can have the same name. Also, the name of an entity can be changed at any time by setting a new name using the [`evolved.NAME`](#evolvedname) fragment as a usual component.
1181-
1182-
You can find entities by their names using the [`evolved.lookup`](#evolvedlookup) and [`evolved.multi_lookup`](#evolvedmulti_lookup) functions. The [`evolved.lookup`](#evolvedlookup) function returns the first entity with the specified name, while the [`evolved.multi_lookup`](#evolvedmulti_lookup) function returns a list of all entities with the specified name.
1183-
1184-
```lua
1185-
local evolved = require 'evolved'
1186-
1187-
local player1 = evolved.builder()
1188-
:name('Player')
1189-
:build()
1190-
1191-
local player2 = evolved.builder()
1192-
:name('Player')
1193-
:build()
1194-
1195-
assert(evolved.lookup('Player') == player1)
1196-
1197-
local player_list, player_count = evolved.multi_lookup('Player')
1198-
assert(player_count == 2 and player_list[1] == player1 and player_list[2] == player2)
1199-
```
1200-
12011201
#### Destruction Policies
12021202

12031203
Typically, fragments remain alive for the entire lifetime of the program. However, in some cases, you might want to destroy fragments when they are no longer needed. For example, you can use some runtime entities as fragments for other entities. In this case, you might want to destroy such fragments even while they are still attached to other entities. Since entities cannot have destroyed fragments, a destruction policy must be applied to resolve this. By default, the library will remove the destroyed fragment from all entities that have it.

0 commit comments

Comments
 (0)