A minimalist and safe ECS library for rust!

Overview

Planck ECS

Planck ECS

The full ECS (Entity-Component-System) library.

Support an Open Source Developer! ♥️
Become a patron

Composed of two smaller libraries:

Read the documentation.

Why would you use this ECS library?

  • Compatible with all platforms, including WASM!
  • Fast enough on every operation, not just iteration.
  • Public domain licensing: CC0
  • Minimal amount of dependencies.
  • Small code size.
  • Stable, tested, benchmarked, 100% completed.
  • Ability to handle system errors instead of crashing.
  • Convert both functions and closures into systems!
  • Safe: only 3 unsafe in total. (compared to hundreds in mainstream ECS libraries!)

Usage

Add the following to you Cargo.toml file:

planck_ecs = "*"

Use it like so:

use planck_ecs::*;
fn main() {
    #[derive(Default)]
    pub struct A;

    let mut world = World::default();

    let sys = (|comps: &mut Components<A>, entities: &mut Entities| {
        let entity = entities.create();
        comps.insert(entity, A);
        Ok(())
    }).system();

    let mut dispatch = DispatcherBuilder::new().add_system(sys).build(&mut world);
    dispatch.run_seq(&world).unwrap();
    dispatch.run_seq(&world).unwrap();
    dispatch.run_seq(&world).unwrap();

    assert!(world.get::<Components<A>>().is_ok());
}

For more examples, see the two following repositories' example folders and documentation:

Maintainer Information

  • Maintainer: Jojolepro
  • Contact: jojolepro [at] jojolepro [dot] com
  • Website: jojolepro.com
  • Patreon: patreon

Licence

CC0, public domain.

TLDR: You can do whatever you want with it. Have fun!

Following discussions on reddit, I'll add the following: We will not be suing anybody for patent infringement. Also, while not enforced by the CC0 license, we ask you to please not pretend you wrote the original software. That just wouldn't be a nice thing to do and we trust that you are a nice person.

You might also like...
Rust Attribute-Based Encryption library rabe's C FFI binding , support CP-ABE and KP-ABE encrypt and decrypt, submodule of Rabe.Core c# library.

Rabe-ffi Rust Attribute-Based Encryption library rabe's C FFI binding , support CP-ABE and KP-ABE encrypt and decrypt, submodule of Rabe.Core c# libra

Rust library for build scripts to compile C/C++ code into a Rust library

A library to compile C/C++/assembly into a Rust library/application.

Robust and Fast tokenizations alignment library for Rust and Python
Robust and Fast tokenizations alignment library for Rust and Python

Robust and Fast tokenizations alignment library for Rust and Python Demo: demo Rust document: docs.rs Blog post: How to calculate the alignment betwee

A rust library containing typings and utility functions dealing with the Public specification of the Internet Computer.

IC Types Contributing Please follow the guidelines in the CONTRIBUTING.md document. Goal This library contains typings and utility functions dealing w

Fastest lz4 compression library in Node.js, powered by napi-rs and lz4-flex.

Lz4 Fastest lz4 compression library in Node.js, powered by napi-rs and lz4-flex. Install this package yarn add lz4-napi API export function compress:

Rust library to interface with Lua

hlua This library is a high-level binding for Lua 5.2. You don't have access to the Lua stack, all you can do is read/write variables (including callb

A library for functional programming in Rust
A library for functional programming in Rust

It contains purely functional data structures to supplement the functional programming needs alongside with the Rust Standard Library.

Lineiform is a meta-JIT library for Rust interpreters

Lineiform Lineiform is a meta-JIT library for Rust interpreters. Given an interpreter that uses closure generation, it allows an author to add minimal

libnotcurses-sys is a low-level Rust wrapper for the notcurses C library

libnotcurses-sys is a low-level Rust wrapper for the notcurses C library This library is built with several layers of zero-overhead abstractions over

Comments
  • Is it possible to serialize with serde?

    Is it possible to serialize with serde?

    Hello,

    I want to use your ECS with WASM. But I struggle to return the state of the world back to Javascript after I ran a dispatcher.

    let's take this little example. dispatch is exposed via wasm_bindgen to Javascript. Javascript calls the function, the dispatch of the world is triggered and I want to return the result.

      pub fn dispatch(&mut self) -> JsValue {
        let run = (|animals: &mut Components<Animal>, points: &mut Components<na::Point2<f32>>| {
          for (_, point) in join!(&animals && &points) {
           //...
          }
          Ok(())
        }).system();
        let mut dispatch = DispatcherBuilder::new().add_system(run).build(&mut self.world);
        dispatch.run_seq(&self.world).unwrap();
    
       // now I want to return all entities which have animal and points as json to the browser
      }
    

    Is it possible to use serde with your ECS out of the box? If so can you provide me an example.

    Thanks in advance!

    opened by Bastczuak 5
Owner
Joël Lupien
I Press Keys on my Keyboard.
Joël Lupien
Rust bindings for writing safe and fast native Node.js modules.

Rust bindings for writing safe and fast native Node.js modules. Getting started Once you have the platform dependencies installed, getting started is

The Neon Project 7k Jan 4, 2023
Safe Rust bridge for creating Erlang NIF functions

Rustler Documentation | Getting Started | Example Rustler is a library for writing Erlang NIFs in safe Rust code. That means there should be no ways t

Rusterlium 3.5k Jan 7, 2023
Safe Rust bindings to Lua 5.1

rust-lua Copyright 2014 Lily Ballard Description This is a set of Rust bindings to Lua 5.1. The goal is to provide a (relatively) safe interface to Lu

Lily Ballard 124 Jan 5, 2023
mruby safe bindings for Rust

mrusty. mruby safe bindings for Rust mrusty lets you: run Ruby 1.9 files with a very restricted API (without having to install Ruby) reflect Rust stru

Anima 200 Oct 12, 2022
WebAssembly implementation from scratch in Safe Rust with zero dependencies

wain wain is a WebAssembly INterpreter written in Rust from scratch with zero dependencies. An implementation of WebAssembly. Features: No unsafe code

Linda_pp 328 Jan 2, 2023
Safe Rust <---> GraalVM Polyglot bindings using procedural macros

The class macro is the primary way to generate bindings to Java types; it will generate a struct (with generics if specified) that implements Pass and Receive and has all the methods you give stubs for. The methods generated can be used like normal rust methods, however mutability is not enforced. The fully-qualified type name should precede a block containing method and constructor stubs. Java primitives like char, int, and byte are aliased to corresponding Rust types.

Alec Petridis 33 Dec 28, 2022
A safe Rust FFI binding for the NVIDIA® Tools Extension SDK (NVTX).

NVIDIA® Tools Extension SDK (NVTX) is a C-based Application Programming Interface (API) for annotating events, code ranges, and resources in your applications. Official documentation for NVIDIA®'s NVTX can be found here.

Spencer Imbleau 78 Jan 2, 2023
High-level memory-safe binding generator for Flutter/Dart <-> Rust

flutter_rust_bridge: High-level memory-safe binding generator for Flutter/Dart <-> Rust Want to combine the best between Flutter, a cross-platform hot

fzyzcjy 2.1k Dec 31, 2022
A collection of unsound rust functions using entirly *safe* code

A collection of unsound rust functions using entirly *safe* code

null 2 Sep 6, 2022
A memory safe Lua interpreter

Hematita Da Lua Hematita Da Lua is an interpreter for the scripting language Lua, written entirely in 100% safe Rust. Hematita is the portugese word f

Daniel 149 Dec 29, 2022