mirror of
https://github.com/Ukendio/jecs.git
synced 2025-04-25 09:30:03 +00:00
quick wiki
This commit is contained in:
parent
ea12df96a4
commit
770c340a94
11 changed files with 2004 additions and 295 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -54,3 +54,7 @@ WallyPatches
|
|||
roblox.toml
|
||||
sourcemap.json
|
||||
drafts/*.lua
|
||||
|
||||
# Vitepress
|
||||
docs/.vitepress/dist
|
||||
docs/.vitepress/cache
|
65
docs/.vitepress/config.mts
Normal file
65
docs/.vitepress/config.mts
Normal file
|
@ -0,0 +1,65 @@
|
|||
import { defineConfig } from 'vitepress'
|
||||
|
||||
// https://vitepress.dev/reference/site-config
|
||||
export default defineConfig({
|
||||
title: "JECS",
|
||||
description: "Just another ECS",
|
||||
themeConfig: {
|
||||
// https://vitepress.dev/reference/default-theme-config
|
||||
logo: '/logo_old.png',
|
||||
|
||||
search: { provider: 'local' },
|
||||
|
||||
nav: [
|
||||
{ text: 'Home', link: '/' },
|
||||
{ text: 'Learn', link: '/learn' },
|
||||
{ text: 'Reference', link: '/reference' }
|
||||
],
|
||||
|
||||
sidebar: {
|
||||
'/learn/': [
|
||||
{
|
||||
text: 'Learn',
|
||||
items: [
|
||||
{text: 'Getting Started', link: '/learn'},
|
||||
{text: 'Why ECS?', link: '/learn/coming-soon.md'},
|
||||
{
|
||||
text: 'Guides', link: '/learn/guides.md', items: [
|
||||
{ text: 'Entities, Components, Systems', link: '/learn/learn-ecs' },
|
||||
{ text: 'Systems Continued', link: '/learn/your-first-system'},
|
||||
{ text: 'Scheduling Systems', link: '/learn/scheduling-systems' },
|
||||
{ text: 'Querying Components', link: '/learn/coming-soon' },
|
||||
{ text: 'Querying Pairs', link: '/learn/coming-soon' },
|
||||
]
|
||||
},
|
||||
// {
|
||||
// text: 'Advanced Guides', link: '/learn/coming-soon', items: [
|
||||
// {text: 'Scheduling Systems', link: '/learn/coming-soon'},
|
||||
// {text: 'Using a Context Entity', link: '/learn/coming-soon'},
|
||||
// {text: 'Listening to Changes', link: '/learn/coming-soon'},
|
||||
// {text: 'Collecting Events', link: '/learn/coming-soon'},
|
||||
// ]
|
||||
// },
|
||||
{text: 'Best Practices', link: '/learn/coming-soon'},
|
||||
{text: 'Contributions', link: '/learn/coming-soon'},
|
||||
]
|
||||
}
|
||||
],
|
||||
'/reference/': [
|
||||
{
|
||||
text: 'Reference',
|
||||
items: [
|
||||
{ text: 'JECS', link: '/reference', items: [
|
||||
{ text: 'World', link: '/reference' },
|
||||
{ text: 'QueryIter', link: '/reference/query' },
|
||||
] },
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
|
||||
socialLinks: [
|
||||
{ icon: 'github', link: 'https://github.com/Ukendio/jecs' }
|
||||
]
|
||||
}
|
||||
})
|
49
docs/api-examples.md
Normal file
49
docs/api-examples.md
Normal file
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
outline: deep
|
||||
---
|
||||
|
||||
# Runtime API Examples
|
||||
|
||||
This page demonstrates usage of some of the runtime APIs provided by VitePress.
|
||||
|
||||
The main `useData()` API can be used to access site, theme, and page data for the current page. It works in both `.md` and `.vue` files:
|
||||
|
||||
```md
|
||||
<script setup>
|
||||
import { useData } from 'vitepress'
|
||||
|
||||
const { theme, page, frontmatter } = useData()
|
||||
</script>
|
||||
|
||||
## Results
|
||||
|
||||
### Theme Data
|
||||
<pre>{{ theme }}</pre>
|
||||
|
||||
### Page Data
|
||||
<pre>{{ page }}</pre>
|
||||
|
||||
### Page Frontmatter
|
||||
<pre>{{ frontmatter }}</pre>
|
||||
```
|
||||
|
||||
<script setup>
|
||||
import { useData } from 'vitepress'
|
||||
|
||||
const { site, theme, page, frontmatter } = useData()
|
||||
</script>
|
||||
|
||||
## Results
|
||||
|
||||
### Theme Data
|
||||
<pre>{{ theme }}</pre>
|
||||
|
||||
### Page Data
|
||||
<pre>{{ page }}</pre>
|
||||
|
||||
### Page Frontmatter
|
||||
<pre>{{ frontmatter }}</pre>
|
||||
|
||||
## More
|
||||
|
||||
Check out the documentation for the [full list of runtime APIs](https://vitepress.dev/reference/runtime-api#usedata).
|
|
@ -1,45 +0,0 @@
|
|||
# World
|
||||
|
||||
A World contains all ECS data
|
||||
Games can have multiple worlds, although typically only one is necessary. These worlds are isolated from each other, meaning they donot share the same entities nor component IDs.
|
||||
|
||||
---
|
||||
|
||||
# Entity
|
||||
|
||||
An unique id.
|
||||
|
||||
Entities consist out of a number unique to the entity in the lower 32 bits, and a counter used to track entity liveliness in the upper 32 bits. When an id is recycled, its generation count is increased. This causes recycled ids to be very large (>4 billion), which is normal.
|
||||
|
||||
---
|
||||
|
||||
# QueryIter
|
||||
|
||||
A result from the `World:query` function.
|
||||
|
||||
Queries are used to iterate over entities that match against the set collection of components.
|
||||
|
||||
Calling it in a loop will allow iteration over the results.
|
||||
|
||||
```lua
|
||||
for id, enemy, charge, model in world:query(Enemy, Charge, Model) do
|
||||
-- Do something
|
||||
end
|
||||
```
|
||||
|
||||
### QueryIter.without
|
||||
|
||||
QueryIter.without(iter: QueryIter
|
||||
...: [Entity](#Entity)): QueryIter
|
||||
|
||||
|
||||
Create a new Query Iterator from the filter
|
||||
|
||||
#### Parameters
|
||||
world The world.
|
||||
... The collection of components to filter archetypes against.
|
||||
|
||||
#### Returns
|
||||
|
||||
The new query iterator.
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
# World
|
||||
|
||||
### World.new
|
||||
|
||||
World.new(): [World](../api-types.md#World)
|
||||
|
||||
Create a new world.
|
||||
|
||||
#### Returns
|
||||
A new world
|
||||
|
||||
---
|
||||
|
||||
### World.entity
|
||||
|
||||
World.entity(world: [World](../api-types.md#World)): [Entity](../api-types.md#Entity)
|
||||
|
||||
Creates an entity in the world.
|
||||
|
||||
#### Returns
|
||||
A new entiity id
|
||||
|
||||
---
|
||||
|
||||
### World.target
|
||||
|
||||
World.target(world: [World](../api-types.md#World),
|
||||
entity: [Entity](../api-types.md#Entity),
|
||||
rel: [Entity](../api-types.md#Entity)): [Entity](../api-types.md#Entity)
|
||||
|
||||
Get the target of a relationship.
|
||||
|
||||
This will return a target (second element of a pair) of the entity for the specified relationship.
|
||||
|
||||
#### Parameters
|
||||
world The world.
|
||||
entity The entity.
|
||||
rel The relationship between the entity and the target.
|
||||
|
||||
#### Returns
|
||||
|
||||
The first target for the relationship
|
||||
|
||||
---
|
||||
|
||||
### World.add
|
||||
|
||||
World.add(world: [World](../api-types.md#World),
|
||||
entity: [Entity](../api-types.md#Entity),
|
||||
id: [Entity](../api-types.md#Entity)): [Entity](..#api-types.md#Entity)
|
||||
|
||||
Add a (component) id to an entity.
|
||||
|
||||
This operation adds a single (component) id to an entity.
|
||||
If the entity already has the id, this operation will have no side effects.
|
||||
|
||||
#### Parameters
|
||||
world The world.
|
||||
entity The entity.
|
||||
id The id to add.
|
||||
|
||||
---
|
||||
|
||||
### World.remove
|
||||
|
||||
World.remove(world: [World](../api-types#World),
|
||||
entity: [Entity](../api-types#Entity),
|
||||
id: [Entity](../api-types#Entity)): [Entity](../api-types#Entity)
|
||||
|
||||
Remove a (component) id to an entity.
|
||||
|
||||
This operation removes a single (component) id to an entity.
|
||||
If the entity already has the id, this operation will have no side effects.
|
||||
|
||||
#### Parameters
|
||||
world The world.
|
||||
entity The entity.
|
||||
id The id to add.
|
||||
|
||||
---
|
||||
|
||||
### World.get
|
||||
|
||||
World.get(world: [World](../api-types.md#World),
|
||||
entity: [Entity](../api-types.md#Entity),
|
||||
id: [Entity](../api-types.md#Entity)): any
|
||||
|
||||
Gets the component data.
|
||||
|
||||
#### Parameters
|
||||
world The world.
|
||||
entity The entity.
|
||||
id The id of component to get.
|
||||
|
||||
#### Returns
|
||||
The component data, nil if the entity does not have the componnet.
|
||||
|
||||
---
|
||||
|
||||
### World.set
|
||||
|
||||
World.set(world: [World](../api-types.md#World),
|
||||
entity: [Entity](../api-types.md#Entity),
|
||||
id: [Entity](../api-types.md#Entity)
|
||||
data: any)
|
||||
|
||||
Set the value of a component.
|
||||
|
||||
#### Parameters
|
||||
world The world.
|
||||
entity The entity.
|
||||
id The id of the componment set.
|
||||
data The data to the component.
|
||||
|
||||
---
|
||||
|
||||
### World.query
|
||||
|
||||
World.query(world: [World](../api-types.md#World),
|
||||
...: [Entity](../api-types.mdEntity)): [QueryIter](../api-types.md#QueryIter)
|
||||
|
||||
Create a QueryIter from the list of filters.
|
||||
|
||||
#### Parameters
|
||||
world The world.
|
||||
... The collection of components to match entities against.
|
||||
|
||||
#### Returns
|
||||
|
||||
The query iterator.
|
||||
|
||||
---
|
||||
|
||||
# Pair
|
||||
|
||||
### pair
|
||||
|
||||
pair(first: [Entity](../api-types#Entity), second: [Entity](../api-types#Entity)): [Entity](../api-types#Entity)
|
||||
|
||||
Creates a composite key.
|
||||
|
||||
#### Parameters
|
||||
first The first element.
|
||||
second The second element.
|
||||
|
||||
#### Returns
|
||||
|
||||
The pair of the two elements
|
||||
|
||||
---
|
||||
|
||||
### IS_PAIR
|
||||
|
||||
jecs.IS_PAIR(id: [Entity](../api-types#Entity)): boolean
|
||||
|
||||
Creates a composite key.
|
||||
|
||||
#### Parameters
|
||||
id The id to check.
|
||||
|
||||
#### Returns
|
||||
|
||||
If id is a pair.
|
||||
|
||||
---
|
||||
|
||||
# Constants
|
||||
|
||||
### OnAdd
|
||||
|
||||
---
|
||||
|
||||
### OnRemove
|
||||
|
||||
---
|
||||
|
||||
### Rest
|
||||
|
||||
---
|
||||
|
||||
### OnSet
|
||||
|
||||
---
|
||||
|
||||
### Wildcard
|
||||
|
||||
Matches any id, returns all matches.
|
81
docs/index.md
Normal file
81
docs/index.md
Normal file
|
@ -0,0 +1,81 @@
|
|||
---
|
||||
# https://vitepress.dev/reference/default-theme-home-page
|
||||
layout: home
|
||||
|
||||
hero:
|
||||
name: "JECS"
|
||||
text: "Just an ECS"
|
||||
tagline: JECS is a stupidly fast Entity Component System (ECS)
|
||||
image: "github"
|
||||
actions:
|
||||
- theme: brand
|
||||
text: Learn JECS
|
||||
link: /learn
|
||||
- theme: alt
|
||||
text: API Usage
|
||||
link: /reference
|
||||
|
||||
features:
|
||||
- title: Relational
|
||||
icon: "🧑🤝🧑"
|
||||
details: Entity Relationships as first class citizens
|
||||
- title: Powerful
|
||||
icon: "🔨"
|
||||
details: Iterate 350,000 entities at 60 frames per second
|
||||
- title: Type Safe
|
||||
icon: "👷"
|
||||
details: Type-safe Luau API (and soon Typescript 😊)
|
||||
- title: Independent
|
||||
icon: "⛔"
|
||||
details: Zero-dependency package
|
||||
- title: Fast
|
||||
icon: "⚡"
|
||||
details: Optimized for column-major operations
|
||||
- title: Memory Safe
|
||||
icon: "💾"
|
||||
details: Cache friendly archetype/SoA storage
|
||||
- title: Stable
|
||||
icon: "🛡️"
|
||||
details: Unit tested for stability
|
||||
---
|
||||
---
|
||||
|
||||
# Code 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
|
||||
```
|
||||
|
||||
---
|
85
docs/markdown-examples.md
Normal file
85
docs/markdown-examples.md
Normal file
|
@ -0,0 +1,85 @@
|
|||
# Markdown Extension Examples
|
||||
|
||||
This page demonstrates some of the built-in markdown extensions provided by VitePress.
|
||||
|
||||
## Syntax Highlighting
|
||||
|
||||
VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
|
||||
|
||||
**Input**
|
||||
|
||||
````md
|
||||
```js{4}
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
msg: 'Highlighted!'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
````
|
||||
|
||||
**Output**
|
||||
|
||||
```js{4}
|
||||
export default {
|
||||
data () {
|
||||
return {
|
||||
msg: 'Highlighted!'
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Custom Containers
|
||||
|
||||
**Input**
|
||||
|
||||
```md
|
||||
::: info
|
||||
This is an info box.
|
||||
:::
|
||||
|
||||
::: tip
|
||||
This is a tip.
|
||||
:::
|
||||
|
||||
::: warning
|
||||
This is a warning.
|
||||
:::
|
||||
|
||||
::: danger
|
||||
This is a dangerous warning.
|
||||
:::
|
||||
|
||||
::: details
|
||||
This is a details block.
|
||||
:::
|
||||
```
|
||||
|
||||
**Output**
|
||||
|
||||
::: info
|
||||
This is an info box.
|
||||
:::
|
||||
|
||||
::: tip
|
||||
This is a tip.
|
||||
:::
|
||||
|
||||
::: warning
|
||||
This is a warning.
|
||||
:::
|
||||
|
||||
::: danger
|
||||
This is a dangerous warning.
|
||||
:::
|
||||
|
||||
::: details
|
||||
This is a details block.
|
||||
:::
|
||||
|
||||
## More
|
||||
|
||||
Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
|
|
@ -1,19 +0,0 @@
|
|||
# Getting Started
|
||||
This section will provide a walk through setting up your development environment and a quick overview of the different features and concepts in Jecs with short examples.
|
||||
|
||||
## Installing Jecs
|
||||
|
||||
To use Jecs, you will need to add the library to your project's source folder.
|
||||
|
||||
## Installing as standalone
|
||||
Head over to the [Releases](https://github.com/ukendio/jecs/releases/latest) page and install the rbxm file.
|
||||

|
||||
|
||||
## Installing with Wally
|
||||
Jecs is available as a package on [wally.run](https://wally.run/package/ukendio/jecs)
|
||||
|
||||
Add it to your project's Wally.toml like this:
|
||||
```toml
|
||||
[dependencies]
|
||||
jecs = "0.1.0" # Make sure this is the latest version
|
||||
```
|
Binary file not shown.
Before Width: | Height: | Size: 34 KiB |
1674
package-lock.json
generated
1674
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -10,7 +10,10 @@
|
|||
"scripts": {
|
||||
"build": "rbxtsc",
|
||||
"watch": "rbxtsc -w",
|
||||
"prepublishOnly": "npm run build"
|
||||
"prepublishOnly": "npm run build",
|
||||
"docs:dev": "vitepress dev docs",
|
||||
"docs:build": "vitepress build docs",
|
||||
"docs:preview": "vitepress preview docs"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "Ukendio",
|
||||
|
@ -38,6 +41,7 @@
|
|||
"eslint-plugin-roblox-ts": "^0.0.32",
|
||||
"prettier": "^2.5.1",
|
||||
"roblox-ts": "^2.3.0",
|
||||
"typescript": "^5.4.2"
|
||||
"typescript": "^5.4.2",
|
||||
"vitepress": "^1.2.3"
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue