Skip to content

Commit

Permalink
switched from plugin to embedded_asset macro
Browse files Browse the repository at this point in the history
  • Loading branch information
cxreiff committed Jul 29, 2024
1 parent ead29a6 commit 017d5a7
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 40 deletions.
22 changes: 1 addition & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "lifecycler"
description = "Bevy Game Jam #5 submission. Terminal aquarium."
version = "0.2.1"
version = "0.2.2"
edition = "2021"
license = "MIT OR Apache-2.0 OR CC0-1.0"
authors = ["cxreiff <cooper@cxreiff.com>"]
Expand All @@ -14,7 +14,6 @@ include = ["/src", "/assets"]
[dependencies]
bevy = "0.14.0"
bevy_atmosphere = "0.10.0"
bevy_embedded_assets = "0.11.0"
bevy_hanabi = "0.12.0"
bevy_ratatui = "0.6.1"
bevy_ratatui_render = "0.5.2"
Expand Down
19 changes: 19 additions & 0 deletions src/assets.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
use bevy::asset::embedded_asset;
use bevy::prelude::*;

pub(super) fn plugin(app: &mut App) {
let prefix = "src/";
embedded_asset!(app, prefix, "../assets/base.glb");
embedded_asset!(app, prefix, "../assets/bubble.ogg");
embedded_asset!(app, prefix, "../assets/coral.glb");
embedded_asset!(app, prefix, "../assets/fish.glb");
embedded_asset!(app, prefix, "../assets/frame.glb");
embedded_asset!(app, prefix, "../assets/gravel.glb");
embedded_asset!(app, prefix, "../assets/off.ogg");
embedded_asset!(app, prefix, "../assets/on.ogg");
embedded_asset!(app, prefix, "../assets/rocks.glb");
embedded_asset!(app, prefix, "../assets/skeleton.glb");
embedded_asset!(app, prefix, "../assets/snail.glb");
embedded_asset!(app, prefix, "../assets/starfish.glb");
embedded_asset!(app, prefix, "../assets/tank.glb");
}
8 changes: 6 additions & 2 deletions src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ fn setup_camera_system(mut commands: Commands, ratatui_render: Res<RatatuiRender
}

fn setup_sfx_system(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.insert_resource(ClickOnSound(asset_server.load("on.ogg")));
commands.insert_resource(ClickOffSound(asset_server.load("off.ogg")));
commands.insert_resource(ClickOnSound(
asset_server.load("embedded://lifecycler/../assets/on.ogg"),
));
commands.insert_resource(ClickOffSound(
asset_server.load("embedded://lifecycler/../assets/off.ogg"),
));
}

fn toggle_daylight_system(
Expand Down
2 changes: 1 addition & 1 deletion src/creatures/fish_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn setup_fish_system(
mesh: 0,
primitive: 0,
})
.from_asset("embedded://fish.glb"),
.from_asset("embedded://lifecycler/../assets/fish.glb"),
);
commands.insert_resource(FishMesh(fish_mesh));

Expand Down
4 changes: 3 additions & 1 deletion src/creatures/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ pub struct FishSkeletonBundle(SceneBundle);

