🏷️ Markers for Bevy ECS Entities

Overview

Bevy ECS Markers

Crates.io MIT/Apache 2.0

Adds the support for marking entites and fetching them in queries

Example

View the whole example here

#[derive(EntityMarker)]
enum Players {
    Red,
    Blue,
}

#[derive(EntityMarker)]
struct CurrentPlayer;

#[derive(Component)]
struct Player(u32);

fn setup(
    mut commands: Commands,
    mut markers: MarkerMut<Players>,
    mut current: MarkerMut<CurrentPlayer>,
) {
    let red = commands.spawn(Player(12)).id();
    markers[Players::Red] = red;

    let blue = commands.spawn(Player(7)).id();
    markers[Players::Blue] = blue;

    *current = blue;
}

fn get_red_player(mut query: Query<&mut Player>, markers: Marker<Players>) {
    if let Ok(mut player) = query.get_mut(markers[Players::Red]) {
        player.0 = 15;
    }
}

fn get_current_player(mut query: Query<&mut Player>, current: Marker<CurrentPlayer>) {
    if let Ok(mut player) = query.get_mut(*current) {
        player.0 = 2;
    }
}

License

at your option.

You might also like...
A direct ecs to low-level server implementation for Godot 4.1

godot_ecs What if Godot 4.1 and Bevy got married? Well, you'd get one interesting duo of data driven goodness. In Development This crate is not produc

Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy
bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy

Bevy Voxel Cone Tracing bevy-hikari is an implementation of voxel cone tracing global illumination with anisotropic mip-mapping in Bevy. Bevy Version

A simple extension for `bevy-editor-pls` to support tilemap editing right inside the bevy app.

What is this This is a simple tilemap editor plugin, that hooks right into bevy_editor_pls to work with bevy_ecs_tilemap. It works completely within i

Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.
Bevy Simple Portals is a Bevy game engine plugin aimed to create portals.

Portals for Bevy Bevy Simple Portals is a Bevy game engine plugin aimed to create portals. Those portals are (for now) purely visual and can be used t

Minecraft using Bevy and Bevy-Meshem

minecraft_bevy Minecraft_bevy was built to showcase bevy_meshem. After a week of developing it has: Chunk loading / unloading each chunk's mesh is bei

A Bevy plugin for loading the LDtk 2D tile map format.
A Bevy plugin for loading the LDtk 2D tile map format.

bevy_ldtk ( Tileset from "Cavernas" by Adam Saltsman ) A Bevy plugin for loading LDtk tile maps. Usage use bevy::prelude::*; use bevy_ldtk::*; fn mai

Basic first-person fly camera for the Bevy game engine

bevy_flycam A basic first-person fly camera for Bevy 0.4 Controls WASD to move horizontally SPACE to ascend LSHIFT to descend ESC to grab/release curs

An ergonomic physics API for bevy games.

