Commit graph

3597 commits

Author SHA1 Message Date
Stephen Gutekanst
34030faa9d module: fix local_events validation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-07 13:54:26 -07:00
Stephen Gutekanst
f578e1f5e2 {module,ecs}: Mach ECS becomes the Mach' module system
This moves the bulk of the ECS code into `src/module`. It also makes
types like `mach.ecs.EntityID` accessible at the top-level `mach.EntityID`
instead.

The motivation of this change is to make the Mach module system a
first-class property of Mach.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
679a05faf4 ecs: refactor comptime.zig -> Archetype.zig
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
883a9a7807 examples: add some TODOs
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
a7a6ecdd45 examples/custom-renderer: correct packed struct -> extern struct
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
8bd822c35d examples/custom-renderer: minor docs improvement
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
5659dd6266 examples/custom-renderer: cleanup docs
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
af3c1e9155 module: remove dispatchNoError, better loop implementation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
5737c62171 engine: minor App event sending cleanup
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
56c16798cd engine: fix local event sending
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
5812409078 module: document loop intention, fix test
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
95331ebf8f module: basic event docs
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
4b9379707c module: cleanup TODOs
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
0148b931ca module: make sendToModule the default name for sending events
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
cf883f5544 module: change state to avoid undefined, remove global allocator
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
5dbf9ece3b module: do not expose list of modules
Doing so would encourage accidentally creating dependency loops.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
b4a479fb3f module: basic event handler parameter validation
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Dustin Taylor
92a9836c61 ECS: @memcpy Overlap Memory Bug Fix 2024-04-06 15:18:38 -07:00
Stephen Gutekanst
3ea64966f0 module: remove TupleHACK now that dependency loop is resolved
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
b3663f7899 module: enable Module to analyze event handler signatures
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
ce0b764a6d ecs: check column type IDs before size/alignment
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
2115f5832a module: write components using a struct pattern
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
17db5498ee module: write module events using a struct pattern
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
582a3c07f6 module: elevate local/global args type construction
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
8711e5e3a7 module: rename MComponentTypes -> ComponentTypesM (consistency with LocalArgsM, etc.)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
e6a170a07a module: remove NamespacedState; module state is literally its struct type
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
17c751a2e7 module: improve variable naming slightly
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
f55aee4b50 module: rename MComponents -> MComponentTypes
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
a83f9d5be8 module: rename NamespacedComponents -> ComponentTypesByName
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
2e7cb30bc9 module: invert switch case for hypothetically better branch prediction
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
ea14480246 module: improve isString, add tests
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
0328598945 module: merge ecs/systems.zig -> module.zig
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
e847d46ff9 module: begin making Mod unaware of all namespaced components
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
df263685ab ecs: update tests
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
b1d8c2a009 ecs: fix test / typo
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
7e0b9dde68 module: components are written in the same style as events
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
f50a27b83d module: update tests for sendGlobal changes
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
23b03f973f module: make sendGlobal() global args type known
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
3661cb8721 module: sending global event requires sender module awareness
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
9eac721f24 module: make send() local args type known
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
ca05c9f3d9 module: expose Module.LocalEvent type
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
38e0d576cc module: expose Module.GlobalEvent type
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
f3f4524f1b all: improve module event names, gfx.Sprite/gfx.Text init
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
15d9efcf26 module: *World is no longer an injectable parameter
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
3bfafe102d module: event handlers are defined ahead of time
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
0fc3bf6545 module: improve parameter injection, fix tests
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
aa33896935 gfx: make Text ECS module use style entities (cleaner API design)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
0c3ae9a048 ecs: correctly update invalidated pointer post-allocation
Potentially fixes hexops/mach#1178

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
3898995c4c all: get ECS running on revised module system
All ECS `examples/` now run on the revised module system.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00
Stephen Gutekanst
cd2f3fbc3f module: test empty/minimal module
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
2024-04-06 15:18:38 -07:00