item flashing
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::entities::item::{Item, ItemBundle, ItemDecorations, ItemType, Material, Quality};
|
||||
use crate::world::tiles::tilemap;
|
||||
use crate::world::VisibleGameEntity;
|
||||
|
||||
// Enum for misc item prefabs
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum MiscPrefab {
|
||||
RawMeat,
|
||||
@@ -12,11 +12,13 @@ pub enum MiscPrefab {
|
||||
|
||||
// Spawns a misc prefab at a given position.
|
||||
// These are all likely temporary to speed up development but will be replaced by semi-custom items everywhere.
|
||||
// As well as acting as demonstration of how to spawn items for the future.
|
||||
pub fn spawn_prefab(
|
||||
commands: &mut Commands,
|
||||
asset_server: &Res<AssetServer>,
|
||||
prefab: MiscPrefab,
|
||||
position: Vec3,
|
||||
tilemap: &mut ResMut<tilemap::TileMap>,
|
||||
) -> Entity {
|
||||
match prefab {
|
||||
MiscPrefab::RawMeat => {
|
||||
@@ -37,7 +39,16 @@ pub fn spawn_prefab(
|
||||
},
|
||||
})
|
||||
.id();
|
||||
commands.entity(meat).insert(VisibleGameEntity).id()
|
||||
let mut items = tilemap
|
||||
.item_tiles
|
||||
.get(&position.as_ivec3())
|
||||
.unwrap_or(&Vec::new())
|
||||
.clone();
|
||||
items.push(meat.index());
|
||||
tilemap
|
||||
.item_tiles
|
||||
.insert(position.as_ivec3(), items.clone());
|
||||
return commands.entity(meat).insert(VisibleGameEntity).id();
|
||||
}
|
||||
MiscPrefab::Coin => {
|
||||
let coin = commands
|
||||
@@ -57,6 +68,15 @@ pub fn spawn_prefab(
|
||||
},
|
||||
})
|
||||
.id();
|
||||
let mut items = tilemap
|
||||
.item_tiles
|
||||
.get(&position.as_ivec3())
|
||||
.unwrap_or(&Vec::new())
|
||||
.clone();
|
||||
items.push(coin.index());
|
||||
tilemap
|
||||
.item_tiles
|
||||
.insert(position.as_ivec3(), items.clone());
|
||||
commands.entity(coin).insert(VisibleGameEntity).id()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user