-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
157 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"aliases": { | ||
"jecs": "src", | ||
"testkit": "testkit", | ||
"jecs": "jecs", | ||
"testkit": "test/testkit", | ||
"mirror": "mirror" | ||
}, | ||
"languageMode": "strict" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,64 @@ | ||
|
||
<p align="center"> | ||
<img src="image-5.png" width=35%/> | ||
</p> | ||
|
||
[![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) | ||
|
||
Just a stupidly fast Entity Component System | ||
|
||
* [Entity Relationships](https://ajmmertens.medium.com/building-games-in-ecs-with-entity-relationships-657275ba2c6c) as first class citizens | ||
* Iterate 800,000 entities at 60 frames per second | ||
* Type-safe [Luau](https://luau-lang.org/) API | ||
* Zero-dependency package | ||
* Optimized for column-major operations | ||
* Cache friendly [archetype/SoA](https://ajmmertens.medium.com/building-an-ecs-2-archetypes-and-vectorization-fe21690805f9) storage | ||
* Rigorously [unit tested](https://github.com/Ukendio/jecs/actions/workflows/ci.yaml) for stability | ||
|
||
### Example | ||
|
||
```lua | ||
local world = jecs.World.new() | ||
local pair = jecs.pair | ||
|
||
-- These components and functions are actually already builtin | ||
-- but have been illustrated for demonstration purposes | ||
local ChildOf = world:component() | ||
local Name = world:component() | ||
|
||
local function parent(entity) | ||
return world:target(entity, ChildOf) | ||
end | ||
local function getName(entity) | ||
return world:get(entity, Name) | ||
end | ||
|
||
local alice = world:entity() | ||
world:set(alice, Name, "alice") | ||
|
||
local bob = world:entity() | ||
world:add(bob, pair(ChildOf, alice)) | ||
world:set(bob, Name, "bob") | ||
|
||
local sara = world:entity() | ||
world:add(sara, pair(ChildOf, alice)) | ||
world:set(sara, Name, "sara") | ||
|
||
print(getName(parent(sara))) | ||
|
||
for e in world:query(pair(ChildOf, alice)) do | ||
print(getName(e), "is the child of alice") | ||
end | ||
|
||
-- Output | ||
-- "alice" | ||
-- bob is the child of alice | ||
-- sara is the child of alice | ||
``` | ||
|
||
21,000 entities 125 archetypes 4 random components queried. | ||
![Queries](image-3.png) | ||
Can be found under /benches/visual/query.luau | ||
|
||
Inserting 8 components to an entity and updating them over 50 times. | ||
![Insertions](image-4.png) | ||
Can be found under /benches/visual/insertions.luau | ||
<p align="center"> | ||
<img src="assets/image-5.png" width=35%/> | ||
</p> | ||
|
||
[![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) | ||
|
||
Just a stupidly fast Entity Component System | ||
|
||
- [Entity Relationships](https://ajmmertens.medium.com/building-games-in-ecs-with-entity-relationships-657275ba2c6c) as first class citizens | ||
- Iterate 800,000 entities at 60 frames per second | ||
- Type-safe [Luau](https://luau-lang.org/) API | ||
- Zero-dependency package | ||
- Optimized for column-major operations | ||
- Cache friendly [archetype/SoA](https://ajmmertens.medium.com/building-an-ecs-2-archetypes-and-vectorization-fe21690805f9) storage | ||
- Rigorously [unit tested](https://github.com/Ukendio/jecs/actions/workflows/ci.yaml) for stability | ||
|
||
### Example | ||
|
||
```lua | ||
local world = jecs.World.new() | ||
local pair = jecs.pair | ||
|
||
-- These components and functions are actually already builtin | ||
-- but have been illustrated for demonstration purposes | ||
local ChildOf = world:component() | ||
local Name = world:component() | ||
|
||
local function parent(entity) | ||
return world:target(entity, ChildOf) | ||
end | ||
local function getName(entity) | ||
return world:get(entity, Name) | ||
end | ||
|
||
local alice = world:entity() | ||
world:set(alice, Name, "alice") | ||
|
||
local bob = world:entity() | ||
world:add(bob, pair(ChildOf, alice)) | ||
world:set(bob, Name, "bob") | ||
|
||
local sara = world:entity() | ||
world:add(sara, pair(ChildOf, alice)) | ||
world:set(sara, Name, "sara") | ||
|
||
print(getName(parent(sara))) | ||
|
||
for e in world:query(pair(ChildOf, alice)) do | ||
print(getName(e), "is the child of alice") | ||
end | ||
|
||
-- Output | ||
-- "alice" | ||
-- bob is the child of alice | ||
-- sara is the child of alice | ||
``` | ||
|
||
21,000 entities 125 archetypes 4 random components queried. | ||
![Queries](assets/image-3.png) | ||
Can be found under /benches/visual/query.luau | ||
|
||
Inserting 8 components to an entity and updating them over 50 times. | ||
![Insertions](assets/image-4.png) | ||
Can be found under /benches/visual/insertions.luau |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,28 @@ | ||
{ | ||
"name": "jecs-test", | ||
"tree": { | ||
"$className": "DataModel", | ||
"StarterPlayer": { | ||
"$className": "StarterPlayer", | ||
"StarterPlayerScripts": { | ||
"$className": "StarterPlayerScripts", | ||
"$path": "tests" | ||
} | ||
}, | ||
"ReplicatedStorage": { | ||
"$className": "ReplicatedStorage", | ||
"Lib": { | ||
"$path": "src" | ||
}, | ||
"rgb": { | ||
"$path": "rgb.luau" | ||
}, | ||
"benches": { | ||
"$path": "benches" | ||
}, | ||
"mirror": { | ||
"$path": "mirror" | ||
}, | ||
"DevPackages": { | ||
"$path": "benches/visual/DevPackages" | ||
} | ||
} | ||
} | ||
"name": "jecs-test", | ||
"tree": { | ||
"$className": "DataModel", | ||
"StarterPlayer": { | ||
"$className": "StarterPlayer", | ||
"StarterPlayerScripts": { | ||
"$className": "StarterPlayerScripts", | ||
"$path": "tests" | ||
} | ||
}, | ||
"ReplicatedStorage": { | ||
"$className": "ReplicatedStorage", | ||
"Lib": { | ||
"$path": "src" | ||
}, | ||
"benches": { | ||
"$path": "benches" | ||
}, | ||
"mirror": { | ||
"$path": "mirror" | ||
}, | ||
"DevPackages": { | ||
"$path": "benches/visual/DevPackages" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ | |
local ReplicatedStorage = game:GetService("ReplicatedStorage") | ||
local Matter = require(ReplicatedStorage.DevPackages["_Index"]["[email protected]"].matter) | ||
local ecr = require(ReplicatedStorage.DevPackages["_Index"]["[email protected]"].ecr) | ||
local rgb = require(ReplicatedStorage.rgb) | ||
local newWorld = Matter.World.new() | ||
|
||
local jecs = require(ReplicatedStorage.Lib) | ||
|
@@ -133,13 +132,6 @@ for i = 1, N do | |
end | ||
print("TEST", hm) | ||
|
||
local white = rgb.white | ||
local yellow = rgb.yellow | ||
local gray = rgb.gray | ||
local green = rgb.green | ||
|
||
local WALL = gray(" │ ") | ||
|
||
local count = 0 | ||
|
||
for _, archetype in ecs:query(D2, D4, D6, D8):archetypes() do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "jecs", | ||
"tree": { | ||
"$path": "src" | ||
} | ||
} | ||
"name": "jecs", | ||
"tree": { | ||
"$path": "jecs.luau" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
{ | ||
"name": "@rbxts/jecs", | ||
"version": "0.4.0-rc.0", | ||
"description": "Stupidly fast Entity Component System", | ||
"main": "src", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ukendio/jecs.git" | ||
}, | ||
"keywords": [], | ||
"author": "Ukendio", | ||
"contributors": [ | ||
"Ukendio", | ||
"EncodedVenom" | ||
], | ||
"homepage": "https://github.com/ukendio/jecs", | ||
"license": "MIT", | ||
"types": "src/index.d.ts", | ||
"files": [ | ||
"src", | ||
"LICENSE.md", | ||
"README.md" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@rbxts/compiler-types": "^2.3.0-types.1", | ||
"@rbxts/types": "^1.0.781", | ||
"@typescript-eslint/eslint-plugin": "^5.8.0", | ||
"@typescript-eslint/parser": "^5.8.0", | ||
"eslint": "^8.5.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-roblox-ts": "^0.0.32", | ||
"prettier": "^2.5.1", | ||
"roblox-ts": "^3.0.0", | ||
"typescript": "^5.4.2", | ||
"vitepress": "^1.3.0" | ||
}, | ||
"scripts": { | ||
"docs:dev": "vitepress dev docs", | ||
"docs:build": "vitepress build docs", | ||
"docs:preview": "vitepress preview docs" | ||
} | ||
} | ||
{ | ||
"name": "@rbxts/jecs", | ||
"version": "0.4.0", | ||
"description": "Stupidly fast Entity Component System", | ||
"main": "jecs.luau", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/ukendio/jecs.git" | ||
}, | ||
"keywords": [], | ||
"author": "Ukendio", | ||
"contributors": [ | ||
"Ukendio", | ||
"EncodedVenom" | ||
], | ||
"homepage": "https://github.com/ukendio/jecs", | ||
"license": "MIT", | ||
"types": "jecs.d.ts", | ||
"files": [ | ||
"jecs.luau", | ||
"LICENSE.md", | ||
"README.md" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"@rbxts/compiler-types": "^2.3.0-types.1", | ||
"@rbxts/types": "^1.0.781", | ||
"@typescript-eslint/eslint-plugin": "^5.8.0", | ||
"@typescript-eslint/parser": "^5.8.0", | ||
"eslint": "^8.5.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-roblox-ts": "^0.0.32", | ||
"prettier": "^2.5.1", | ||
"roblox-ts": "^3.0.0", | ||
"typescript": "^5.4.2", | ||
"vitepress": "^1.3.0" | ||
}, | ||
"scripts": { | ||
"docs:dev": "vitepress dev docs", | ||
"docs:build": "vitepress build docs", | ||
"docs:preview": "vitepress preview docs" | ||
} | ||
} |
Oops, something went wrong.