Initial push
This commit is contained in:
commit
6a08d8d7f4
8 changed files with 2118 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.env
|
8
.luaurc
Normal file
8
.luaurc
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"aliases": {
|
||||
"jecs": "src",
|
||||
"testkit": "testkit",
|
||||
"mirror": "mirror",
|
||||
},
|
||||
"languageMode": "strict"
|
||||
}
|
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2024 jecs authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
65
README.md
Normal file
65
README.md
Normal file
|
@ -0,0 +1,65 @@
|
|||
|
||||
<p align="center">
|
||||
<img src="jecs_darkmode.svg#gh-dark-mode-only" width=50%/>
|
||||
<img src="jecs_lightmode.svg#gh-light-mode-only" width=50%/>
|
||||
</p>
|
||||
|
||||
[![License: Apache 2.0](https://img.shields.io/badge/License-Apache-blue.svg?style=for-the-badge)](LICENSE-APACHE)
|
||||
[![Wally](https://img.shields.io/github/v/tag/ukendio/jecs?&style=for-the-badge)](https://wally.run/package/ukendio/jecs)
|
||||
|
||||
jecs is Just a stupidly fast Entity Component System
|
||||
|
||||
- Entity Relationships 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 storage
|
||||
- Unit tested for stability
|
||||
|
||||
### Example
|
||||
|
||||
```lua
|
||||
local world = jecs.World.new()
|
||||
local pair = jecs.pair
|
||||
|
||||
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
|
13
pesde.toml
Normal file
13
pesde.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
name = "marked/jecs_pesde"
|
||||
description = "A minimal copy of jecs intended for adding as a Luau git dependency on pesde projects"
|
||||
version = "0.3.2"
|
||||
repository = "https://git.devmarked.win/marked/jecs-pesde"
|
||||
|
||||
includes = ["init.luau", "pesde.toml", "README.md", "LICENSE", ".luaurc"]
|
||||
|
||||
[target]
|
||||
environment = "luau"
|
||||
lib = "init.luau"
|
||||
|
||||
[indices]
|
||||
default = "https://github.com/daimond113/pesde-index"
|
113
pull.luau
Normal file
113
pull.luau
Normal file
|
@ -0,0 +1,113 @@
|
|||
--!strict
|
||||
local task = require("@lune/task")
|
||||
local process = require("@lune/process")
|
||||
local fs = require("@lune/fs")
|
||||
local net = require("@lune/net")
|
||||
local serde = require("@lune/serde")
|
||||
|
||||
print("-- 🟧 Starting pull of latest release...")
|
||||
|
||||
type wally_manifest = {
|
||||
package: {
|
||||
name: string,
|
||||
version: string,
|
||||
registry: string,
|
||||
realm: string,
|
||||
license: string?,
|
||||
exclude: { string }?,
|
||||
include: { string }?,
|
||||
},
|
||||
dependencies: {
|
||||
[string]: string,
|
||||
},
|
||||
}
|
||||
|
||||
print("🟧 Fetching github token...")
|
||||
local github_token: string = process.args[1]
|
||||
|
||||
if not github_token then
|
||||
local env_exists = fs.metadata(".env").exists
|
||||
if not env_exists then
|
||||
error("Usage: lune run download-jecs [GITHUB_PAT]\nAlternatively, put the PAT in an .env file under GITHUB_PAT")
|
||||
end
|
||||
|
||||
local env = serde.decode("toml", fs.readFile(".env"))
|
||||
local pat = env.GITHUB_PAT or error("❌ Couldn't read GITHUB_PAT from .env")
|
||||
github_token = pat
|
||||
end
|
||||
print("✅ Got github token.")
|
||||
|
||||
--local manifest_contents = fs.readFile("wally.toml") or error("Couldn't read manifest.")
|
||||
print("🟧 Fetching latest jecs wally manifest...")
|
||||
local pull_manifest_res = net.request("https://raw.githubusercontent.com/Ukendio/jecs/refs/heads/main/wally.toml")
|
||||
if not pull_manifest_res.ok then
|
||||
error(`❌ Couldn't download jecs manifest: {pull_manifest_res.statusCode} {pull_manifest_res.statusMessage}`)
|
||||
end
|
||||
local manifest_contents = pull_manifest_res.body
|
||||
local manifest: wally_manifest = serde.decode("toml", manifest_contents) or error("Couldn't decode manifest.")
|
||||
local jecs_version = manifest.package.version
|
||||
print(`✅ Got latest manifest. Version: {jecs_version}`)
|
||||
|
||||
type gh_api_tag = {
|
||||
ref: string,
|
||||
node_id: string,
|
||||
url: string,
|
||||
object: {
|
||||
sha: string,
|
||||
type: string,
|
||||
url: string,
|
||||
},
|
||||
}
|
||||
|
||||
print("🟧 Getting tag associated with version in manifest...")
|
||||
local response = net.request({
|
||||
url = `https://api.github.com/repos/ukendio/jecs/git/refs/tags/v{jecs_version}`,
|
||||
method = "GET",
|
||||
headers = {
|
||||
Accept = "application/vnd.github+json",
|
||||
Authorization = `Bearer {github_token}`,
|
||||
["X-GitHub-Api-Version"] = "2022-11-28",
|
||||
},
|
||||
})
|
||||
|
||||
if not response.ok then
|
||||
error(`❌ Github api response not ok:\n{response.statusCode} @ {response.statusMessage}\n{response.body}`)
|
||||
end
|
||||
|
||||
local gh_api_tag: gh_api_tag = serde.decode("json", response.body)
|
||||
print(`✅ Got associated tag: {gh_api_tag.object.sha}`)
|
||||
|
||||
local URL = `https://raw.githubusercontent.com/Ukendio/jecs/{gh_api_tag.object.sha}/`
|
||||
local function download(path: string, output: string)
|
||||
process.spawn("curl", { URL .. path, "-o", output })
|
||||
end
|
||||
|
||||
local function download_list(list: { { path: string, output: string } })
|
||||
local n = #list
|
||||
print(`🟧 Downloading {n} files...`)
|
||||
|
||||
for idx = 1, n do
|
||||
local file = list[idx]
|
||||
|
||||
print(`Downloading file {idx}/{n} - {file.path} -> {file.output}...`)
|
||||
download(file.path, file.output)
|
||||
end
|
||||
|
||||
print(`✅ Downloaded {n} files.`)
|
||||
end
|
||||
|
||||
download_list({
|
||||
{ path = "src/init.luau", output = "init.luau" },
|
||||
{ path = ".luaurc", output = ".luaurc" },
|
||||
{ path = "LICENSE", output = "LICENSE" },
|
||||
{ path = "README.md", output = "README.md" },
|
||||
})
|
||||
|
||||
print("🟧 Writing pesde manifest...")
|
||||
local pesde_manifest =
|
||||
`name = "marked/jecs_pesde"\ndescription = "A minimal copy of jecs intended for adding as a Luau git dependency on pesde projects"\nversion = "{jecs_version}"\nrepository = "https://git.devmarked.win/marked/jecs-pesde"\n\nincludes = ["init.luau", "pesde.toml", "README.md", "LICENSE", ".luaurc"]\n\n[target]\nenvironment = "luau"\nlib = "init.luau"\n\n[indices]\ndefault = "https://github.com/daimond113/pesde-index"`
|
||||
|
||||
fs.writeFile("pesde.toml", pesde_manifest)
|
||||
print("✅ Wrote pesde manifest.")
|
||||
|
||||
print("-- ✅ Finished pulling latest release.")
|
8
rokit.toml
Normal file
8
rokit.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
# This file lists tools managed by Rokit, a toolchain manager for Roblox projects.
|
||||
# For more information, see https://github.com/rojo-rbx/rokit
|
||||
|
||||
# New tools can be added by running `rokit add <tool>` in a terminal.
|
||||
|
||||
[tools]
|
||||
lune = "lune-org/lune@0.8.9"
|
||||
pesde = "daimond113/pesde@0.5.0-rc.7"
|
Loading…
Reference in a new issue