Skip to main content

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

1//! Fired when the player applies an engineering modification to one of their ship's modules.
2
3use crate::civilization::Engineer;
4use serde::{Deserialize, Serialize};
5
6use crate::modules::materials::Material;
7use crate::modules::ship::{Blueprint, BlueprintModifier, ShipModule, ShipSlot};
8
9/// Fired when the player applies an engineering modification to one of their ship's modules.
10#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
11#[serde(rename_all = "PascalCase")]
12pub struct EngineerCraftEvent {
13    /// The slot of the module being modified.
14    pub slot: ShipSlot,
15
16    /// The type of module being modified.
17    pub module: ShipModule,
18
19    /// List of paid materials for the modification. Note that these are the materials for one
20    /// increase in quality and not for fully upgrading the whole level.
21    pub ingredients: Vec<EngineerCraftEventIngredient>,
22
23    /// The name of engineer that applied the modification. In some cases where the engineer is
24    /// [Engineer::System] this is not set.
25    pub engineer: Option<String>,
26
27    /// The engineer where the player applied the modifications.
28    #[serde(rename = "EngineerID")]
29    pub engineer_id: Engineer,
30
31    /// The id of the modification the player applied.
32    #[serde(rename = "BlueprintID")]
33    pub blueprint_id: u64,
34
35    /// The name of the modification the player applied.
36    pub blueprint_name: Blueprint,
37
38    /// The level or 'grade' of the applied modification.
39    pub level: u8,
40
41    /// The quality or 'progress' of the applied modification.
42    pub quality: f32,
43
44    /// The modifiers that are affected by the modification.
45    pub modifiers: Vec<EngineerCraftEventModifier>,
46}
47
48/// A material requirement for a modification.
49#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
50#[serde(rename_all = "PascalCase")]
51pub struct EngineerCraftEventIngredient {
52    /// The material required.
53    pub name: Material,
54
55    /// The number of the given material required.
56    pub count: u16,
57}
58
59/// An applied modifier to the module.
60#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
61#[serde(rename_all = "PascalCase")]
62pub struct EngineerCraftEventModifier {
63    /// The name of the modified applied.
64    pub label: BlueprintModifier,
65
66    /// The kind of modifier that was applied.
67    #[serde(flatten)]
68    pub kind: EngineerCraftEventModifierKind,
69}
70
71/// The kind of applied modifier/
72#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
73#[serde(untagged)]
74pub enum EngineerCraftEventModifierKind {
75    /// A change in a numeric value.
76    ValueChange(EngineerCraftEventValueChange),
77
78    /// Replacement of a certain string.
79    StringChange(EngineerCraftEventStringChange),
80}
81
82/// A change in a numeric value.
83#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
84#[serde(rename_all = "PascalCase")]
85pub struct EngineerCraftEventValueChange {
86    /// The new value of the target modifier.
87    pub value: f32,
88
89    /// The original value of target modifier.
90    pub original_value: f32,
91
92    /// Whether decreasing the value yields positive results.
93    pub less_is_good: u8,
94}
95
96/// Replacement of a certain string.
97#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
98#[serde(rename_all = "PascalCase")]
99pub struct EngineerCraftEventStringChange {
100    /// New value of the string for the given modifier.
101    pub value_str: String,
102
103    /// New localized value of the string for the given modifier.
104    #[serde(rename = "ValueStr_Localised")]
105    pub value_str_localized: String,
106}