1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 23:44:38 +00:00

base in AttributeInstance

This commit is contained in:
mat 2022-11-06 22:19:39 -06:00
commit d672a9c89f

View file

@ -11,17 +11,18 @@ pub struct AttributeModifiers {
} }
#[derive(Clone, Debug, Default)] #[derive(Clone, Debug, Default)]
pub struct AttributeInstance<const BASE: f64> { pub struct AttributeInstance {
pub base: f64,
pub modifiers: Vec<AttributeModifier>, pub modifiers: Vec<AttributeModifier>,
} }
impl<const BASE: f64> AttributeInstance { impl AttributeInstance {
pub fn calculate(&self) -> f64 { pub fn calculate(&self) -> f64 {
let mut total = BASE; let mut total = self.base;
for modifier in self.modifiers { for modifier in self.modifiers {
match modifier.operation { match modifier.operation {
AttributeModifierOperation::Addition => total += modifier.amount, AttributeModifierOperation::Addition => total += modifier.amount,
AttributeModifierOperation::MultiplyBase => total += BASE * modifier.amount, AttributeModifierOperation::MultiplyBase => total += self.base * modifier.amount,
_ => {} _ => {}
} }
match modifier.operation { match modifier.operation {