assembly_maps/luz/paths/
core.rs

1use assembly_core::num_derive::{FromPrimitive, ToPrimitive};
2use assembly_core::types::{ObjectID, ObjectTemplate, Quaternion, Vector3f, WorldID};
3use std::collections::HashMap;
4
5#[cfg(feature = "serde-derives")]
6use serde::Serialize;
7
8/// Version / first field of path data
9#[cfg_attr(feature = "serde-derives", derive(Serialize))]
10#[derive(Clone, Debug, FromPrimitive, ToPrimitive)]
11pub struct ZonePathsVersion(u32);
12
13/// Version of this path data
14#[cfg_attr(feature = "serde-derives", derive(Serialize))]
15#[derive(Clone, Copy, Debug, FromPrimitive, ToPrimitive)]
16pub struct PathVersion(u32);
17
18impl PathVersion {
19    pub fn min(self, val: u32) -> bool {
20        self.0 >= val
21    }
22}
23
24/// Type of this path
25#[cfg_attr(feature = "serde-derives", derive(Serialize))]
26#[derive(Debug, FromPrimitive, ToPrimitive)]
27pub enum PathType {
28    Movement,
29    MovingPlatform,
30    Property,
31    Camera,
32    Spawner,
33    Showcase,
34    Race,
35    Rail,
36}
37
38/// Interpretation of this path
39#[cfg_attr(feature = "serde-derives", derive(Serialize))]
40#[derive(Debug, FromPrimitive, ToPrimitive)]
41pub enum PathComposition {
42    /// A closed polygon
43    Polygon,
44    /// A collection of single points
45    Points,
46    /// A sequence of points
47    Line,
48}
49
50/// General data for a movement path
51#[derive(Debug)]
52#[cfg_attr(feature = "serde-derives", derive(Serialize))]
53pub struct PathDataMovement {}
54
55/// General data for a moving platform path
56#[derive(Debug)]
57#[cfg_attr(feature = "serde-derives", derive(Serialize))]
58pub struct PathDataMovingPlatform {
59    /// Unknown field
60    pub something: Option<u8>,
61    /// Travel sound?
62    pub platform_travel_sound: Option<String>,
63}
64
65/// Time units for rental time
66#[derive(Debug, FromPrimitive, ToPrimitive)]
67#[cfg_attr(feature = "serde-derives", derive(Serialize))]
68pub enum PropertyRentalTimeUnit {
69    Forever,
70    Seconds,
71    Minutes,
72    Hours,
73    Days,
74    Weeks,
75    Months,
76    Years,
77}
78
79/// Achievement required to rent a property
80#[derive(Debug, FromPrimitive, ToPrimitive)]
81#[cfg_attr(feature = "serde-derives", derive(Serialize))]
82pub enum PropertyAchievementRequired {
83    None,
84    Builder,
85    Craftsman,
86    SeniorBuilder,
87    Journeyman,
88    MasterBuilder,
89    Architect,
90    SeniorArchitect,
91    MasterArchitect,
92    Visionary,
93    Exemplar,
94}
95
96/// General data for a property (border) path
97#[derive(Debug)]
98#[cfg_attr(feature = "serde-derives", derive(Serialize))]
99pub struct PathDataProperty {
100    /// Unknown value
101    pub value_1: u32,
102    /// Rental price
103    pub price: u32,
104    /// Rental time
105    pub rental_time: u32,
106    /// World that this property is attached to
107    pub associated_map: WorldID,
108    /// Unknown value
109    pub value_2: u32,
110    /// Display name of the property
111    pub display_name: String,
112    /// Display description
113    pub display_description: String,
114    /// Unknown value
115    pub value_3: u32,
116    /// Limit to the number of clones in one instance
117    pub clone_limit: u32,
118    /// Multiplier for reputation
119    pub reputation_multiplier: f32,
120    /// Unit for rental time
121    pub rental_time_unit: PropertyRentalTimeUnit,
122    /// Required achievement
123    pub achievement_required: PropertyAchievementRequired,
124    /// Coordinate of the player
125    pub player_zone_coordinate: Vector3f,
126    /// Maximum building height
127    pub max_build_height: f32,
128}
129
130/// General data for camera path
131#[derive(Debug)]
132#[cfg_attr(feature = "serde-derives", derive(Serialize))]
133pub struct PathDataCamera {
134    /// Following path
135    pub next_path: String,
136    /// Unknown
137    pub value_1: Option<u8>,
138}
139
140/// General data for a spawner path
141#[derive(Debug)]
142#[cfg_attr(feature = "serde-derives", derive(Serialize))]
143pub struct PathDataSpawner {
144    /// The object to be spawned
145    pub spawned_lot: ObjectTemplate,
146    /// Time until respawn
147    pub respawn_time: u32,
148    /// max to spawn (MAX_VALUE for infinity)
149    pub max_to_spawn: u32,
150    /// number to maintain spawned
151    pub min_to_spawn: u32,
152    /// Spawner object ID without flags
153    pub spawner_obj_id: ObjectID,
154    /// Activate network on load
155    pub activate_network_on_load: bool,
156}
157
158/// General data for a showcase path
159#[derive(Debug)]
160#[cfg_attr(feature = "serde-derives", derive(Serialize))]
161pub struct PathDataShowcase {}
162
163/// General data for a race path
164#[derive(Debug)]
165#[cfg_attr(feature = "serde-derives", derive(Serialize))]
166pub struct PathDataRace {}
167
168/// General data for a rail path
169#[derive(Debug)]
170#[cfg_attr(feature = "serde-derives", derive(Serialize))]
171pub struct PathDataRail {}
172
173/// Data for a movement path waypoint
174#[derive(Debug)]
175#[cfg_attr(feature = "serde-derives", derive(Serialize))]
176pub struct PathWaypointDataMovement {
177    pub config: WaypointConfig,
178}
179
180/// Sounds for a moving platform
181#[derive(Debug)]
182#[cfg_attr(feature = "serde-derives", derive(Serialize))]
183pub struct PathWaypointDataMovingPlatformSounds {
184    pub arrive_sound: String,
185    pub depart_sound: String,
186}
187
188/// Data for a moving platform path waypoint
189#[derive(Debug)]
190#[cfg_attr(feature = "serde-derives", derive(Serialize))]
191pub struct PathWaypointDataMovingPlatform {
192    pub rotation: Quaternion,
193    pub lock_player: bool,
194    pub speed: f32,
195    pub wait: f32,
196    pub sounds: Option<PathWaypointDataMovingPlatformSounds>,
197}
198
199/// Data for a property (border) path waypoint
200#[derive(Debug)]
201#[cfg_attr(feature = "serde-derives", derive(Serialize))]
202pub struct PathWaypointDataProperty {}
203
204/// Data for a camera path waypoint
205#[derive(Debug)]
206#[cfg_attr(feature = "serde-derives", derive(Serialize))]
207pub struct PathWaypointDataCamera {
208    pub rotation: Quaternion,
209    pub time: f32,
210    pub value_5: f32,
211    pub tension: f32,
212    pub continuity: f32,
213    pub bias: f32,
214}
215
216/// Data for a spawner network waypoint
217#[derive(Debug)]
218#[cfg_attr(feature = "serde-derives", derive(Serialize))]
219pub struct PathWaypointDataSpawner {
220    pub rotation: Quaternion,
221    pub config: WaypointConfig,
222}
223
224/// Data for a showcase path waypoint
225#[derive(Debug)]
226#[cfg_attr(feature = "serde-derives", derive(Serialize))]
227pub struct PathWaypointDataShowcase {}
228
229/// Data for a race path waypoint
230#[derive(Debug)]
231#[cfg_attr(feature = "serde-derives", derive(Serialize))]
232pub struct PathWaypointDataRace {
233    pub rotation: Quaternion,
234    pub value_1: u8,
235    pub value_2: u8,
236    pub value_3: f32,
237    pub value_4: f32,
238    pub value_5: f32,
239}
240
241/// Data for a rail path waypoint
242#[derive(Debug)]
243#[cfg_attr(feature = "serde-derives", derive(Serialize))]
244pub struct PathWaypointDataRail {
245    pub rotation: Quaternion,
246    pub speed: Option<f32>,
247    pub config: WaypointConfig,
248}
249
250/// Config for a waypoint
251pub type WaypointConfig = HashMap<String, String>;
252
253/// Path Waypoint
254#[derive(Debug)]
255#[cfg_attr(feature = "serde-derives", derive(Serialize))]
256pub struct PathWaypointVariant<WaypointType> {
257    pub position: Vector3f,
258    #[cfg_attr(feature = "serde-derives", serde(flatten))]
259    pub data: WaypointType,
260}
261
262pub type PathWaypointVariantMovement = PathWaypointVariant<PathWaypointDataMovement>;
263pub type PathWaypointVariantMovingPlatform = PathWaypointVariant<PathWaypointDataMovingPlatform>;
264pub type PathWaypointVariantProperty = PathWaypointVariant<PathWaypointDataProperty>;
265pub type PathWaypointVariantCamera = PathWaypointVariant<PathWaypointDataCamera>;
266pub type PathWaypointVariantSpawner = PathWaypointVariant<PathWaypointDataSpawner>;
267pub type PathWaypointVariantShowcase = PathWaypointVariant<PathWaypointDataShowcase>;
268pub type PathWaypointVariantRace = PathWaypointVariant<PathWaypointDataRace>;
269pub type PathWaypointVariantRail = PathWaypointVariant<PathWaypointDataRail>;
270
271/// Common header for all paths
272#[derive(Debug)]
273#[cfg_attr(feature = "serde-derives", derive(Serialize))]
274pub struct PathHeader {
275    pub version: PathVersion,
276    pub path_name: String,
277    pub value_1: u32,
278    pub path_composition: PathComposition,
279}
280
281/// Wrapper for all general path data
282#[derive(Debug)]
283#[cfg_attr(feature = "serde-derives", derive(Serialize))]
284pub struct PathVariant<DataType, WaypointDataType> {
285    pub header: PathHeader,
286    pub path_data: DataType,
287    pub waypoints: Vec<PathWaypointVariant<WaypointDataType>>,
288}
289
290pub type PathVariantMovement = PathVariant<PathDataMovement, PathWaypointDataMovement>;
291pub type PathVariantMovingPlatform =
292    PathVariant<PathDataMovingPlatform, PathWaypointDataMovingPlatform>;
293pub type PathVariantProperty = PathVariant<PathDataProperty, PathWaypointDataProperty>;
294pub type PathVariantCamera = PathVariant<PathDataCamera, PathWaypointDataCamera>;
295pub type PathVariantSpawner = PathVariant<PathDataSpawner, PathWaypointDataSpawner>;
296pub type PathVariantShowcase = PathVariant<PathDataShowcase, PathWaypointDataShowcase>;
297pub type PathVariantRace = PathVariant<PathDataRace, PathWaypointDataRace>;
298pub type PathVariantRail = PathVariant<PathDataRail, PathWaypointDataRail>;
299
300/// Enum of all path variants
301#[derive(Debug)]
302#[cfg_attr(feature = "serde-derives", derive(Serialize))]
303#[cfg_attr(feature = "serde-derives", serde(tag = "type"))]
304pub enum Path {
305    Movement(PathVariantMovement),
306    MovingPlatform(PathVariantMovingPlatform),
307    Property(PathVariantProperty),
308    Camera(PathVariantCamera),
309    Spawner(PathVariantSpawner),
310    Showcase(PathVariantShowcase),
311    Race(PathVariantRace),
312    Rail(PathVariantRail),
313}
314
315/// All paths in a zone
316#[derive(Debug)]
317#[cfg_attr(feature = "serde-derives", derive(Serialize))]
318pub struct ZonePaths {
319    pub version: ZonePathsVersion,
320    pub paths: Vec<Path>,
321}