├── .gitignore ├── Binary ├── .cargo │ └── config.toml ├── .gitignore ├── .vscode │ ├── launch.json │ └── tasks.json ├── Cargo.toml.liquid ├── README.md ├── assets │ ├── cube.glb │ └── icon.png ├── cargo-generate.toml ├── final-msg.rhai ├── pre-check.rhai ├── src │ ├── debug.rs │ ├── lib.rs │ └── main.rs └── tests │ ├── common │ └── mod.rs │ └── plugin_integration_tests.rs ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE-APACHE ├── LICENSE-MIT ├── Library ├── .gitignore ├── .vscode │ ├── launch.json │ └── tasks.json ├── Cargo.toml.liquid ├── README.md ├── cargo-generate.toml ├── final-msg.rhai ├── src │ └── lib.rs └── tests │ ├── common │ └── mod.rs │ └── plugin_integration_tests.rs ├── Minimal ├── .cargo │ └── config.toml ├── .gitignore ├── .vscode │ ├── launch.json │ └── tasks.json ├── Cargo.toml.liquid ├── cargo-generate.toml ├── final-msg.rhai ├── pre-check.rhai └── src │ └── main.rs ├── README.md ├── Workflow ├── .github │ └── workflows │ │ ├── ci.yaml │ │ └── release.yaml ├── cargo-generate.toml ├── final-msg.rhai ├── pre-check.rhai └── wasm │ └── index.html ├── assets └── template-expansion.gif └── cargo-generate.toml /.gitignore: -------------------------------------------------------------------------------- 1 | # Visual Studio Code settings file 2 | .vscode/settings.json 3 | -------------------------------------------------------------------------------- /Binary/.cargo/config.toml: -------------------------------------------------------------------------------- 1 | [target.wasm32-unknown-unknown] 2 | runner = "wasm-server-runner" 3 | -------------------------------------------------------------------------------- /Binary/.gitignore: -------------------------------------------------------------------------------- 1 | # will have compiled files and executables 2 | /debug/ 3 | /target/ 4 | 5 | # These are backup files generated by rustfmt 6 | **/*.rs.bk 7 | 8 | # MSVC Windows builds of rustc generate these, which store debugging information 9 | *.pdb 10 | 11 | # Visual Studio Code settings file 12 | .vscode/settings.json 13 | -------------------------------------------------------------------------------- /Binary/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "lldb", 9 | "request": "launch", 10 | "name": "Debug executable '{{project-name}}'", 11 | "cargo": { 12 | "args": ["build", "--bin={{project-name}}"] 13 | }, 14 | "args": [], 15 | "env": { 16 | "CARGO_MANIFEST_DIR": "${workspaceFolder}" 17 | }, 18 | "cwd": "${workspaceFolder}" 19 | }, 20 | { 21 | "type": "lldb", 22 | "request": "launch", 23 | "name": "Debug unit tests in executable '{{project-name}}'", 24 | "cargo": { 25 | "args": ["test", "--no-run", "--bin={{project-name}}"] 26 | }, 27 | "args": [], 28 | "env": { 29 | "CARGO_MANIFEST_DIR": "${workspaceFolder}" 30 | }, 31 | "cwd": "${workspaceFolder}" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /Binary/.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | // See https://go.microsoft.com/fwlink/?LinkId=733558 2 | // for the documentation about the tasks.json format 3 | { 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "label": "Test (fast compile)", 8 | "detail": "Runs all tests", 9 | "type": "shell", 10 | "group": "test", 11 | "command": "cargo t --workspace --features bevy/dynamic", 12 | "options": { 13 | "env": { 14 | "RUST_LOG": "warn,{{crate_name}}=trace" 15 | } 16 | }, 17 | "problemMatcher": ["$rustc"], 18 | "presentation": { 19 | "echo": true, 20 | "reveal": "always", 21 | "panel": "shared", 22 | "showReuseMessage": true, 23 | "clear": true, 24 | "focus": true 25 | } 26 | }, 27 | { 28 | "label": "Run release (fast compile)", 29 | "detail": "Runs binary in release mode", 30 | "type": "shell", 31 | "group": "build", 32 | "command": "cargo run --features bevy/dynamic --release", 33 | "problemMatcher": ["$rustc"], 34 | "presentation": { 35 | "echo": true, 36 | "reveal": "always", 37 | "panel": "shared", 38 | "showReuseMessage": true, 39 | "clear": true, 40 | "focus": true 41 | } 42 | }, 43 | { 44 | "label": "Run debug (fast compile)", 45 | "detail": "Runs binary in debug mode", 46 | "type": "shell", 47 | "group": "build", 48 | "command": "cargo run --features bevy/dynamic", 49 | "problemMatcher": ["$rustc"], 50 | "presentation": { 51 | "echo": true, 52 | "reveal": "always", 53 | "panel": "shared", 54 | "showReuseMessage": true, 55 | "clear": true, 56 | "focus": true 57 | } 58 | }, 59 | { 60 | "label": "Run w. editor-pls", 61 | "detail": "Runs binary with editor-pls enabled", 62 | "type": "shell", 63 | "command": "cargo run --features editor", 64 | "problemMatcher": ["$rustc"], 65 | "group": "build", 66 | "presentation": { 67 | "echo": true, 68 | "reveal": "always", 69 | "panel": "shared", 70 | "showReuseMessage": true, 71 | "clear": true, 72 | "focus": true 73 | } 74 | }, 75 | { 76 | "label": "Run w. inspector-egui", 77 | "detail": "Runs binary with inspector-egui enabled", 78 | "type": "shell", 79 | "command": "cargo run --features inspector", 80 | "problemMatcher": ["$rustc"], 81 | "group": "build", 82 | "presentation": { 83 | "echo": true, 84 | "reveal": "always", 85 | "panel": "shared", 86 | "showReuseMessage": true, 87 | "clear": true, 88 | "focus": true 89 | } 90 | }, 91 | { 92 | "label": "WASM development", 93 | "detail": "Use cargo watch to run wasm-server-runner", 94 | "type": "shell", 95 | "group": "build", 96 | "command": "cargo watch -- cargo run --target wasm32-unknown-unknown", 97 | "problemMatcher": ["$rustc"], 98 | "presentation": { 99 | "echo": true, 100 | "reveal": "always", 101 | "panel": "shared", 102 | "showReuseMessage": true, 103 | "clear": true, 104 | "focus": true 105 | } 106 | }, 107 | { 108 | "label": "WASM development w. inspector-egui", 109 | "detail": "Use cargo watch to run wasm-server-runner, inspector-egui enabled", 110 | "type": "shell", 111 | "group": "build", 112 | "command": "cargo watch -- cargo run --target wasm32-unknown-unknown --features inspector", 113 | "problemMatcher": ["$rustc"], 114 | "presentation": { 115 | "echo": true, 116 | "reveal": "always", 117 | "panel": "shared", 118 | "showReuseMessage": true, 119 | "clear": true, 120 | "focus": true 121 | } 122 | }, 123 | { 124 | "label": "Build {{crate_name}} lib doc", 125 | "detail": "Builds the documentation", 126 | "type": "shell", 127 | "command": "cargo doc --lib --all-features --no-deps", 128 | "problemMatcher": ["$rustc"], 129 | "group": "build", 130 | "presentation": { 131 | "echo": true, 132 | "reveal": "always", 133 | "panel": "shared", 134 | "showReuseMessage": true, 135 | "focus": true, 136 | "clear": true 137 | } 138 | }, 139 | { 140 | "label": "Open {{crate_name}} lib doc", 141 | "detail": "Open the documentation", 142 | "type": "shell", 143 | "command": "cargo doc --lib --all-features --no-deps --open", 144 | "problemMatcher": ["$rustc"], 145 | "dependsOn": "Build doc" 146 | }, 147 | { 148 | "label": "Update", 149 | "detail": "Update dependencies (Cargo.lock)", 150 | "type": "shell", 151 | "command": "cargo update", 152 | "problemMatcher": [], 153 | "presentation": { 154 | "echo": true, 155 | "reveal": "always", 156 | "panel": "shared", 157 | "showReuseMessage": true, 158 | "clear": true, 159 | "focus": true 160 | } 161 | }, 162 | { 163 | "label": "Clippy", 164 | "detail": "Look for Clippy errors", 165 | "type": "shell", 166 | "command": "cargo clippy --all-features --all-targets -- -D warnings", 167 | "problemMatcher": [], 168 | "presentation": { 169 | "echo": true, 170 | "reveal": "always", 171 | "panel": "shared", 172 | "showReuseMessage": true, 173 | "clear": true, 174 | "focus": true 175 | } 176 | }, 177 | { 178 | "label": "Format", 179 | "detail": "Format all source", 180 | "type": "shell", 181 | "command": "cargo fmt --all --quiet", 182 | "problemMatcher": [], 183 | "presentation": { 184 | "echo": false, 185 | "reveal": "never", 186 | "panel": "shared", 187 | "showReuseMessage": false 188 | } 189 | }, 190 | { 191 | "label": "Clean", 192 | "detail": "Clean build artifacts", 193 | "type": "shell", 194 | "command": "cargo clean", 195 | "problemMatcher": [], 196 | "presentation": { 197 | "echo": false, 198 | "reveal": "never", 199 | "panel": "shared", 200 | "showReuseMessage": false 201 | } 202 | } 203 | ] 204 | } 205 | -------------------------------------------------------------------------------- /Binary/Cargo.toml.liquid: -------------------------------------------------------------------------------- 1 | {% if within_cargo_project==false %}[workspace] 2 | resolver = "2" 3 | members = [] 4 | 5 | {% endif %}[package] 6 | name = "{{project-name}}" 7 | version = "0.1.0" 8 | authors = ["{{authors}}"] 9 | readme = "README.md" 10 | description = """ 11 | Short description goes here. 12 | """ 13 | #license = "MIT OR Apache-2.0" 14 | {% if within_cargo_project==false %}#repository = "https://github.com/{{gh_username}}/{{project-name}}" 15 | {% endif %}edition = "2021"{% if within_cargo_project %} 16 | resolver = "2"{% endif %} 17 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 18 | 19 | [features] 20 | default = [] 21 | editor = [ "bevy_editor_pls" ] 22 | inspector = [ "bevy-inspector-egui" ] 23 | 24 | [dependencies] 25 | # Other crates of possible interest: 26 | # https://bevyengine.org/assets/#assets 27 | # https://gist.github.com/taurr/962ceb49472993e3092e97b07339c164 28 | bevy = { version = "0.9", features = [] } 29 | bevy_editor_pls = { git = "https://github.com/jakobhellermann/bevy_editor_pls", optional = true } 30 | bevy-inspector-egui = { version="0.14", optional=true } 31 | 32 | [target.'cfg(target_arch="wasm32")'.dependencies] 33 | bevy-web-resizer = "4.0" 34 | 35 | {%- if within_cargo_project==false %}#[patch.crates-io] 36 | #bevy = { git = "https://github.com/bevyengine/bevy", branch = "main" } 37 | {%- endif %} 38 | 39 | [dev-dependencies] 40 | anyhow = "1.0" 41 | 42 | {% if within_cargo_project==false -%} 43 | #[patch.crates-io] 44 | # Enable only a small amount of optimization in debug mode 45 | [profile.dev] 46 | opt-level = 1 47 | incremental = true 48 | 49 | # Enable target specific optimizations in debug mode 50 | [target.'cfg(not(target_arch="wasm32"))'.profile.dev.package."*"] 51 | opt-level = 3 52 | 53 | [target.'cfg(target_arch="wasm32")'.profile.dev.package."*"] 54 | opt-level = 's' 55 | 56 | # Enable target specific optimizations in release mode 57 | [profile.release] 58 | lto = "thin" 59 | 60 | [target.'cfg(target_arch="wasm32")'.profile.release] 61 | opt-level = 's' 62 | {% endif %} -------------------------------------------------------------------------------- /Binary/README.md: -------------------------------------------------------------------------------- 1 | # {{project-name}} 2 | 3 | [![CI](https://github.com/{{gh_username}}/{{project-name}}/workflows/CI/badge.svg)](https://github.com/{{gh_username}}/{{project-name}}/actions) 4 | [![Coverage Status](https://coveralls.io/repos/github/{{gh_username}}/{{project-name}}/badge.svg?branch=main)](https://coveralls.io/github/{{gh_username}}/{{project-name}}?branch=main) 5 | 6 | TODO: Write this readme 7 | 8 | --- 9 | *This project uses [Bevy], and was bootstrapped using [bevy-template.rs].* 10 | 11 | [Bevy]:https://bevyengine.org 12 | [bevy-template.rs]:https://github.com/taurr/bevy-template-rs 13 | -------------------------------------------------------------------------------- /Binary/assets/cube.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taurr/bevy-template-rs/102967f1990e80e2472e1ce42adc69c931625c23/Binary/assets/cube.glb -------------------------------------------------------------------------------- /Binary/assets/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/taurr/bevy-template-rs/102967f1990e80e2472e1ce42adc69c931625c23/Binary/assets/icon.png -------------------------------------------------------------------------------- /Binary/cargo-generate.toml: -------------------------------------------------------------------------------- 1 | [template] 2 | cargo_generate_version = ">=0.16.0" 3 | 4 | [hooks] 5 | pre = ["pre-check.rhai"] 6 | post = ["final-msg.rhai"] 7 | 8 | [placeholders] 9 | gh_username = { type = "string", prompt = "Github Username?", regex="\\w+" } 10 | camera = { type = "string", prompt = "Camera type?", choices = [ 11 | "2D", 12 | "3D", 13 | ], default = "2D" } 14 | 15 | [conditional.'within_cargo_project'] 16 | ignore = [ 17 | ".cargo", 18 | ".github", 19 | ".vscode", 20 | ".gitignore", 21 | ] 22 | 23 | [conditional.'within_cargo_project && is_init'] 24 | ignore = ["README.md", "Cargo.toml"] 25 | 26 | [conditional.'within_cargo_project == false'.placeholders] 27 | ide = { type = "string", prompt = "Which IDE to use?", default = "vscode", choices = ["none", "vscode"] } 28 | 29 | [conditional.'within_cargo_project == false && ide != "vscode"'] 30 | ignore = [".vscode"] 31 | -------------------------------------------------------------------------------- /Binary/final-msg.rhai: -------------------------------------------------------------------------------- 1 | if variable::get("camera") != "3D" { 2 | file::delete("assets/cube.glb"); 3 | } 4 | if variable::get("camera") != "2D" { 5 | file::delete("assets/icon.png"); 6 | } 7 | 8 | if file::exists("src/{{crate_name}}.rs") { 9 | file::delete("src/{{crate_name}}.rs"); 10 | } 11 | 12 | if !variable::get("within_cargo_project") { 13 | print(); 14 | print("WASM support is enabled in this project."); 15 | print("To use it, make sure to run: rustup target install wasm32-unknown-unknown"); 16 | print("and: cargo install -f wasm-server-runner"); 17 | print(); 18 | print("You can then launch a small development server using: cargo watch -- cargo run --target wasm32-unknown-unknown"); 19 | if variable::get("ide") == "vscode" { 20 | print("A vscode build task for launching the development server (using cargo-watch) has been added."); 21 | } 22 | } else { 23 | print(); 24 | print("Remember to add this crate to the workspace in the parent Cargo.toml:"); 25 | print("[workspace]"); 26 | print(" members = [\"" + variable::get("project-name")+ "\"]"); 27 | } 28 | print(); 29 | -------------------------------------------------------------------------------- /Binary/pre-check.rhai: -------------------------------------------------------------------------------- 1 | if variable::get("crate_type") != "bin" { 2 | abort("This is a template for an executable, and is not compatible with the --lib option"); 3 | } 4 | -------------------------------------------------------------------------------- /Binary/src/debug.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | pub(crate) struct DebugPlugins; 4 | 5 | impl PluginGroup for DebugPlugins { 6 | #[cfg(not(debug_assertions))] 7 | fn build(self) -> bevy::app::PluginGroupBuilder { 8 | bevy::app::PluginGroupBuilder::start::() 9 | } 10 | 11 | #[cfg(debug_assertions)] 12 | #[cfg(not(any(feature = "editor", feature = "inspector")))] 13 | fn build(self) -> bevy::app::PluginGroupBuilder { 14 | bevy::app::PluginGroupBuilder::start::() 15 | .add(bevy::diagnostic::FrameTimeDiagnosticsPlugin) 16 | //.add(bevy::diagnostic::EntityCountDiagnosticsPlugin) 17 | //.add(bevy::asset::diagnostic::AssetCountDiagnosticsPlugin::::default()) 18 | .add(bevy::diagnostic::LogDiagnosticsPlugin::default()) 19 | } 20 | 21 | #[cfg(debug_assertions)] 22 | #[cfg(all(feature = "editor", not(feature = "inspector")))] 23 | fn build(self) -> bevy::app::PluginGroupBuilder { 24 | bevy::app::PluginGroupBuilder::start::() 25 | .add(bevy::diagnostic::FrameTimeDiagnosticsPlugin) 26 | .add(bevy_editor_pls::EditorPlugin) 27 | } 28 | 29 | #[cfg(debug_assertions)] 30 | #[cfg(all(not(feature = "editor"), feature = "inspector"))] 31 | fn build(self) -> bevy::app::PluginGroupBuilder { 32 | use bevy_inspector_egui::WorldInspectorPlugin; 33 | bevy::app::PluginGroupBuilder::start::() 34 | .add(bevy::diagnostic::FrameTimeDiagnosticsPlugin) 35 | .add(WorldInspectorPlugin::new()) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Binary/src/lib.rs: -------------------------------------------------------------------------------- 1 | use bevy::prelude::*; 2 | 3 | {% if camera=="2D" -%} 4 | pub const VIEWPORT_WIDTH: f32 = 80.0; 5 | pub const VIEWPORT_HEIGHT: f32 = 80.0; 6 | 7 | {% endif -%}pub struct {{crate_name|pascal_case}}Plugin; 8 | 9 | impl Plugin for {{crate_name|pascal_case}}Plugin { 10 | fn build(&self, app: &mut App) { 11 | app.add_startup_system(Self::setup).add_system(Self::rotate); 12 | } 13 | } 14 | 15 | #[derive(Debug, Component, Default)] 16 | pub struct {{crate_name|pascal_case}}Component; 17 | 18 | impl {{crate_name|pascal_case}}Plugin { 19 | fn setup(mut commands: Commands, asset_server: Res) { 20 | {% if camera=="3D" -%} 21 | use std::f32::consts::TAU; 22 | commands 23 | .spawn({{crate_name|pascal_case}}Component) 24 | .insert(Name::new("{{crate_name|pascal_case}}Plugin Root")) 25 | .insert(SpatialBundle::default()) 26 | .with_children(|commands| { 27 | commands 28 | .spawn(SceneBundle { 29 | scene: asset_server.load("cube.glb#Scene0"), 30 | transform: Transform::from_xyz(0.0, 0.0, 0.0).with_rotation( 31 | Quat::from_euler( 32 | EulerRot::XYZ, 33 | 22.5 * TAU / 360.0, 34 | 45.0 * TAU / 360.0, 35 | 0.0, 36 | ), 37 | ), 38 | ..default() 39 | }) 40 | .insert(Name::new("{{crate_name|pascal_case}}Plugin Scene")); 41 | }); 42 | {%- else -%} 43 | commands 44 | .spawn({{crate_name|pascal_case}}Component) 45 | .insert(Name::new("{{crate_name|pascal_case}}Plugin Root")) 46 | .insert(SpatialBundle::default()) 47 | .with_children(|commands| { 48 | commands 49 | .spawn(SpriteBundle { 50 | sprite: Sprite { 51 | custom_size: Some(Vec2::new( 52 | VIEWPORT_WIDTH / 2.0, 53 | VIEWPORT_HEIGHT / 2.0, 54 | )), 55 | ..default() 56 | }, 57 | texture: asset_server.load("icon.png"), 58 | ..default() 59 | }) 60 | .insert(Name::new("{{crate_name|pascal_case}}Plugin Sprite")); 61 | }); 62 | {%- endif %} 63 | } 64 | 65 | fn rotate(time: Res