Skip to content

Instantly share code, notes, and snippets.

@Telzhaak
Telzhaak / Bevy 0.4 DefaultPlugins Scheduler
Last active February 4, 2021 09:06
All Stages and Systems used by Bevy's DefaultPlugins, Version 0.4
Stages and systems in scheduler:
0 Scheduler
1 ├ STAGE: 'startup'
2 │ └ Scheduler
3 │ ├ STAGE: 'pre_startup'
4 │ │ └ SystemStage
5 │ ├ STAGE: 'startup'
6 │ │ └ SystemStage
7 │ │ └ &bevy_input::gamepad::gamepad_event_system
8 │ └ STAGE: 'post_startup'
@Telzhaak
Telzhaak / main.rs
Created August 25, 2020 15:04
Color changing Rects
use bevy::prelude::*;
use bevy::diagnostic::{FrameTimeDiagnosticsPlugin, PrintDiagnosticsPlugin};
use rand::Rng;
struct Fluxel2D {
width: u32,
height: u32,
}
@Telzhaak
Telzhaak / usecase.rs
Created October 31, 2018 13:52
My use-case for resource loading in a system.
pub struct DeSavegameSystem;
impl<'a> System<'a> for DeSavegameSystem {
type SystemData = (
Option<Write<'a, GameSessionData>>,
Option<Read<'a, SavegamePaths>>,
);
fn run(&mut self,(
session_data,
@Telzhaak
Telzhaak / MainMenu.rs
Last active October 6, 2018 12:31
HiddenComponent test
fn disable_current_screen(&mut self, world: &mut World){
if let Some(entity) = self.current_screen{
let mut hidden_component_storage = world.write_storage::<Hidden>();
hidden_component_storage.remove(entity);
};
}
fn enable_current_screen(&mut self, world: &mut World){
self.b_buttons_found = false;
@Telzhaak
Telzhaak / english.yaml
Created September 17, 2018 17:47
yaml config of app and args
args:
- name:
index: 1
required: true
help: Sets the name of the component.
- tag_component:
short: t
long: tag
help: Create a tag-component with no fields and NullStorage.
- storage_type:
@Telzhaak
Telzhaak / follow_camera_system_2d.rs
Last active September 11, 2018 09:55
A camera following the player in a 2D game.
/// 2D player following camera system. Needs to be dispatched after the Transform-Bundle, to avoid jittering,
/// but before the Render-Bundle.
pub struct FollowCameraSystem;
impl<'s> System<'s> for FollowCameraSystem{
type SystemData = (
WriteStorage<'s, Transform>,
ReadStorage<'s, CPlayer>,
ReadStorage<'s, Camera>,
);
#[derive(PartialEq, Eq)]
enum ContainerType{
HorizontalBox, //places contained_childrens in a horizontal manner
VerticalBox,//like above, but vertically
ScaleBox,//scales it's contents, e.g. to allow for a zoom-in on an item in the inventory
UniformGrid,//places all contained_children in a grid with uniformely sized and distributed boxes, ignoring desired_sizes, etc
//etc ...
}
//Containers hold Data for a LayoutSystem, that ONLY works on the layout.