diff --git a/.luaurc b/.luaurc index 73598d29..07221f7b 100644 --- a/.luaurc +++ b/.luaurc @@ -1,8 +1,8 @@ { "aliases": { - "jecs": "src", - "testkit": "testkit", + "jecs": "jecs", + "testkit": "test/testkit", "mirror": "mirror" }, "languageMode": "strict" -} \ No newline at end of file +} diff --git a/README.md b/README.md index 9e5a24d2..d44797ce 100644 --- a/README.md +++ b/README.md @@ -1,65 +1,64 @@ - -
- -
- -[![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 ++ +
+ +[![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 diff --git a/image-1.png b/assets/image-1.png similarity index 100% rename from image-1.png rename to assets/image-1.png diff --git a/image-2.png b/assets/image-2.png similarity index 100% rename from image-2.png rename to assets/image-2.png diff --git a/image-3.png b/assets/image-3.png similarity index 100% rename from image-3.png rename to assets/image-3.png diff --git a/image-4.png b/assets/image-4.png similarity index 100% rename from image-4.png rename to assets/image-4.png diff --git a/image-5.png b/assets/image-5.png similarity index 100% rename from image-5.png rename to assets/image-5.png diff --git a/jecs_darkmode.svg b/assets/jecs_darkmode.svg similarity index 99% rename from jecs_darkmode.svg rename to assets/jecs_darkmode.svg index f64b173d..23a466e2 100644 --- a/jecs_darkmode.svg +++ b/assets/jecs_darkmode.svg @@ -1,6 +1,6 @@ - + diff --git a/jecs_lightmode.svg b/assets/jecs_lightmode.svg similarity index 99% rename from jecs_lightmode.svg rename to assets/jecs_lightmode.svg index dbcd08c7..cc93360f 100644 --- a/jecs_lightmode.svg +++ b/assets/jecs_lightmode.svg @@ -1,6 +1,6 @@ - + diff --git a/logo_old.png b/assets/logo_old.png similarity index 100% rename from logo_old.png rename to assets/logo_old.png diff --git a/bench.project.json b/bench.project.json index efb20916..2ffa974d 100644 --- a/bench.project.json +++ b/bench.project.json @@ -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" + } + } + } } diff --git a/benches/visual/despawn.bench.luau b/benches/visual/despawn.bench.luau index 40e033c8..8bcf1dc3 100644 --- a/benches/visual/despawn.bench.luau +++ b/benches/visual/despawn.bench.luau @@ -5,7 +5,6 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local Matter = require(ReplicatedStorage.DevPackages.Matter) local ecr = require(ReplicatedStorage.DevPackages.ecr) local jecs = require(ReplicatedStorage.Lib) -local rgb = require(ReplicatedStorage.rgb) local newWorld = Matter.World.new() local ecs = jecs.World.new() diff --git a/benches/visual/query.bench.luau b/benches/visual/query.bench.luau index 1761eea1..16602f14 100644 --- a/benches/visual/query.bench.luau +++ b/benches/visual/query.bench.luau @@ -4,7 +4,6 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local Matter = require(ReplicatedStorage.DevPackages["_Index"]["matter-ecs_matter@0.8.1"].matter) local ecr = require(ReplicatedStorage.DevPackages["_Index"]["centau_ecr@0.8.0"].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 diff --git a/benches/visual/spawn.bench.luau b/benches/visual/spawn.bench.luau index 0948fcd9..5dc2b84a 100644 --- a/benches/visual/spawn.bench.luau +++ b/benches/visual/spawn.bench.luau @@ -5,7 +5,6 @@ local ReplicatedStorage = game:GetService("ReplicatedStorage") local Matter = require(ReplicatedStorage.DevPackages.Matter) local ecr = require(ReplicatedStorage.DevPackages.ecr) local jecs = require(ReplicatedStorage.Lib) -local rgb = require(ReplicatedStorage.rgb) local newWorld = Matter.World.new() local ecs = jecs.World.new() diff --git a/default.project.json b/default.project.json index c53955bb..d4531a0f 100644 --- a/default.project.json +++ b/default.project.json @@ -1,6 +1,6 @@ { - "name": "jecs", - "tree": { - "$path": "src" - } - } + "name": "jecs", + "tree": { + "$path": "jecs.luau" + } +} diff --git a/src/index.d.ts b/jecs.d.ts similarity index 100% rename from src/index.d.ts rename to jecs.d.ts diff --git a/src/init.luau b/jecs.luau similarity index 100% rename from src/init.luau rename to jecs.luau diff --git a/mirror/init.luau b/mirror.luau similarity index 100% rename from mirror/init.luau rename to mirror.luau diff --git a/package.json b/package.json index 5c2cccc2..43d13e67 100644 --- a/package.json +++ b/package.json @@ -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" + } +} diff --git a/rgb.luau b/rgb.luau deleted file mode 100644 index a391f8eb..00000000 --- a/rgb.luau +++ /dev/null @@ -1,33 +0,0 @@ -return { - white_underline = function(s: any) - return `\27[1;4m{s}\27[0m` - end, - - white = function(s: any) - return `\27[37;1m{s}\27[0m` - end, - - green = function(s: any) - return `\27[32;1m{s}\27[0m` - end, - - red = function(s: any) - return `\27[31;1m{s}\27[0m` - end, - - yellow = function(s: any) - return `\27[33;1m{s}\27[0m` - end, - - red_highlight = function(s: any) - return `\27[41;1;30m{s}\27[0m` - end, - - green_highlight = function(s: any) - return `\27[42;1;30m{s}\27[0m` - end, - - gray = function(s: any) - return `\27[30;1m{s}\27[0m` - end, -} diff --git a/test.project.json b/test.project.json deleted file mode 100644 index 0a3901a2..00000000 --- a/test.project.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "jecs-test", - "tree": { - "$className": "DataModel", - "StarterPlayer": { - "$className": "StarterPlayer", - "StarterPlayerScripts": { - "$className": "StarterPlayerScripts", - "$path": "tests" - } - }, - "ReplicatedStorage": { - "$className": "ReplicatedStorage", - "Lib": { - "$path": "lib" - }, - "rgb": { - "$path": "rgb.lua" - }, - "benches": { - "$path": "benches" - }, - "mirror": { - "$path": "mirror" - } - } - } - } - \ No newline at end of file diff --git a/testkit.luau b/test/testkit.luau similarity index 100% rename from testkit.luau rename to test/testkit.luau diff --git a/testez-companion.toml b/testez-companion.toml deleted file mode 100644 index 4de0c23d..00000000 --- a/testez-companion.toml +++ /dev/null @@ -1,3 +0,0 @@ -roots = ["ServerStorage"] - -[extraOptions] diff --git a/wally.toml b/wally.toml index 09262ca4..b1ceef4a 100644 --- a/wally.toml +++ b/wally.toml @@ -6,8 +6,7 @@ realm = "shared" license = "MIT" include = [ "default.project.json", - "src/**", - "src", + "jecs.luau", "wally.toml", "README.md", "CHANGELOG.md",