Skip to main content

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

1//! Fired when the player registers a new entry in their codex.
2
3use serde::{Deserialize, Serialize};
4
5use crate::modules::exploration::CodexEntry;
6use crate::modules::galaxy::Region;
7
8/// Fired when the player registers a new entry in their codex.
9#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
10#[serde(rename_all = "PascalCase")]
11pub struct CodexEntryEvent {
12    /// The id of the entry.
13    #[serde(rename = "EntryID")]
14    pub entry_id: u64,
15
16    /// The name of the codex entry.
17    pub name: CodexEntry,
18
19    /// The localized name of the codex entry.
20    #[serde(rename = "Name_Localised")]
21    pub name_localized: Option<String>,
22
23    /// The category for this entry.
24    pub category: CodexEntryEventCategory,
25
26    /// The localized name of the category for this entry.
27    #[serde(rename = "Category_Localised")]
28    pub category_localized: Option<String>,
29
30    /// The subcategory for this entry.
31    pub sub_category: CodexEntryEventSubcategory,
32
33    /// The localized name of the subcategory for this entry.
34    #[serde(rename = "SubCategory_Localised")]
35    pub sub_category_localized: Option<String>,
36
37    /// The region the codex entry has been scanned.
38    pub region: Region,
39
40    /// The localized name of the region the codex entry has been scanned.
41    #[serde(rename = "Region_Localised")]
42    pub region_localized: Option<String>,
43
44    /// The name of the system the codex entry has been scanned.
45    pub system: String,
46
47    /// The address of the system the codex entry has been scanned.
48    pub system_address: u64,
49
50    /// The body id of the subject of the entry or has been scanned on.
51    #[serde(rename = "BodyID")]
52    pub body_id: Option<u8>,
53
54    // TODO sometimes missing, sometimes an empty string
55    pub nearest_destination: Option<String>,
56
57    /// Filled for exobiology entries detailing where on the planet the entry has been scanned.
58    pub planetary_location: Option<CodexEntryEventPlanetaryLocation>,
59
60    /// Whether the player has never encountered this entry before, including in other regions.
61    #[serde(default)]
62    pub is_new_entry: bool,
63}
64
65/// Category for a given codex entry.
66#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
67pub enum CodexEntryEventCategory {
68    /// Includes things like genuses and species.
69    #[serde(rename = "$Codex_Category_Biology;")]
70    Biology,
71
72    /// Includes things like star and planet classes.
73    #[serde(rename = "$Codex_Category_StellarBodies;")]
74    StellarBodies,
75
76    /// Includes entries related to guardians.
77    #[serde(rename = "$Codex_Category_Civilisations;")]
78    Civilizations,
79
80    /// Unknown codex category.
81    #[cfg(feature = "allow-unknown")]
82    #[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
83    #[serde(untagged)]
84    Unknown(String),
85}
86
87/// Subcategory for a given codex entry.
88#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
89pub enum CodexEntryEventSubcategory {
90    /// Subcategory related to organic structures like genuses and species.
91    #[serde(rename = "$Codex_SubCategory_Organic_Structures;")]
92    OrganicStructures,
93
94    /// Subcategory related to star bodies.
95    #[serde(rename = "$Codex_SubCategory_Stars;")]
96    Stars,
97
98    /// Subcategory related to planets.
99    #[serde(rename = "$Codex_SubCategory_Terrestrials;")]
100    Terrestrials,
101
102    /// Subcategory related to gas giants.
103    #[serde(rename = "$Codex_SubCategory_Gas_Giants;")]
104    GasGiants,
105
106    #[serde(rename = "$Codex_SubCategory_Geology_and_Anomalies;")]
107    GeologyAndAnomalies,
108
109    /// Subcategory related to Thargoids and their activity.
110    #[serde(rename = "$Codex_SubCategory_Thargoid;")]
111    Thargoid,
112
113    /// Unknown subcategory.
114    #[cfg(feature = "allow-unknown")]
115    #[cfg_attr(docsrs, doc(cfg(feature = "allow-unknown")))]
116    #[serde(untagged)]
117    Unknown(String),
118}
119
120/// Details about the location of the codex entry on a planet.
121#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
122#[serde(rename_all = "PascalCase")]
123pub struct CodexEntryEventPlanetaryLocation {
124    /// The latitude of the codex entry on a planet.
125    pub latitude: f32,
126
127    /// The longitude of the codex entry on a planet.
128    pub longitude: f32,
129}