Skip to content

Commit 8f48fc0

Browse files
committed
Release version 0.2.0
1 parent cf18623 commit 8f48fc0

File tree

2 files changed

+191
-4
lines changed

2 files changed

+191
-4
lines changed

CHANGELOG.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
# Changelog
2+
3+
## v0.2.0 2021-7-23
4+
5+
This release is a complete internal restructuring to support system-owned components, new events, and a macrocache backend. Whilst effort has been made to maintain the current API, there are some significant changes.
6+
7+
### Added
8+
9+
- **Ease of use:**
10+
11+
- Improved documentation to cover all library functionality.
12+
13+
- Added code examples from documentation to the `examples` folder.
14+
15+
- More descriptive error messages.
16+
17+
- `onEcsBuilt` allows you to emit code after `makeEcs` has finished. This code can use entities and ECS operations, which can be useful for utility functions and setup for systems and libraries.
18+
19+
- `defaultComponentOptions`, `defaultEntityOptions`, and `defaultSystemOptions` now have shorter aliases as `defaultCompOpts`, `defaultEntOpts`, and `defaultSysOpts`.
20+
21+
- `EcsEntityOptions` allows selection of error response between assertions and raising exceptions.
22+
23+
- **Components:**
24+
25+
- `removeComponent`, `addComponent`, and `fetchComponent` can now be written `remove`, `add`, and `fetch`.
26+
27+
- You can now remove multiple components in one state change with `remove`/`removeComponents`.
28+
29+
- `update`/`updateComponents` supports updating multiple components with a `ComponentList`. Only existing components on the entity are updated, and others in the `ComponentList` are ignored.
30+
31+
- `typeName` converts a run time `ComponentTypeId` to the string of the type it represents.
32+
33+
- `componentCount` returns the number of components in use for a component type or instance type.
34+
35+
- `componentStorage` lets you access the component's storage list.
36+
37+
- `registerComponents` will ignore types with the `{.notComponent.}` pragma.
38+
39+
- **Systems:**
40+
41+
- You can now write code directly in the system body that is executed when the system is run. This means blocks are no longer a requirement of system bodies and you don't need to use `start` blocks to declare variables. Another benefit is you can write system code that respects the `paused` state even when not using any blocks.
42+
43+
- The `all` and `stream` blocks are now expanded within the system body. This allows multiple passes and further processing such as running code in the body between these blocks.
44+
45+
- Systems now allow multiple blocks of the same type.
46+
47+
- Systems passed the same component more than once will now throw an error at compile time.
48+
49+
- System fields can be defined with the `fields:` block within `makeSystem`. When a system has previously been defined with `defineSystem`, the `fields:` block is checked to match this definition.
50+
51+
- Systems now support a `stream stochastic:` block to randomly select items to process.
52+
53+
- Systems can be grouped to run as separate procedures with `defineGroup`. These systems are removed from the pending output of `commitSystems` and are instead emitted with `commitGroup`. It's a compile time error to emit groups with systems that don't have bodies defined.
54+
55+
- The system utility `clear` allows deleting all entities in a system.
56+
57+
- The system utility `remove` allows removing multiple components from all entities in a system.
58+
59+
- `expectSystems` checks that an entity has a specific set of systems and will `doAssert` if the entity does not satisfy these systems.
60+
61+
- `systemsUsed` returns a string containing the systems that would be used for entities with a particular set of components.
62+
63+
- `analyseSystem` provides statistical analysis of the memory addresses accessed by a system.
64+
65+
- Systems include a `deleteList` `seq` that will delete any entities added to it after the system has finished executing.
66+
67+
- Systems include an `id` field with the system's `SystemIndex`.
68+
69+
- `caseSystem` allows generic operations based on a run time `SystemIndex` in a similar way to `caseComponent`.
70+
71+
- System options given to `defineSystem` are now checked to match options passed to `makeSystemOpts`.
72+
73+
- **ECS identities:**
74+
75+
- Multiple ECS may be generated separately using `const` identity strings.
76+
77+
- **System owned components:**
78+
79+
- Systems can now own the storage and lifetime of components they use with `defineSystemOwner`. Owned components are inlined into the groups field of the owner system and depend on the system row to exist. When iterating, systems access their owned components in order as contiguous memory and without indirection. Access to owned components from other systems is a single indirection.
80+
81+
- A component type can only be owned by one system.
82+
- Adding owned components to entities without meeting the full component requirements of the owner systems will result in an error.
83+
- Removing owned components will cascade system removal for other owned components in the system.
84+
85+
- **System events:**
86+
87+
- When defining a system, you can now use `added` and `removed` blocks to let you process state changes in a system context. These events let you work with sets of components using `item` as if you were using an `all` or `stream` block.
88+
89+
- Actions in `added` and `removed` are performed immediately as part of a state change such as `add` or `remove`, and not during the system's normal cycle.
90+
91+
- **`onEntityChange` event:**
92+
93+
- This event is triggered for any entity that has components added or removed.
94+
95+
- **Run-time construction:**
96+
97+
- Creating entities with `construct` and `clone` is now more efficient and flexible.
98+
99+
- These operations are now generated as integrated state changes for dynamic sets of components.
100+
- `construct` builds a map of types then updates all relevant systems with a single generated state change.
101+
- Previously `add` was called for each component, with significant overhead.
102+
- `clone` can elide some validity checks.
103+
104+
- The `cl` macro makes building a `ComponentList` easy by allowing both source component types and container types to be mixed, whilst handling the internal `typeId` field for you. This macro also reduces boilerplate by handling a single component without having to typecast it to `Component`.
105+
106+
- `construct` and `clone` now call user events.
107+
108+
- Post construction events allow adding/removing components.
109+
110+
- `transition` allows state machine like switching of components between two `ComponentList` parameters.
111+
112+
- **Misc utilities:**
113+
114+
- `high(entityType: typedesc[EntityId] | typedesc[EntityRef])` returns the highest `EntityId` currently in use.
115+
116+
- `EntityRef` now has a `valid` template.
117+
118+
- **New templates within `caseComponent`:**
119+
120+
- `isOwned` returns a bool constant indicating if the component type is owned.
121+
122+
- `owningSystemIndex` returns the `SystemIndex` of the owner system (or `InvalidSystem` if none).
123+
124+
- `owningSystem` lets you access the component's owner system variable. Note that this is only generated for components that are owned.
125+
126+
- `componentData` lets you access the component's storage list.
127+
128+
- **Compile switches:**
129+
130+
- `ecsLog`: output ECS generation progress.
131+
132+
- `ecsLogDetails`: output detailed ECS generation information.
133+
134+
- `ecsStrict` includes a check at compile time to catch accessing `item` after a remove or delete has affected the system (which can potentially change what `item` refers to).
135+
136+
### Changes
137+
138+
- The library now uses the `macrocache` module to store the ECS state instead of `{.compileTime.}` variables.
139+
140+
- The default stream count is now `1`, changed from `10`.
141+
142+
- User events now run outside of state changes instead of inside them, and can rely on the state being fully defined when invoked.
143+
144+
- `SystemIndex` now starts from `1` and `SystemIndex(0) == InvalidSystemIndex`. Previously `InvalidSystemIndex` was equal to `SystemIndex(-1)`. This change means default (zero) values are invalid, and `SystemIndex` achieves parity with `ComponentTypeId`.
145+
146+
### Breaking changes
147+
148+
- **Removed:**
149+
150+
- `makeSystemOptFields` has been removed, as it is no longer needed. Fields in `makeSystem` and `makeSystemOpts` can be defined using the `fields:` block.
151+
152+
- The `tmpl` and `init` macros generated for each component have been removed. Use the `cl` macro or manually initialise component containers with `makeContainer`.
153+
154+
- The `deleteEntity` template within `all` and `stream` blocks has been removed as it offers no value over `entity.delete`.
155+
156+
- `reprocessRow` has been removed. This is now handled automatically at compile time.
157+
158+
- `addFetch` has been removed. This operation was ambiguous with `addComponent` and whilst `addComponent` returns a component instance, `addFetch` returned a `ComponentRef`, which is less useful. To obtain a `ComponentRef` from an instance, use the `toRef` template.
159+
160+
- `amFieldTemplates` in `EcsCompOptions.accessMethod` has been removed as it did not offer any significant functionality over `amDotOp`.
161+
162+
- Within `caseComponent`, the `componentRefInit` template has been removed as these initialisers are no longer present.
163+
164+
- **Changed:**
165+
166+
- **System execution order**: `defineSystem` now sets the order that systems are run by `commitSystems`, where previously this was set when the system *body* was defined by `makeSystem` or `makeSystemBody`. When no matching `defineSystem` exists, `makeSystem` appends order as before when it invokes `defineSystem`. This means the order must be defined before `makeEcs` is run, whereas before it could be defined after `makeEcs`.
167+
168+
- `commitSystems` will only output systems that have not already been output and are not grouped.
169+
170+
- The construction callback API has changed: constructor/clone callbacks now return a `seq[Component]` which is processed after the callback to ensure systems are correctly linked. Construction/clone callbacks should create the appropriate `Component` containers and add them to the `seq` result.
171+
172+
- Within `caseComponent`, the template `componentInstanceIds` has been renamed `componentGenerations`.
173+
174+
- The compile switch `debugSystemPerformance` is now `ecsPerformanceHints`. This option now also tracks and displays component read/write access within systems.
175+
176+
- The compile switch `debugComponentGeneration` is now `ecsLogCode`.
177+
178+
---
179+
180+
## v0.1.0 2020-5-1
181+
182+
### Added
183+
184+
- **Initial ECS design:**
185+
- Components have storage generated from their types.
186+
- All component accesses are an index to their storage.
187+
- State change operations are generated at compile time.

polymorph.nimble

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
packageName = "Polymorph"
2-
version = "0.1.0"
3-
author = "rlipsc"
4-
description = "Compile-time composable entity component system generator"
2+
version = "0.2.0"
3+
author = "Ryan Lipscombe"
4+
description = "An entity-component-system generator"
55
license = "Apache License 2.0"
66

7-
requires "nim >= 1.0.0"
7+
requires "nim >= 1.4.2"
88

99
task test, "Test suite":
1010
exec "nim c -d:debug -r tests/testall"

0 commit comments

Comments
 (0)