tf2_enum/
killstreak_tier.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/// Killstreak tier.
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#[allow(missing_docs)]
34pub enum KillstreakTier {
35    #[strum(serialize = "Killstreak")]
36    Killstreak = 1,
37    #[strum(serialize = "Specialized Killstreak")]
38    Specialized = 2,
39    #[strum(serialize = "Professional Killstreak")]
40    Professional = 3,
41}
42
43impl Attribute for KillstreakTier {
44    const DEFINDEX: u32 = 2025;
45    const USES_FLOAT_VALUE: bool = true;
46    /// Represents the "killstreak_tier" attribute.
47    const ATTRIBUTE: AttributeDef = AttributeDef {
48        defindex: 2025,
49        name: "killstreak tier",
50        attribute_class: Some("killstreak_tier"),
51        description_string: Some("Killstreaks Active"),
52        description_format: Some(DescriptionFormat::ValueIsAdditive),
53        effect_type: EffectType::Positive,
54        hidden: false,
55        stored_as_integer: false,
56    };
57    
58    /// Gets the attribute float value.
59    fn attribute_float_value(&self) -> Option<f32> {
60        Some((*self as u32) as f32)
61    }
62}
63
64impl TryFromIntAttributeValue for KillstreakTier {}
65
66impl From<KillstreakTier> for ItemAttribute {
67    fn from(val: KillstreakTier) -> Self {
68        ItemAttribute {
69            defindex: KillstreakTier::DEFINDEX,
70            value: val.attribute_value(),
71            float_value: val.attribute_float_value(),
72        }
73    }
74}