Heron An ergonomic physics API for 2d and 3d bevy games. (powered by rapier) How it looks like fn main() { App::build() .add_plugins(DefaultPlug

Comments
  • MarkerData Rewrite

    MarkerData Rewrite

    • Split up MarkerData in smaller and custom traits
    • Add init_markerdata helpers
    • Move unit_index to ValueMarkerData exclusively
    • Restructure examples
    • Add new examples
    • Remove inline functions from Marker and MarkerMut, just Deref to the provided MarkerData
    • Add possibility to make custom MarkerData traits
    opened by DasLixou 0
Releases(1.0.4)
  • 1.0.4(Dec 26, 2022)

  • 1.0.3(Dec 26, 2022)

    • Make generated MarkerData having same visibility as EntityMarker struct.

    Full Changelog: https://github.com/ChoppedStudio/bevy_ecs_markers/compare/1.0.2...1.0.3

    Source code(tar.gz)
    Source code(zip)
  • 1.0.2(Dec 26, 2022)

    • Rename #[marker] to #[entity_marker] due to nameing problems

    Full Changelog: https://github.com/ChoppedStudio/bevy_ecs_markers/compare/1.0.1...1.0.2

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Dec 26, 2022)

    • Add #[marker] attribute to #[derive(EntityMarker)]

    Full Changelog: https://github.com/ChoppedStudio/bevy_ecs_markers/compare/1.0.0...1.0.1

    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Dec 24, 2022)

    • Split up MarkerData in smaller and custom traits
    • Add init_markerdata helpers
    • Move unit_index to ValueMarkerData exclusively
    • Restructure examples
    • Add new examples
    • Remove inline functions from Marker and MarkerMut, just Deref to the provided MarkerData
    • Add possibility to make custom MarkerData traits
    Source code(tar.gz)
    Source code(zip)
  • 0.1.4(Dec 23, 2022)

    What's Changed

    • Add more inlining by @DasLixou in https://github.com/ChoppedStudio/bevy_ecs_markers/pull/2

    Full Changelog: https://github.com/ChoppedStudio/bevy_ecs_markers/compare/0.1.3...0.1.4

    Source code(tar.gz)
    Source code(zip)
  • 0.1.3(Dec 19, 2022)

    What's Changed

    • Rewrite Storing by @DasLixou in https://github.com/ChoppedStudio/bevy_ecs_markers/pull/1

    New Contributors

    • @DasLixou made their first contribution in https://github.com/ChoppedStudio/bevy_ecs_markers/pull/1

    Full Changelog: https://github.com/ChoppedStudio/bevy_ecs_markers/compare/0.1.2...0.1.3

    Source code(tar.gz)
    Source code(zip)
  • 0.1.2(Dec 18, 2022)

  • 0.1.1(Dec 18, 2022)

  • 0.1.0(Dec 18, 2022)

Owner
Chopped Studio
Indie Game Studio from @DasLixou
Chopped Studio
An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities

bevy_sparse_grid_2d An opinionated 2D sparse grid made for use with Bevy. For storing and querying entities. Personally, I'm using it for simple stupi

Johan Klokkhammer Helsing 5 Feb 26, 2023
Attach Bevy's Handles/Entities statically to Types.

Easily attach bevy's Handles/Entities statically to types on startup and get them in any system, without using Resources. It's just a little less clut

Dekirisu 6 Sep 4, 2023
A tilemap rendering crate for bevy which is more ECS friendly.

bevy_ecs_tilemap A tilemap rendering plugin for bevy which is more ECS friendly by having an entity per tile. Features A tile per entity Fast renderin

John 414 Dec 30, 2022
Minimalistic implementation of entity kinds for Bevy ECS.

Bevy ?? Kindly This crate is a minimalistic implementation of Kinded Entities for Bevy game engine. In summary, it allows the user to define, construc

null 10 Jan 26, 2023
Bring Bevy's ECS to Godot4

bevy_godot4 Bring the design power of Bevy's ECS to the mature engine capabilities of Godot 4. WARNING: This crate is very early in development, and i

JR 4 May 8, 2023
A simple type safety solution for Bevy ECS.

?? Moonshine Kind A simple type safety solution for Bevy ECS. Overview An Entity is a generic way to reference entities within Bevy ECS: #[derive(Comp

null 8 Nov 3, 2023
Specs - Parallel ECS

Specs Specs Parallel ECS Specs is an Entity-Component System written in Rust. Unlike most other ECS libraries out there, it provides easy parallelism

Amethyst Engine 2.2k Jan 8, 2023
High performance Rust ECS library

Legion aims to be a feature rich high performance Entity component system (ECS) library for Rust game projects with minimal boilerplate. Getting Start

Amethyst Engine 1.4k Jan 5, 2023
Creative Coding Framework based on Entity Component System (ECS) written in Rust

creativity creativity is Creative Coding Framework based on Entity Component System (ECS) written in Rust. Key Features TBA Quick Start TBA How To Con

Chris Ohk 9 Nov 6, 2021
🤹‍ 2D sprite rendering extension for the specs ECS system

specs-blit 2D sprite rendering extension for the Specs ECS system. All sprites are loaded onto a big array on the heap. Example // Setup the specs wor

Thomas Versteeg 8 Aug 14, 2022