1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::{combat::Attack, comp::item::Reagent, effect::Effect};
use rand::{thread_rng, Rng};
use serde::{Deserialize, Serialize};
use vek::Rgb;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Explosion {
    pub effects: Vec<RadiusEffect>,
    pub radius: f32,
    pub reagent: Option<Reagent>,
    pub min_falloff: f32,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub enum RadiusEffect {
    TerrainDestruction(f32, Rgb<f32>),
    Entity(Effect),
    Attack(Attack),
}

#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
pub enum ColorPreset {
    Black,
    InkBomb,
    IceBomb,
}

impl ColorPreset {
    pub fn to_rgb(&self) -> Rgb<f32> {
        match self {
            Self::Black => Rgb::black(),
            Self::InkBomb => Rgb::new(4.0, 7.0, 32.0),
            Self::IceBomb => {
                let variation = thread_rng().gen::<f32>();
                Rgb::new(
                    83.0 - (20.0 * variation),
                    212.0 - (52.0 * variation),
                    255.0 - (62.0 * variation),
                )
            },
        }
    }
}