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
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
use assembly_core::types::{WorldID, Vector3f, Quaternion, ObjectTemplate, ObjectID};
use assembly_core::num_derive::{FromPrimitive, ToPrimitive};
use std::collections::HashMap;

/// Version / first field of path data
#[derive(Clone, Debug, FromPrimitive, ToPrimitive)]
pub struct ZonePathsVersion(u32);

/// Version of this path data
#[derive(Clone, Copy, Debug, FromPrimitive, ToPrimitive)]
pub struct PathVersion(u32);

impl PathVersion {
    pub fn min(self, val: u32) -> bool {
        return self.0 >= val;
    }
}

/// Type of this path
#[derive(Debug, FromPrimitive, ToPrimitive)]
pub enum PathType {
    Movement,
    MovingPlatform,
    Property,
    Camera,
    Spawner,
    Showcase,
    Race,
    Rail,
}

/// Interpretation of this path
#[derive(Debug, FromPrimitive, ToPrimitive)]
pub enum PathComposition {
    /// A closed polygon
    Polygon,
    /// A collection of single points
    Points,
    /// A sequence of points
    Line,
}

/// General data for a movement path
#[derive(Debug)]
pub struct PathDataMovement {}

/// General data for a moving platform path
#[derive(Debug)]
pub struct PathDataMovingPlatform {
    /// Unknown field
    pub something: Option<u8>,
    /// Travel sound?
    pub platform_travel_sound: Option<String>,
}

/// Time units for rental time
#[derive(Debug, FromPrimitive, ToPrimitive)]
pub enum PropertyRentalTimeUnit {
    Forever,
    Seconds,
    Minutes,
    Hours,
    Days,
    Weeks,
    Months,
    Years,
}

/// Achievement required to rent a property
#[derive(Debug, FromPrimitive, ToPrimitive)]
pub enum PropertyAchievementRequired {
    None,
    Builder,
    Craftsman,
    SeniorBuilder,
    Journeyman,
    MasterBuilder,
    Architect,
    SeniorArchitect,
    MasterArchitect,
    Visionary,
    Exemplar,
}

/// General data for a property (border) path
#[derive(Debug)]
pub struct PathDataProperty {
    /// Unknown value
    pub value_1: u32,
    /// Rental price
    pub price: u32,
    /// Rental time
    pub rental_time: u32,
    /// World that this property is attached to
    pub associated_map: WorldID,
    /// Unknown value
    pub value_2: u32,
    /// Display name of the property
    pub display_name: String,
    /// Display description
    pub display_description: String,
    /// Unknown value
    pub value_3: u32,
    /// Limit to the number of clones in one instance
    pub clone_limit: u32,
    /// Multiplier for reputation
    pub reputation_multiplier: f32,
    /// Unit for rental time
    pub rental_time_unit: PropertyRentalTimeUnit,
    /// Required achievement
    pub achievement_required: PropertyAchievementRequired,
    /// Coordinate of the player
    pub player_zone_coordinate: Vector3f,
    /// Maximum building height
    pub max_build_height: f32,
}

/// General data for camera path
#[derive(Debug)]
pub struct PathDataCamera {
    /// Following path
    pub next_path: String,
    /// Unknown
    pub value_1: Option<u8>,
}

/// General data for a spawner path
#[derive(Debug)]
pub struct PathDataSpawner {
    /// The object to be spawned
    pub spawned_lot: ObjectTemplate,
    /// Time until respawn
    pub respawn_time: u32,
    /// max to spawn (MAX_VALUE for infinity)
    pub max_to_spawn: u32,
    /// number to maintain spawned
    pub min_to_spawn: u32,
    /// Spawner object ID without flags
    pub spawner_obj_id: ObjectID,
    /// Activate network on load
    pub activate_network_on_load: bool,
}

/// General data for a showcase path
#[derive(Debug)]
pub struct PathDataShowcase {}

/// General data for a race path
#[derive(Debug)]
pub struct PathDataRace {}

/// General data for a rail path
#[derive(Debug)]
pub struct PathDataRail {}

/// Data for a movement path waypoint
#[derive(Debug)]
pub struct PathWaypointDataMovement {
    pub config: WaypointConfig,
}

/// Sounds for a moving platform
#[derive(Debug)]
pub struct PathWaypointDataMovingPlatformSounds {
    pub arrive_sound: String,
    pub depart_sound: String,
}

