jecs/README.md

145 lines
4.7 KiB
Markdown
Raw Normal View History

2024-11-23 03:42:54 +00:00
<p align="center">
<img src="assets/image-5.png" width=35%/>
</p>
2025-02-19 18:31:27 +00:00
<div align="center">
<img src="assets/image-5.png" width="240" alt="Jecs Logo"/>
2024-11-23 03:42:54 +00:00
[![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)
2025-02-19 18:31:27 +00:00
# Jecs
### Just a Stupidly Fast ECS for Roblox
2024-11-23 03:42:54 +00:00
2025-02-19 18:31:27 +00:00
[![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)
2025-02-19 18:25:43 +00:00
2025-02-19 16:10:38 +00:00
# Jecs - Just a Stupidly Fast ECS
2025-02-19 18:31:27 +00:00
A high-performance Entity Component System (ECS) for Roblox games, with first-class support for both Luau and TypeScript.
</div>
2024-11-23 03:42:54 +00:00
2025-02-19 18:25:43 +00:00
A high-performance Entity Component System (ECS) for Roblox games, supporting both Luau and TypeScript.
2025-02-19 18:31:27 +00:00
## ✨ Features
2024-11-23 03:42:54 +00:00
2025-02-19 16:10:38 +00:00
## Features
2025-02-19 18:31:27 +00:00
- 🚀 **Blazing Fast:** Iterate over hundreds of thousands of entities at 60 FPS
- 🔗 **Entity Relationships:** First-class support for entity relationships
- 🏷️ **Component Traits:** Add metadata and behavior to components
- 📝 **Type Safety:** Fully typed API for both Luau and TypeScript
- 🎯 **Zero Dependencies:** Simple integration with no external dependencies
-**Optimized Storage:** Cache-friendly archetype/SoA storage
-**Battle-tested:** Comprehensive test coverage
- 📚 **Well Documented:** Clear, thorough documentation and examples
2025-02-19 16:10:38 +00:00
2025-02-19 18:26:50 +00:00
* **Blazing Fast:** Iterate over hundreds of thousands of entities at 60 frames per second. Benchmark results are available in the documentation.
2025-02-19 18:25:43 +00:00
* **Entity Relationships:** First-class support for defining and querying relationships between entities.
* **Type Safety:** Fully typed API for both Luau and TypeScript, enhancing code maintainability and reducing errors.
* **Zero Dependencies:** No external dependencies required, simplifying integration into your project.
* **Optimized Storage:** Cache-friendly archetype/SoA (Structure of Arrays) storage for optimal performance.
* **Battle-tested:** Rigorously unit tested for stability and reliability.
2025-02-19 18:26:50 +00:00
* **Comprehensive Documentation:** Detailed documentation guides you through installation, usage, and advanced concepts.
2025-02-19 18:31:27 +00:00
## 🚀 Quick Start
2025-02-19 18:25:43 +00:00
2025-02-19 18:31:27 +00:00
### Installation
2025-02-19 16:10:38 +00:00
## Documentation
2025-02-19 18:25:43 +00:00
* [Getting Started](docs/learn/overview/get-started.md)
2025-02-19 18:26:50 +00:00
* [API Reference](docs/api/jecs.md) (Note: This link may need updating to reflect the actual location of the API docs if they are generated separately)
2025-02-19 18:25:43 +00:00
* [Concepts](docs/learn/concepts/)
* Entities and Components
* Queries
* Relationships
* Component Traits
* Addons
* [Examples](examples/)
* [FAQ](docs/learn/faq/common-issues.md)
* [Contributing](docs/contributing/)
2025-02-19 16:10:38 +00:00
2025-02-19 18:25:43 +00:00
## Quick Example (Luau)
2024-11-23 03:42:54 +00:00
```lua
local world = jecs.World.new()
2025-02-19 16:10:38 +00:00
local Position = world:component() :: jecs.Entity<Vector3>
local Velocity = world:component() :: jecs.Entity<Vector3>
2024-11-23 03:42:54 +00:00
2025-02-19 16:10:38 +00:00
local entity = world:entity()
world:set(entity, Position, Vector3.new(0, 0, 0))
world:set(entity, Velocity, Vector3.new(1, 0, 0))
2025-02-19 18:25:43 +00:00
-- Update system (example)
2025-02-19 16:10:38 +00:00
for id, position, velocity in world:query(Position, Velocity) do
world:set(id, Position, position + velocity)
2024-11-23 03:42:54 +00:00
end
2025-02-19 16:10:38 +00:00
```
2024-11-23 03:42:54 +00:00
2025-02-19 18:25:43 +00:00
## Quick Example (TypeScript)
```typescript
import { World } from "@rbxts/jecs";
2024-11-23 03:42:54 +00:00
2025-02-19 18:25:43 +00:00
const world = new World();
const Position = world.component<Vector3>();
const Velocity = world.component<Vector3>();
const entity = world.entity();
world.set(entity, Position, new Vector3(0, 0, 0));
world.set(entity, Velocity, new Vector3(1, 0, 0));
// Update system (example)
for (const [id, position, velocity] of world.query(Position, Velocity)) {
world.set(id, Position, position.add(velocity));
}
```
## Performance
2024-11-23 03:42:54 +00:00
2025-02-19 18:26:50 +00:00
Benchmark results demonstrating Jecs' performance are available in the documentation. These include query and insertion performance tests.
2024-11-23 03:42:54 +00:00
2025-02-19 16:10:38 +00:00
## Installation
2024-11-23 03:42:54 +00:00
2025-02-19 18:25:43 +00:00
### Using Wally (Luau)
Add Jecs to your `wally.toml`:
2025-02-19 18:31:27 +00:00
Using Wally (recommended):
2025-02-19 16:10:38 +00:00
```toml
[dependencies]
jecs = "ukendio/jecs@0.2.3"
```
2024-11-23 03:42:54 +00:00
2025-02-19 18:25:43 +00:00
Then run:
```bash
wally install
```
### Using npm (Roblox-ts)
2025-02-19 16:10:38 +00:00
```bash
2025-02-19 18:25:43 +00:00
npm install @rbxts/jecs
2024-11-23 03:42:54 +00:00
```
2025-02-19 18:25:43 +00:00
### Standalone Installation
1. Download `jecs.rbxm` from the [releases page](https://github.com/ukendio/jecs/releases).
2. Import it into your Roblox project.
2024-11-23 03:42:54 +00:00
2025-02-19 16:10:38 +00:00
## Contributing
We welcome contributions! Please see our [contribution guidelines](docs/contributing/guidelines.md) for details.
## Community & Support
2025-02-19 18:25:43 +00:00
* [Discord Community](https://discord.gg/h2NV8PqhAD)
* [GitHub Issues](https://github.com/ukendio/jecs/issues)
* [API Documentation](https://ukendio.github.io/jecs/) (Note: This link may need updating)
2025-02-19 16:10:38 +00:00
## License
Jecs is [MIT licensed](LICENSE).
2025-02-19 18:25:43 +00:00
2025-02-19 18:26:50 +00:00
```
2025-02-19 18:31:27 +00:00
Jecs = "ukendio/jecs@VERSION"
```