Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Box item #504

Merged
merged 2 commits into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/map/elements/item/crate/crate.atlas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: ./crate.png
tile_size: [36, 31]
rows: 1
columns: 1
16 changes: 16 additions & 0 deletions assets/map/elements/item/crate/crate.element.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
name: Crate
category: Weapons
builtin: !Crate
throw_velocity: [7, 5]

atlas: ./crate.atlas.yaml

breaking_atlas: ./crate_breaking.atlas.yaml
breaking_anim_length: 25
breaking_anim_fps: 30

# TODO: Better break sound
break_sound: ./fuse.ogg

body_size: [36, 30]
body_offset: [0, 0]
grab_offset: [14, -2]
break_timeout: 4
Binary file added assets/map/elements/item/crate/crate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions assets/map/elements/item/crate/crate_breaking.atlas.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
image: ./crate_breaking.png
tile_size: [128, 128]
rows: 1
columns: 25
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/map/elements/item/crate/fuse.ogg
Binary file not shown.
11 changes: 8 additions & 3 deletions assets/map/elements/item/grenade/grenade.element.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
name: Grenades
category: Weapons
builtin: !Grenades
atlas: ./grenade.atlas.yaml
explosion_atlas: ./explosion.atlas.yaml
builtin: !Grenade
fuse_time: 4.0
throw_velocity: [7, 5]
damage_region_size: [60, 60]
damage_region_lifetime: 0.6

atlas: ./grenade.atlas.yaml

explosion_atlas: ./explosion.atlas.yaml
explosion_lifetime: 1.0
explosion_frames: 12
explosion_fps: 8
explosion_sound: ./explosion.ogg

fuse_sound: ./fuse.ogg

body_size: [18, 18]
grab_offset: [-7, -6]
body_offset: [0, 2]
# TODO: Enable and fix rotation problems
can_rotate: false
4 changes: 4 additions & 0 deletions assets/map/levels/level1.map.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,10 @@ layers:
- 536.0
- 309.5
element: ../elements/item/grenade/grenade.element.yaml
- pos:
- 719.0
- 400.5
element: ../elements/item/crate/crate.element.yaml
- pos:
- 292.2272
- 609.5
Expand Down
26 changes: 25 additions & 1 deletion src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ impl AssetLoader for MapElementMetaLoader {
dependencies.push(path);
*sound_handle = handle.typed();
}
BuiltinElementKind::Grenades {
BuiltinElementKind::Grenade {
atlas,
atlas_handle,
explosion_atlas,
Expand Down Expand Up @@ -445,6 +445,30 @@ impl AssetLoader for MapElementMetaLoader {
*handle = sound_handle.typed();
}
}
BuiltinElementKind::Crate {
atlas,
atlas_handle,
breaking_atlas,
breaking_atlas_handle,
break_sound,
break_sound_handle,
..
} => {
for (atlas, atlas_handle) in [
(atlas, atlas_handle),
(breaking_atlas, breaking_atlas_handle),
] {
let (path, handle) = get_relative_asset(load_context, self_path, atlas);
*atlas_handle = AssetHandle::new(path.clone(), handle.typed());
dependencies.push(path);
}

let (sound, handle) = (break_sound, break_sound_handle);
let (sound_path, sound_handle) =
get_relative_asset(load_context, self_path, sound);
dependencies.push(sound_path);
*handle = sound_handle.typed();
}
}

// Load preloaded assets
Expand Down
1 change: 1 addition & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ impl Plugin for MapPlugin {
/// script.
#[derive(Reflect, Component, Default)]
#[reflect(Component, Default)]
#[component(storage = "SparseSet")]
pub struct MapElementHydrated;

/// If this component and a [`Transform`] component is added to any entity, it will be moved back to
Expand Down
2 changes: 2 additions & 0 deletions src/map/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub mod player_spawner;
pub mod sproinger;

// Items
pub mod crate_item;
pub mod grenade;
pub mod sword;

Expand All @@ -27,6 +28,7 @@ impl Plugin for MapElementsPlugin {
fn build(&self, app: &mut App) {
app.add_plugin(decoration::DecorationPlugin)
.add_plugin(grenade::GrenadePlugin)
.add_plugin(crate_item::CrateItemPlugin)
.add_plugin(player_spawner::PlayerSpawnerPlugin)
.add_plugin(sproinger::SproingerPlugin)
.add_plugin(sword::SwordPlugin);
Expand Down
Loading