fn setup_lifecycle_system(mut commands: Commands, asset_server: Res<AssetServer>) {
let fish_skeleton = SceneBundle {
scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://skeleton.glb")),
scene: asset_server.load(
GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/skeleton.glb"),
),
..default()
};
commands.insert_resource(FishSkeletonBundle(fish_skeleton));
Expand Down
3 changes: 2 additions & 1 deletion src/creatures/snail_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ fn setup_snails_system(
asset_server: Res<AssetServer>,
mut spawn_events: EventWriter<SnailSpawnEvent>,
) {
let snail = asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://snail.glb"));
let snail = asset_server
.load(GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/snail.glb"));
commands.insert_resource(SnailScene(snail));

spawn_events.send(SnailSpawnEvent(Vec3::new(-1.4, -1.7, 0.4), 0.1));
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/starfish_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ fn setup_starfishes_system(
asset_server: Res<AssetServer>,
mut spawn_events: EventWriter<StarfishSpawnEvent>,
) {
let starfish =
asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://starfish.glb"));
let starfish = asset_server
.load(GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/starfish.glb"));
commands.insert_resource(StarfishScene(starfish));

spawn_events.send(StarfishSpawnEvent(Vec3::new(-0.3, -1.3, -0.4), 0.2));
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ use bevy::{
window::ExitCondition,
};
use bevy_atmosphere::plugin::AtmospherePlugin;
use bevy_embedded_assets::EmbeddedAssetPlugin;
use bevy_hanabi::HanabiPlugin;
use bevy_ratatui::RatatuiPlugins;
use bevy_ratatui_render::RatatuiRenderPlugin;

mod assets;
mod bubbles;
mod camera;
mod creatures;
Expand All @@ -35,7 +35,6 @@ impl Plugin for AppPlugin {
level: bevy::log::Level::ERROR,
..default()
}),
EmbeddedAssetPlugin::default(),
ScheduleRunnerPlugin::run_loop(Duration::from_secs_f64(1. / 90.)),
FrameTimeDiagnosticsPlugin,
RatatuiPlugins {
Expand All @@ -50,6 +49,7 @@ impl Plugin for AppPlugin {
.init_resource::<Flags>();

app.add_plugins((
assets::plugin,
bubbles::plugin,
camera::plugin,
draw::plugin,
Expand Down
4 changes: 3 additions & 1 deletion src/pellets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ fn setup_pellets_system(
}

fn setup_sfx_system(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.insert_resource(PelletSound(asset_server.load("bubble.ogg")));
commands.insert_resource(PelletSound(
asset_server.load("embedded://lifecycler/../assets/bubble.ogg"),
));
}

fn create_pellets_system(
Expand Down
21 changes: 14 additions & 7 deletions src/tank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,36 @@ fn setup_tank_system(
SceneBundle {
transform: Transform::from_scale(Vec3::new(2., 0.5, 2.))
.with_rotation(Quat::from_rotation_x(PI / 2.)),
scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://tank.glb")),
scene: asset_server.load(
GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/tank.glb"),
),
..default()
},
));
commands.spawn(SceneBundle {
transform: Transform::from_scale(Vec3::new(1.8, 1., 0.5))
.with_translation(Vec3::new(0., -1.75, 0.)),
scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://gravel.glb")),
scene: asset_server.load(
GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/gravel.glb"),
),
..default()
});

commands.spawn(SceneBundle {
transform: Transform::from_scale(Vec3::new(2., 0.6, 2.0))
.with_translation(Vec3::new(0., 0.0, 0.))
.with_rotation(Quat::from_rotation_x(PI / 2.)),
scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://base.glb")),
scene: asset_server
.load(GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/base.glb")),
..default()
});

commands.spawn(SceneBundle {
transform: Transform::from_scale(Vec3::new(2., 2., 0.6))
.with_translation(Vec3::new(0., 0.0, 0.))
.with_rotation(Quat::from_rotation_x(0.)),
scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://frame.glb")),
scene: asset_server
.load(GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/frame.glb")),
..default()
});

Expand All @@ -68,7 +74,7 @@ fn setup_tank_system(
mesh: 0,
primitive: 0,
})
.from_asset("embedded://coral.glb"),
.from_asset("embedded://lifecycler/../assets/coral.glb"),
);
commands.spawn(coral_bundle_1);

Expand All @@ -82,12 +88,13 @@ fn setup_tank_system(
mesh: 1,
primitive: 0,
})
.from_asset("embedded://coral.glb"),
.from_asset("embedded://lifecycler/../assets/coral.glb"),
);
commands.spawn(coral_bundle_2);

let rock_bundle = SceneBundle {
scene: asset_server.load(GltfAssetLabel::Scene(0).from_asset("embedded://rocks.glb")),
scene: asset_server
.load(GltfAssetLabel::Scene(0).from_asset("embedded://lifecycler/../assets/rocks.glb")),
..default()
};

Expand Down

0 comments on commit 017d5a7

Please sign in to comment.