/// Data for a moving platform path waypoint
#[derive(Debug)]
pub struct PathWaypointDataMovingPlatform {
    pub rotation: Quaternion,
    pub lock_player: bool,
    pub speed: f32,
    pub wait: f32,
    pub sounds: Option<PathWaypointDataMovingPlatformSounds>,
}

/// Data for a property (border) path waypoint
#[derive(Debug)]
pub struct PathWaypointDataProperty {}

/// Data for a camera path waypoint
#[derive(Debug)]
pub struct PathWaypointDataCamera {
    pub value_1: f32,
    pub value_2: f32,
    pub value_3: f32,
    pub value_4: f32,
    pub time: f32,
    pub value_5: f32,
    pub tension: f32,
    pub continuity: f32,
    pub bias: f32,
}

/// Data for a spawner network waypoint
#[derive(Debug)]
pub struct PathWaypointDataSpawner {
    pub rotation: Quaternion,
    pub config: WaypointConfig,
}

/// Data for a showcase path waypoint
#[derive(Debug)]
pub struct PathWaypointDataShowcase {}

/// Data for a race path waypoint
#[derive(Debug)]
pub struct PathWaypointDataRace {
    pub rotation: Quaternion,
    pub value_1: u8,
    pub value_2: u8,
    pub value_3: f32,
    pub value_4: f32,
    pub value_5: f32,
}

/// Data for a rail path waypoint
#[derive(Debug)]
pub struct PathWaypointDataRail {
    pub value_1: f32,
    pub value_2: f32,
    pub value_3: f32,
    pub value_4: f32,
    pub config: WaypointConfig,
}

/// Config for a waypoint
pub type WaypointConfig = HashMap<String, String>;

/// Path Waypoint
#[derive(Debug)]
pub struct PathWaypointVariant<WaypointType> {
    pub position: Vector3f,
    pub data: WaypointType,
}

pub type PathWaypointVariantMovement        = PathWaypointVariant<PathWaypointDataMovement>;
pub type PathWaypointVariantMovingPlatform  = PathWaypointVariant<PathWaypointDataMovingPlatform>;
pub type PathWaypointVariantProperty        = PathWaypointVariant<PathWaypointDataProperty>;
pub type PathWaypointVariantCamera          = PathWaypointVariant<PathWaypointDataCamera>;
pub type PathWaypointVariantSpawner         = PathWaypointVariant<PathWaypointDataSpawner>;
pub type PathWaypointVariantShowcase        = PathWaypointVariant<PathWaypointDataShowcase>;
pub type PathWaypointVariantRace            = PathWaypointVariant<PathWaypointDataRace>;
pub type PathWaypointVariantRail            = PathWaypointVariant<PathWaypointDataRail>;

/// Common header for all paths
#[derive(Debug)]
pub struct PathHeader {
    pub version: PathVersion,
    pub path_name: String,
    pub value_1: u32,
    pub path_composition: PathComposition,
}

/// Wrapper for all general path data
#[derive(Debug)]
pub struct PathVariant<DataType, WaypointDataType> {
    pub header: PathHeader,
    pub path_data: DataType,
    pub waypoints: Vec<PathWaypointVariant<WaypointDataType>>
}

pub type PathVariantMovement        = PathVariant<PathDataMovement,         PathWaypointDataMovement>;
pub type PathVariantMovingPlatform  = PathVariant<PathDataMovingPlatform,   PathWaypointDataMovingPlatform>;
pub type PathVariantProperty        = PathVariant<PathDataProperty,         PathWaypointDataProperty>;
pub type PathVariantCamera          = PathVariant<PathDataCamera,           PathWaypointDataCamera>;
pub type PathVariantSpawner         = PathVariant<PathDataSpawner,          PathWaypointDataSpawner>;
pub type PathVariantShowcase        = PathVariant<PathDataShowcase,         PathWaypointDataShowcase>;
pub type PathVariantRace            = PathVariant<PathDataRace,             PathWaypointDataRace>;
pub type PathVariantRail            = PathVariant<PathDataRail,             PathWaypointDataRail>;

/// Enum of all path variants
#[derive(Debug)]
pub enum Path {
    Movement(PathVariantMovement),
    MovingPlatform(PathVariantMovingPlatform),
    Property(PathVariantProperty),
    Camera(PathVariantCamera),
    Spawner(PathVariantSpawner),
    Showcase(PathVariantShowcase),
    Race(PathVariantRace),
    Rail(PathVariantRail),
}

/// All paths in a zone
#[derive(Debug)]
pub struct ZonePaths {
    pub version: ZonePathsVersion,
    pub paths: Vec<Path>,
}