From 522aad7889cd62e96af7c420789507ccbf5b7aaa Mon Sep 17 00:00:00 2001 From: troido Date: Sat, 22 Feb 2020 23:41:51 +0100 Subject: it is now possible to use items --- src/components/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/components/mod.rs') 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 { -- cgit