From 4a5a425a9c9370f10b6823cc82e2f6dd8e94802e Mon Sep 17 00:00:00 2001 From: Raghav Arora Date: Thu, 20 Feb 2025 00:16:57 +0530 Subject: [PATCH] Updated with changes as per PR #194 --- README.md | 17 +++- docs/learn/faq/migrating-from-matter.md | 122 ------------------------ 2 files changed, 13 insertions(+), 126 deletions(-) delete mode 100644 docs/learn/faq/migrating-from-matter.md diff --git a/README.md b/README.md index 1625540..b1be75c 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@
Jecs Logo - + # Jecs ### Just a Stupidly Fast Entity Component System - - [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](LICENSE) + + [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](LICENSE) [![Wally](https://img.shields.io/github/v/tag/ukendio/jecs?&style=for-the-badge)](https://wally.run/package/ukendio/jecs)
@@ -22,14 +22,22 @@ ```lua local world = jecs.World.new() local pair = jecs.pair +local Position = world:component() :: jecs.Id +local Velocity = world:component() :: jecs.Id -- These components and functions are actually already builtin -- but have been illustrated for demonstration purposes local ChildOf = world:component() local Name = world:component() +local entity = world:entity() +world:set(entity, Position, Vector3.new(0, 0, 0)) +world:set(entity, Velocity, Vector3.new(1, 0, 0)) local function parent(entity) return world:target(entity, ChildOf) +-- Update system (example) +for id, position, velocity in world:query(Position, Velocity) do + world:set(id, Position, position + velocity) end local function getName(entity) @@ -88,4 +96,5 @@ Please read our [Contributing Guidelines](CONTRIBUTING.md) before submitting pul ## 📄 License -Jecs is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. \ No newline at end of file +Jecs is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. +``` diff --git a/docs/learn/faq/migrating-from-matter.md b/docs/learn/faq/migrating-from-matter.md deleted file mode 100644 index 4b2ad28..0000000 --- a/docs/learn/faq/migrating-from-matter.md +++ /dev/null @@ -1,122 +0,0 @@ -# Migrating from Matter - -This guide helps you migrate your code from Matter ECS to Jecs. - -## Key Differences - -### World Creation -```lua --- Matter -local world = Matter.World.new() - --- Jecs -local world = jecs.World.new() -``` - -### Component Definition -```lua --- Matter -local Position = { name = "Position" } -local Velocity = { name = "Velocity" } - --- Jecs -local Position = world:component() :: jecs.Entity -local Velocity = world:component() :: jecs.Entity -``` - -### Entity Creation -```lua --- Matter -local entity = world:spawn() - --- Jecs -local entity = world:entity() -``` - -### Adding Components -```lua --- Matter -world:insert(entity, Position, { x = 0, y = 0, z = 0 }) - --- Jecs -world:set(entity, Position, Vector3.new(0, 0, 0)) -``` - -### Querying -```lua --- Matter -for id, pos, vel in world:query(Position, Velocity) do - -- Process entities -end - --- Jecs -for id, pos, vel in world:query(Position, Velocity) do - -- Process entities -end -``` - -## Major Feature Differences - -### Relationships -Jecs provides built-in support for entity relationships: -```lua --- Jecs only -world:add(child, pair(ChildOf, parent)) -``` - -### Component Traits -Jecs allows adding traits to components: -```lua --- Jecs only -world:add(Position, Networked) -``` - -### Query Caching -Jecs provides explicit query caching: -```lua --- Jecs only -local cachedQuery = world:query(Position, Velocity):cached() -``` - -## Migration Steps - -1. **Update Component Definitions** - - Replace Matter component tables with Jecs components - - Add type annotations for better type safety - -2. **Update Entity Management** - - Replace `spawn()` with `entity()` - - Update component insertion syntax - -3. **Update Queries** - - Review and update query usage - - Consider using query caching for performance - -4. **Add Relationships** - - Replace custom parent-child implementations with Jecs relationships - - Use built-in relationship features - -5. **Update Systems** - - Review system implementation patterns - - Consider using component traits for better organization - -## Performance Considerations - -1. **Query Performance** - - Cache frequently used queries - - Use appropriate filters - -2. **Component Storage** - - Use tags for boolean states - - Consider component data structure size - -3. **Relationship Usage** - - Be mindful of relationship complexity - - Use built-in relationships when possible - -## Getting Help - -Need help migrating? -- Join our [Discord server](https://discord.gg/h2NV8PqhAD) -- Check the [API documentation](../../api/jecs.md) -- Open an issue on [GitHub](https://github.com/ukendio/jecs/issues) \ No newline at end of file