diff options
| author | Valentin Popov <valentin@popov.link> | 2026-07-18 19:56:34 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-07-18 19:56:34 +0300 |
| commit | 9dcf6d456e0c2e06d45be001874ac72d7911703e (patch) | |
| tree | d53358e84632fe132fad8298a54a7aeb48adb31b /crates/fparkan-assets | |
| parent | 3592b46b0ffa31d1b09fd9503e87e00af616ab28 (diff) | |
| download | fparkan-9dcf6d456e0c2e06d45be001874ac72d7911703e.tar.xz fparkan-9dcf6d456e0c2e06d45be001874ac72d7911703e.zip | |
feat(runtime): load mission script bundles
Diffstat (limited to 'crates/fparkan-assets')
| -rw-r--r-- | crates/fparkan-assets/src/lib.rs | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/crates/fparkan-assets/src/lib.rs b/crates/fparkan-assets/src/lib.rs index 2dc9ef5..708993f 100644 --- a/crates/fparkan-assets/src/lib.rs +++ b/crates/fparkan-assets/src/lib.rs @@ -24,7 +24,7 @@ use fparkan_material::{ decode_wear, resolve_material, Mat0Document, MaterialError, ResolvedMaterial, WearTable, MAT0_KIND, WEAR_KIND, }; -use fparkan_mission_format::{decode_tma, decode_tma_land_path}; +use fparkan_mission_format::{decode_tma, decode_tma_land_path, ClanBody}; pub use fparkan_mission_format::{LpString, MissionDocument, MissionError, TmaProfile}; use fparkan_msh::{decode_msh, validate_msh, ModelAsset, MshError}; use fparkan_nres::{decode as decode_nres, ReadProfile}; @@ -63,6 +63,17 @@ pub struct MissionTerrainPaths { pub land_map: NormalizedPath, } +/// Raw compiled-script base selected by one TMA clan. +/// +/// The path remains raw legacy bytes until the runtime applies its path policy. +#[derive(Clone, Debug, Eq, PartialEq)] +pub struct MissionScriptBundleBase { + /// Index in the mission clan array. + pub clan_index: usize, + /// First clan resource path, without a required `.scr` suffix. + pub path_raw: Vec<u8>, +} + /// Terrain loading errors that include runtime world construction failures. #[derive(Debug)] pub enum TerrainPreparationError { @@ -121,6 +132,29 @@ pub fn decode_mission_land_path( decode_tma_land_path(bytes, profile) } +/// Returns non-empty script/formula bases selected by TMA clans. +/// +/// The first resource has the same position in the standard and spatial clan +/// layouts. Its consumer-specific meaning is intentionally left to runtime. +#[must_use] +pub fn mission_script_bundle_bases(mission: &MissionDocument) -> Vec<MissionScriptBundleBase> { + mission + .clans + .iter() + .enumerate() + .filter_map(|(clan_index, clan)| { + let path_raw = match &clan.body { + ClanBody::Standard { first_resource, .. } => first_resource.path.raw.clone(), + ClanBody::Spatial { first_resource, .. } => first_resource.raw.clone(), + }; + (!path_raw.is_empty()).then_some(MissionScriptBundleBase { + clan_index, + path_raw, + }) + }) + .collect() +} + /// Builds canonical mission terrain paths from the mission `Land` reference. /// /// # Errors |
