Add a sword item, Weapon/Damage components
This commit is contained in:
parent
734ac096c4
commit
b6e044a8fe
@ -24,6 +24,14 @@ Templates(
|
||||
provides: Some([ ("MagicMap", 0) ]),
|
||||
frequency: 1,
|
||||
),
|
||||
Template(
|
||||
entity_type: Item,
|
||||
name: "Rusty Sword",
|
||||
glyph: '/',
|
||||
levels: [0, 1, 2],
|
||||
frequency: 1,
|
||||
base_damage: Some(1),
|
||||
),
|
||||
Template(
|
||||
entity_type: Enemy,
|
||||
name: "Goblin",
|
||||
|
@ -89,3 +89,9 @@ pub struct ActivateItem {
|
||||
pub used_by: Entity,
|
||||
pub item: Entity,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Damage(pub i32);
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Weapon;
|
||||
|
@ -17,6 +17,7 @@ pub fn spawn_player(ecs: &mut World, pos: Point) {
|
||||
},
|
||||
Name("Player 1".to_string()),
|
||||
FieldOfView::new(8),
|
||||
Damage(1),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -96,5 +96,12 @@ impl Templates {
|
||||
_ => println!("Warning: we don't know how to provide {}", provides),
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(damage) = &template.base_damage {
|
||||
commands.add_component(entity, Damage(*damage));
|
||||
if template.entity_type == EntityType::Item {
|
||||
commands.add_component(entity, Weapon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user