From f3e70cef15d368d8a956d8512df6681bed93b1b3 Mon Sep 17 00:00:00 2001 From: yuni Date: Tue, 5 Nov 2024 05:27:36 +0100 Subject: [PATCH] allow arbitrary number of ar avatars for npcs --- src/cmd.rs | 56 +++++------------------------------------------ src/data/defs.txt | 6 ++--- 2 files changed, 9 insertions(+), 53 deletions(-) diff --git a/src/cmd.rs b/src/cmd.rs index f075274..c514f8b 100644 --- a/src/cmd.rs +++ b/src/cmd.rs @@ -126,9 +126,7 @@ struct ParserState { suit_integrity: f32, light_brightness: f32, light_color: Option, - ar_model: Option, - ar_model2: Option, - ar_model3: Option, + ar_models: Vec, show_only_in_map_at_distance: Option<(f64, String)>, } impl Default for ParserState { @@ -190,9 +188,7 @@ impl Default for ParserState { suit_integrity: 1.0, light_brightness: 0.0, light_color: None, - ar_model: None, - ar_model2: None, - ar_model3: None, + ar_models: vec![], show_only_in_map_at_distance: None, } } @@ -693,13 +689,7 @@ pub fn load_defs(mut ew_spawn: EventWriter) { state.wants_matchvelocity_id = Some(id.to_string()); } ["armodel", asset_name] => { - state.ar_model = Some(asset_name.to_string()); - } - ["armodel_secondary", asset_name] => { - state.ar_model2 = Some(asset_name.to_string()); - } - ["armodel_tertiary", asset_name] => { - state.ar_model3 = Some(asset_name.to_string()); + state.ar_models.push(asset_name.to_string()); } ["targeted", "yes"] => { state.is_targeted_on_startup = true; @@ -1246,7 +1236,7 @@ fn spawn_entities( ..default() }); } - if let Some(_) = state.ar_model { + if !state.ar_models.is_empty() { actor.insert(hud::AugmentedRealityOverlayBroadcaster); } if state.is_player { @@ -1277,7 +1267,7 @@ fn spawn_entities( } actor_entity = actor.id(); - if let Some(ar_asset_name) = &state.ar_model { + for ar_asset_name in &state.ar_models { let mut entitycmd = commands.spawn(( hud::AugmentedRealityOverlay { owner: actor_entity, @@ -1291,41 +1281,7 @@ fn spawn_entities( NotShadowCaster, NotShadowReceiver, )); - load_asset(ar_asset_name, &mut entitycmd, &*asset_server); - } - - if let Some(ar_asset_name) = &state.ar_model2 { - let mut entitycmd = commands.spawn(( - hud::AugmentedRealityOverlay { - owner: actor_entity, - scale: 1.0, - }, - world::DespawnOnPlayerDeath, - SpatialBundle { - visibility: Visibility::Hidden, - ..default() - }, - NotShadowCaster, - NotShadowReceiver, - )); - load_asset(ar_asset_name, &mut entitycmd, &*asset_server); - } - - if let Some(ar_asset_name) = &state.ar_model3 { - let mut entitycmd = commands.spawn(( - hud::AugmentedRealityOverlay { - owner: actor_entity, - scale: 1.0, - }, - world::DespawnOnPlayerDeath, - SpatialBundle { - visibility: Visibility::Hidden, - ..default() - }, - NotShadowCaster, - NotShadowReceiver, - )); - load_asset(ar_asset_name, &mut entitycmd, &*asset_server); + load_asset(ar_asset_name.as_str(), &mut entitycmd, &*asset_server); } if state.is_point_of_interest || state.is_moon || state.is_planet { diff --git a/src/data/defs.txt b/src/data/defs.txt index f43cc34..2e8148d 100644 --- a/src/data/defs.txt +++ b/src/data/defs.txt @@ -335,8 +335,8 @@ actor 700 -100 -1100 suitv2 id Luna chatid Luna armodel suit_ar_skirt - armodel_secondary suit_ar_nekomimi - armodel_tertiary suit_ar_bra + armodel suit_ar_nekomimi + armodel suit_ar_bra angularmomentum 0 0 0 wants maxrotation 0 wants matchvelocitywith lunaplatform @@ -366,7 +366,7 @@ actor -55e3 31e3 0 suitv2 name "Yuni" chatid Yuni armodel suit_ar_skirt - armodel_secondary suit_ar_hoodie + armodel suit_ar_hoodie rotationx 180 rotationy 90 wants matchvelocitywith thebe