7 releases
new 0.3.1 | Apr 28, 2025 |
---|---|
0.3.0 |
|
0.2.2 | Jan 12, 2025 |
0.2.1 | Nov 30, 2024 |
0.1.1 | May 5, 2024 |
#2863 in Game dev
Used in moonshine-view
35KB
🍸 Moonshine Core
Unconventional cocktail of libraries to make ECS-driven development easier and safer in Bevy.
See individual crates for detailed documentation and examples.
🍎 Moonshine Kind
Type safety solution for Bevy entities:
use bevy::prelude::*;
use moonshine_core::prelude::*;
#[derive(Component)]
struct Fruit;
#[derive(Component)]
struct FruitBasket {
fruits: Vec<Instance<Fruit>>
}
🌴 Moonshine Object
Ergonomic wrapper for managing complex enttiy hierarchies:
use bevy::prelude::*;
use moonshine_core::prelude::*;
#[derive(Component)]
struct Bird;
#[derive(Component)]
struct Flying;
fn setup_bird(birds: Objects<Bird, Added<Flying>>, mut commands: Commands) {
for bird in birds.iter() {
if let Some(wings) = bird.find_by_path("./Wings") {
for wing in wings.children() {
// TODO: Flap! Flap!
}
}
}
}
💾 Moonshine Save
Save/Load framework for managing persistent game state:
use bevy::prelude::*;
use moonshine_core::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins((SavePlugin, LoadPlugin))
.add_systems(PreUpdate, save_default().into(static_file("world.ron")).run_if(should_save))
.add_systems(PreUpdate, load(static_file("world.ron")).run_if(should_load))
.run();
}
fn should_save(key: Res<ButtonInput<KeyCode>>) -> bool {
key.just_pressed(KeyCode::KeyS)
}
fn should_load(key: Res<ButtonInput<KeyCode>>) -> bool {
key.just_pressed(KeyCode::KeyL)
}
🏷️ Moonshine Tag
Cheap, fast, mostly unique identifiers designed for Bevy:
use bevy::prelude::*;
use moonshine_tag::{prelude::*, filter, Filter};
tags! { APPLE, ORANGE, JUICY, CRUNCHY, POISONED }
let mut world = World::new();
// Define some fruits!
let fruits = [
Tags::from([APPLE, CRUNCHY]),
Tags::from([ORANGE, JUICY]),
Tags::from([APPLE, CRUNCHY, POISONED])
];
// Only crunchy, edible apples, please! :)
let filter: Filter = filter!([APPLE, CRUNCHY]) & filter!(![POISONED]);
for fruit in &fruits {
if filter.allows(fruit) {
world.spawn(fruit.clone());
}
}
# assert!(filter.allows(&fruits[0]));
🛠️ Moonshine Utilities
Collection of generic utilities for improved safety, diagnostics, and ergonomics.
Support
Please post an issue for any bugs, questions, or suggestions.
You may also contact me on the official Bevy Discord server as @Zeenobit.
Dependencies
~25–38MB
~667K SLoC