mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed base energy being 0.
This commit is contained in:
parent
c4d7fa7fc1
commit
680a4e4dde
@ -99,7 +99,12 @@ impl Energy {
|
|||||||
|
|
||||||
pub fn update_max_energy(&mut self, body: Option<Body>, level: u16) {
|
pub fn update_max_energy(&mut self, body: Option<Body>, level: u16) {
|
||||||
if let Some(body) = body {
|
if let Some(body) = body {
|
||||||
|
self.set_base_max(body.base_energy() + 50 * level as u32);
|
||||||
self.set_maximum(body.base_energy() + 50 * level as u32);
|
self.set_maximum(body.base_energy() + 50 * level as u32);
|
||||||
|
self.change_by(EnergyChange {
|
||||||
|
amount: 50,
|
||||||
|
source: EnergySource::LevelUp,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +115,12 @@ impl Energy {
|
|||||||
self.last_max = self.base_max;
|
self.last_max = self.base_max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is private because max energy is based on the level
|
||||||
|
fn set_base_max(&mut self, amount: u32) {
|
||||||
|
self.base_max = amount;
|
||||||
|
self.current = self.current.min(self.maximum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct EnergyChange {
|
pub struct EnergyChange {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user