example item
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::entities::item::decorations::ItemDecorations;
|
||||
use crate::entities::item::material::{GemType, Material, MetalType};
|
||||
use crate::entities::item::quality::Quality;
|
||||
use crate::entities::item::types::ItemType;
|
||||
use crate::entities::item::Item;
|
||||
use crate::entities::item::ItemBundle;
|
||||
use crate::entities::item::ItemName;
|
||||
|
||||
// System to reduce stain time over time
|
||||
pub fn stain_fade_system(time: Res<Time>, mut items: Query<&mut Item>) {
|
||||
// Fade stains every 10 seconds
|
||||
if time.elapsed_secs_f64() as u32 % 10 == 0 {
|
||||
for mut item in items.iter_mut() {
|
||||
item.reduce_stain_time(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to create a decorated item
|
||||
pub fn create_decorated_item(
|
||||
commands: &mut Commands,
|
||||
item_type: ItemType,
|
||||
base_material: Material,
|
||||
quality: Quality,
|
||||
position: Vec3,
|
||||
sprite: Sprite,
|
||||
) -> Entity {
|
||||
let mut decorations = ItemDecorations::new();
|
||||
|
||||
// Example: Add a ruby encrusting to valuable items
|
||||
if quality >= Quality::Superior {
|
||||
decorations.add_gem_encrusting(
|
||||
Material::Gem(GemType::Ruby),
|
||||
0.5, // Small gem
|
||||
Quality::WellCrafted,
|
||||
);
|
||||
}
|
||||
|
||||
// Example: Add silver trim to masterwork items
|
||||
if quality >= Quality::Masterwork {
|
||||
decorations.add_trim(
|
||||
Material::Metal(MetalType::Silver),
|
||||
0.2, // Small amount of trim
|
||||
quality,
|
||||
);
|
||||
}
|
||||
|
||||
// Example: Add engraving to exceptional+ items
|
||||
if quality >= Quality::Exceptional {
|
||||
decorations.add_engraving("a majestic dorf holding a pickaxe".to_string(), quality);
|
||||
}
|
||||
|
||||
commands
|
||||
.spawn(ItemBundle {
|
||||
item: Item {
|
||||
quality,
|
||||
..Item::default()
|
||||
},
|
||||
item_type: item_type.clone(),
|
||||
base_material,
|
||||
decorations,
|
||||
transform: Transform::from_translation(position),
|
||||
visibility: Visibility::Visible,
|
||||
sprite: sprite,
|
||||
})
|
||||
.insert(ItemName::new(item_type.name()))
|
||||
.id()
|
||||
}
|
||||
Reference in New Issue
Block a user