ed_journals/modules/logs/content/log_event_content/
ship_targeted_event.rs

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use serde::{Deserialize, Serialize};

use crate::modules::ship::ShipType;

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct ShipTargetedEvent {
    pub target_locked: bool,

    /// [None] is used when [target_locked] is false.
    #[serde(flatten, default)]
    pub scan_stage: Option<ShipTargetedEventScanStage>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase", untagged)]
pub enum ShipTargetedEventScanStage {
    Locked(ShipTargetedEventScanStageLocked),
    StageOne(ShipTargetedEventScanStageOne),
    StageTwo(ShipTargetedEventScanStageTwo),
    StageThree(ShipTargetedEventScanStageThree),
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct ShipTargetedEventScanStageLocked {
    pub ship: ShipType,

    #[serde(rename = "Ship_Localised")]
    pub ship_localized: Option<String>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct ShipTargetedEventScanStageOne {
    pub ship: ShipType,

    #[serde(rename = "Ship_Localised")]
    pub ship_localized: String,
    pub pilot_name: String,

    #[serde(rename = "PilotName_Localised")]
    pub pilot_name_localized: String,

    pub pilot_rank: String,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct ShipTargetedEventScanStageTwo {
    pub ship: ShipType,

    #[serde(rename = "Ship_Localised")]
    pub ship_localized: String,

    // TODO replace this with an enum
    pub pilot_name: String,

    #[serde(rename = "PilotName_Localised")]
    pub pilot_name_localized: String,

    pub pilot_rank: String,
    pub shield_health: f32,
    pub hull_health: f32,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
#[serde(rename_all = "PascalCase")]
pub struct ShipTargetedEventScanStageThree {
    pub ship: ShipType,

    #[serde(rename = "Ship_Localised")]
    pub ship_localized: String,
    pub pilot_name: String,

    #[serde(rename = "PilotName_Localised")]
    pub pilot_name_localized: String,

    pub pilot_rank: String,
    pub shield_health: f32,
    pub hull_health: f32,

    // TODO the wiki says this field should be present, but my logs don't seem to contain then.
    pub faction: String,

    // TODO replace this with an enum
    pub legal_status: String,

    // TODO maybe this can be replaced with an enum
    pub sub_system: String,
    pub sub_system_health: f32,

    pub power: Option<String>,
}