specs_declaration 0.3.0

A simple macro to effectively create SPECS systems.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 0 items with examples
  • Size
  • Source code size: 45.38 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 132.23 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • AnneKitsune/specs_declaration
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • AnneKitsune

Support an Open Source Developer! :hearts:

Become a patron

SPECS Declaration

A simple macro to effectively create SPECS systems.

Adding To Your Project

Add the following to your Cargo.toml file:

specs_declaration = "*"

Usage

  • system!
  • Give the name of the system and, optionally, the generic parameters
  • Give the content of your usual SystemData, in the form of a closure
  • Write your operations as if you were in the usual run(&self, params..) function of the System
use specs::*;

system!(SystemName, |velocity: WriteStorage<'a, Velocity>| {
    for vel in (&velocity,).join() {
        println!("velocity: {}, {}, {}", vel.x, vel.y, vel.z);
    }
});

With generics:

use specs::*;

system!(SystemName<T: Debug + Send + Sync + 'static>, |my_resource: Read<'a, T>, velocity: WriteStorage<'a, Velocity>| {
    println!("My Generic Resource: {:?}", my_resource);

    for vel in (&velocity,).join() {
        println!("velocity: {}, {}, {}", vel.x, vel.y, vel.z);
    }
});

Consider donating on my patreon if you find this useful!