1use rakata_core::ResRef;
4use rakata_formats::{GffLocalizedString, GffModel};
5
6use crate::shared::ObjectId;
7
8#[derive(Debug, Clone, PartialEq, GffModel)]
10pub struct GitEncounterPoint {
11 #[gff(X, unexamined)]
13 pub x: f32,
14 #[gff(Y, unexamined)]
16 pub y: f32,
17 #[gff(Z, unexamined)]
19 pub z: f32,
20}
21
22#[derive(Debug, Clone, PartialEq, GffModel)]
28#[gff_entry(SpawnResRef, wire = ResRef, live)]
29#[gff_entry(SpawnCR, wire = f32, live)]
30pub struct GitEncounterSpawn {}
31
32#[derive(Debug, Clone, PartialEq, GffModel)]
34pub struct GitSpawnPoint {
35 #[gff(X, unexamined)]
37 pub x: f32,
38 #[gff(Y, unexamined)]
40 pub y: f32,
41 #[gff(Z, unexamined)]
43 pub z: f32,
44 #[gff(Orientation, unexamined)]
46 pub orientation: f32,
47}
48
49#[derive(Debug, Clone, PartialEq, GffModel)]
51#[gff_entry(Active, wire = u8, live)]
68#[gff_entry(AreaListMaxSize, wire = i32, live)]
69#[gff_entry(AreaListSize, wire = i32, unexamined)]
70#[gff_entry(AreaPoints, wire = f32, live)]
71#[gff_entry(Commandable, wire = u8, unexamined)]
72#[gff_entry(CurrentSpawns, wire = i32, live)]
73#[gff_entry(CustomScriptId, wire = i32, live)]
74#[gff_entry(Difficulty, wire = i32, live)]
75#[gff_entry(DifficultyIndex, wire = i32, live)]
76#[gff_entry(Exhausted, wire = u8, live)]
77#[gff_entry(Faction, wire = u32, live)]
78#[gff_entry(HeartbeatDay, wire = u32, live)]
79#[gff_entry(HeartbeatTime, wire = u32, live)]
80#[gff_entry(LastEntered, wire = u32, live)]
81#[gff_entry(LastLeft, wire = u32, live)]
82#[gff_entry(LastSpawnDay, wire = u32, live)]
83#[gff_entry(LastSpawnTime, wire = u32, live)]
84#[gff_entry(LocalizedName, wire = GffLocalizedString, live)]
85#[gff_entry(MaxCreatures, wire = i32, live)]
86#[gff_entry(NumberSpawned, wire = i32, live)]
87#[gff_entry(OnEntered, wire = ResRef, live)]
88#[gff_entry(OnExhausted, wire = ResRef, live)]
89#[gff_entry(OnExit, wire = ResRef, live)]
90#[gff_entry(OnHeartbeat, wire = ResRef, live)]
91#[gff_entry(OnUserDefined, wire = ResRef, live)]
92#[gff_entry(PlayerOnly, wire = u8, live)]
93#[gff_entry(RecCreatures, wire = i32, live)]
94#[gff_entry(Reset, wire = u8, live)]
95#[gff_entry(ResetTime, wire = i32, live)]
96#[gff_entry(Respawns, wire = i32, live)]
97#[gff_entry(SpawnOption, wire = i32, live)]
98#[gff_entry(SpawnPoolActive, wire = f32, live)]
99#[gff_entry(Started, wire = u8, live)]
100#[gff_entry(Tag, wire = String, live)]
101#[gff_entry(ActionList, container = list, unexamined)]
102#[gff_entry(AreaList, container = list, live)]
103#[gff_entry(CreatureList, container = list, live)]
104#[gff_entry(VarTable, container = list, unexamined)]
105#[gff_entry(SWVarTable, container = nested, unexamined)]
106#[gff_entry(SpawnList, list = GitEncounterSpawn, element_id = positional, live)]
107pub struct GitEncounter {
108 #[gff(
110 Geometry,
111 not_a_constant,
112 list = GitEncounterPoint,
113 element_id = unenforced(
114 1,
115 "neither read route asks an element for its type: LoadEncounterGeometry \
116 walks the list by position and takes every field by label, and it is \
117 reached the same way through ReadEncounterFromGff and through \
118 LoadEncounters' override branch. A module's static .git writes 1 here \
119 and a savegame writes each element's position, and neither is wrong"
120 )
121 )]
122 pub geometry: Vec<GitEncounterPoint>,
123 #[gff(
125 SpawnPointList,
126 not_a_constant,
127 list = GitSpawnPoint,
128 element_id = unenforced(
129 2,
130 "LoadEncounterSpawnPoints walks by position and takes every field by \
131 label, on both routes into it, so nothing tests an element's id. The \
132 two writers spend it differently for the same reason its sibling \
133 Geometry does"
134 )
135 )]
136 pub spawn_points: Vec<GitSpawnPoint>,
137 #[gff(ObjectId, stamped = ObjectId::INVALID, optional = ObjectId)]
155 pub object_id: Option<ObjectId>,
156 #[gff(TemplateResRef, unexamined, optional = ResRef)]
164 pub template_resref: Option<ResRef>,
165 #[gff(XPosition, constructed)]
167 pub x_position: f32,
168 #[gff(YPosition, constructed)]
170 pub y_position: f32,
171 #[gff(ZPosition, constructed)]
173 pub z_position: f32,
174}