summaryrefslogtreecommitdiff
path: root/src/components/mod.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-23 23:44:50 +0100
committertroido <troido@protonmail.com>2020-02-23 23:44:50 +0100
commit86cdc6c567d0ca429d69bebbb2fb02f1d3754c8d (patch)
treed70eb9d9f014c9cdbf301772c339f22ee5e3ab82 /src/components/mod.rs
parentf422238d7aaae0ff1b2d560a71a99b0a881ad338 (diff)
players can now attack other objects
Diffstat (limited to 'src/components/mod.rs')
-rw-r--r--src/components/mod.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs
index 0c258dc..330bc67 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -9,7 +9,9 @@ use specs::{
HashMapStorage,
FlaggedStorage,
NullStorage,
- Component
+ Component,
+ Entity,
+ WriteStorage
};
use crate::{
@@ -121,14 +123,33 @@ pub struct Attacked {
pub attacks: Vec<Attack>
}
+pub fn add_attack(attacked: &mut WriteStorage<Attacked> , ent: Entity, attack: Attack) {
+ attacked
+ .entry(ent)
+ .unwrap()
+ .or_insert_with(Attacked::default)
+ .attacks
+ .push(attack);
+}
+
#[derive(Default, Component, Debug, Clone)]
#[storage(NullStorage)]
pub struct Entered;
+#[derive(Default, Component, Debug, Clone)]
+#[storage(NullStorage)]
+pub struct Dying;
+
+#[derive(Component, Debug, Clone)]
+#[storage(HashMapStorage)]
+pub struct Trap {
+ pub attack: Attack
+}
+
#[derive(Component, Debug, Clone)]
#[storage(HashMapStorage)]
-pub struct Trap{
+pub struct Fighter {
pub attack: Attack
}