summaryrefslogtreecommitdiff
path: root/src/components/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/mod.rs')
-rw-r--r--src/components/mod.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/components/mod.rs b/src/components/mod.rs
index a0ccde4..459590b 100644
--- a/src/components/mod.rs
+++ b/src/components/mod.rs
@@ -84,6 +84,14 @@ pub struct Health {
pub health: i64,
pub maxhealth: i64
}
+impl Health {
+ pub fn heal(&mut self, amount: i64) {
+ self.health += amount;
+ if self.health > self.maxhealth {
+ self.health = self.maxhealth;
+ }
+ }
+}
#[derive(Component, Debug, Clone)]
pub struct Serialise {