generated from 2ndbeam/bevy-template
feat!: Half-implemented sprite container
- Updated all assets - Refactored door again - Half of the sprites are visually broken for now
This commit is contained in:
parent
929ad45571
commit
b2efc73602
22 changed files with 165 additions and 31 deletions
|
|
@ -12,8 +12,6 @@ use crate::{
|
|||
|
||||
use super::*;
|
||||
|
||||
const CRATE_CLOSED_ASSET: &'static str = "sprites/interactive/crate_closed.png";
|
||||
|
||||
#[derive(Component, Clone, Copy, Default, Reflect, Debug, PartialEq, Eq)]
|
||||
#[reflect(Component, Clone, Default, Debug, PartialEq)]
|
||||
#[require(Sprite, InteractiveObject, Inventory)]
|
||||
|
|
@ -38,15 +36,26 @@ pub fn on_container_interact(
|
|||
}
|
||||
|
||||
pub fn container_bundle(
|
||||
asset_server: &Res<AssetServer>,
|
||||
textures: &Res<LayoutTextures>,
|
||||
position: Vec2,
|
||||
inventory_size: UVec2,
|
||||
) -> impl Bundle {
|
||||
let image = asset_server.load(CRATE_CLOSED_ASSET);
|
||||
let texture_atlas = TextureAtlas {
|
||||
layout: textures.container.atlas.clone(),
|
||||
index: textures.container.indices["main"],
|
||||
};
|
||||
let hl_texture_atlas = texture_atlas.clone().with_index(textures.container.indices["highlighted"]);
|
||||
let sprite = Sprite {
|
||||
image: textures.container.image.clone(),
|
||||
texture_atlas: Some(texture_atlas),
|
||||
..default()
|
||||
};
|
||||
let mut highlight_sprite = sprite.clone();
|
||||
highlight_sprite.texture_atlas = Some(hl_texture_atlas);
|
||||
(
|
||||
Container,
|
||||
Transform::from_xyz(position.x, position.y - meters(0.5), 0.),
|
||||
Sprite::from_image(image),
|
||||
sprite,
|
||||
Inventory::new(inventory_size),
|
||||
Children::spawn((
|
||||
Spawn((
|
||||
|
|
@ -54,6 +63,11 @@ pub fn container_bundle(
|
|||
Sensor,
|
||||
Transform::from_xyz(0., meters(0.5), 0.),
|
||||
)),
|
||||
Spawn((
|
||||
highlight_sprite,
|
||||
Transform::from_xyz(0., 0., 1.),
|
||||
Visibility::Hidden,
|
||||
)),
|
||||
)),
|
||||
Name::new(format!("Container {}x{}", inventory_size.x, inventory_size.y)),
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue