ecso

Entity Component System for Haxe
https://github.com/EcsoKit/ecso

To install, run:

haxelib install ecso 1.0.0-alpha.6 

See using Haxelib in Haxelib documentation for more information.

README.md

ecso is an open-source and experimental Entity Component System plugin for Haxe, which enables ECS oriented compiler features and focuses on simplicity.

This alpha version requires a 64-bit version of Haxe 4.2.2 or 4.2.3. It is strongly advised to use ecso with the following targets: HashLink, JavaScript, C++, C#, or Eval (interp). Other targets will be tested progressively.

If you have any suggestions or run into any problems, please open an issue on GitHub .

Features

  • Framework agnostic: focus exclusively on core ECS aspects.
  • Haxe-Powered: integrates with built-in semantics and features (such as macros, type inference, closures, null safety, etc).
  • Advanced code-analyzes: structure for high-level ECS-oriented compiler optimizations.
  • Super simple API: lightweight with clarity, readability and discoverability in mind.
  • Cross-platform: enables target-specific optimizations, and run on every Haxe target.
  • Performance: while the current focus is on design and not on speed, the nature of ecso promises a good level of customization to best fit specific needs, optimizing out branching and unboxing from systems, etc.
  • Fast Compilation: plugins are incredibly fast, with zero-overhead for non-ecso projects.

Code example

import ecso.Entity;

typedef Position = {
    var x:Int;
    var y:Int;
}

typedef Velocity = {
    var vx:Int;
    var vy:Int;
}

function move (entity:Position & Velocity) {
    entity.x += entity.vx;
    entity.y += entity.vy;
}

function teleport (entity:Position, x:Int, y:Int) {
    entity.x = x;
    entity.y = y;
}

function main () {
    final entities = new EntityGroup();

    entities.createEntity({
        x: 10,
        y: 10,
        vx: 2,
        vy: 1
    });

    entities.foreachEntity( move ); // runs the system `move`.
    entities.foreachEntity( teleport.bind(_, 0, 0) ); // runs `teleport` with arguments.
    entities.foreachEntity( function (entity:{ y:Int, vy:Int }) { // runs an anonymous system.
        if (entity.y < 100)
            entity.vy -= 1;
    });
}

For more details about ecso please visit the wiki page.

How to install

Run haxelib install ecso and add --library ecso to your compilation flags.

To use ecso from source or use nightly builds, you can refer to the installation page.

Contribution

Any kind of contribution is welcome and appreciated. You can read more here. Thank you!

Contributors
dpomier
Version
1.0.0-alpha.6
Published
3 years ago
License
MIT

All libraries are free

Every month, more than a thousand developers use Haxelib to find, share, and reuse code — and assemble it in powerful new ways. Enjoy Haxe; It is great!

Explore Haxe

Haxe Manual

Haxe Code Cookbook

Haxe API documentation

You can try Haxe in the browser! try.haxe.org

Join us on GitHub!

Haxe is being developed on GitHub. Feel free to contribute or report issues to our projects.

Haxe on GitHub