tf2_enum/
killstreaker.rs

1use crate::{
2    Attribute,
3    AttributeDef,
4    DescriptionFormat,
5    EffectType,
6    ItemAttribute,
7    TryFromIntAttributeValue,
8};
9use num_enum::{IntoPrimitive, TryFromPrimitive};
10use serde_repr::{Deserialize_repr, Serialize_repr};
11use strum::{Display, EnumCount, EnumIter, EnumString};
12
13/// Killstreaker.
14#[derive(
15    Debug,
16    Clone,
17    Copy,
18    Eq,
19    PartialEq,
20    Ord,
21    PartialOrd,
22    Hash,
23    Display,
24    Serialize_repr,
25    Deserialize_repr,
26    EnumString,
27    EnumIter,
28    EnumCount,
29    TryFromPrimitive,
30    IntoPrimitive,
31)]
32#[repr(u32)]
33#[strum(serialize_all = "title_case")]
34#[allow(missing_docs)]
35pub enum Killstreaker {
36    FireHorns = 2002,
37    CerebralDischarge = 2003,
38    Tornado = 2004,
39    Flames = 2005,
40    Singularity = 2006,
41    Incinerator = 2007,
42    #[strum(serialize = "Hypno-Beam")]
43    HypnoBeam = 2008,
44}
45
46impl Attribute for Killstreaker {
47    const DEFINDEX: u32 = 2013;
48    const USES_FLOAT_VALUE: bool = true;
49    /// Represents the "killstreak_effect" attribute.
50    const ATTRIBUTE: AttributeDef = AttributeDef {
51        defindex: 2013,
52        name: "killstreak effect",
53        attribute_class: Some("killstreak_effect"),
54        description_string: Some("Killstreaker: %s1"),
55        description_format: Some(DescriptionFormat::ValueIsKillstreakEffectIndex),
56        effect_type: EffectType::Positive,
57        hidden: false,
58        stored_as_integer: false,
59    };
60    
61    /// Gets the attribute float value.
62    fn attribute_float_value(&self) -> Option<f32> {
63        Some((*self as u32) as f32)
64    }
65}
66
67impl TryFromIntAttributeValue for Killstreaker {}
68
69impl From<Killstreaker> for ItemAttribute {
70    fn from(val: Killstreaker) -> Self {
71        ItemAttribute {
72            defindex: Killstreaker::DEFINDEX,
73            value: val.attribute_value(),
74            float_value: val.attribute_float_value(),
75        }
76    }
77}