allow arbitrary number of ar avatars for npcs

This commit is contained in:
yuni 2024-11-05 05:27:36 +01:00
parent c195e91bef
commit f3e70cef15
2 changed files with 9 additions and 53 deletions

View file

@ -126,9 +126,7 @@ struct ParserState {
suit_integrity: f32, suit_integrity: f32,
light_brightness: f32, light_brightness: f32,
light_color: Option<Color>, light_color: Option<Color>,
ar_model: Option<String>, ar_models: Vec<String>,
ar_model2: Option<String>,
ar_model3: Option<String>,
show_only_in_map_at_distance: Option<(f64, String)>, show_only_in_map_at_distance: Option<(f64, String)>,
} }
impl Default for ParserState { impl Default for ParserState {
@ -190,9 +188,7 @@ impl Default for ParserState {
suit_integrity: 1.0, suit_integrity: 1.0,
light_brightness: 0.0, light_brightness: 0.0,
light_color: None, light_color: None,
ar_model: None, ar_models: vec![],
ar_model2: None,
ar_model3: None,
show_only_in_map_at_distance: None, show_only_in_map_at_distance: None,
} }
} }
@ -693,13 +689,7 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
state.wants_matchvelocity_id = Some(id.to_string()); state.wants_matchvelocity_id = Some(id.to_string());
} }
["armodel", asset_name] => { ["armodel", asset_name] => {
state.ar_model = Some(asset_name.to_string()); state.ar_models.push(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());
} }
["targeted", "yes"] => { ["targeted", "yes"] => {
state.is_targeted_on_startup = true; state.is_targeted_on_startup = true;
@ -1246,7 +1236,7 @@ fn spawn_entities(
..default() ..default()
}); });
} }
if let Some(_) = state.ar_model { if !state.ar_models.is_empty() {
actor.insert(hud::AugmentedRealityOverlayBroadcaster); actor.insert(hud::AugmentedRealityOverlayBroadcaster);
} }
if state.is_player { if state.is_player {
@ -1277,7 +1267,7 @@ fn spawn_entities(
} }
actor_entity = actor.id(); 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(( let mut entitycmd = commands.spawn((
hud::AugmentedRealityOverlay { hud::AugmentedRealityOverlay {
owner: actor_entity, owner: actor_entity,
@ -1291,41 +1281,7 @@ fn spawn_entities(
NotShadowCaster, NotShadowCaster,
NotShadowReceiver, NotShadowReceiver,
)); ));
load_asset(ar_asset_name, &mut entitycmd, &*asset_server); load_asset(ar_asset_name.as_str(), &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);
} }
if state.is_point_of_interest || state.is_moon || state.is_planet { if state.is_point_of_interest || state.is_moon || state.is_planet {

View file

@ -335,8 +335,8 @@ actor 700 -100 -1100 suitv2
id Luna id Luna
chatid Luna chatid Luna
armodel suit_ar_skirt armodel suit_ar_skirt
armodel_secondary suit_ar_nekomimi armodel suit_ar_nekomimi
armodel_tertiary suit_ar_bra armodel suit_ar_bra
angularmomentum 0 0 0 angularmomentum 0 0 0
wants maxrotation 0 wants maxrotation 0
wants matchvelocitywith lunaplatform wants matchvelocitywith lunaplatform
@ -366,7 +366,7 @@ actor -55e3 31e3 0 suitv2
name "Yuni" name "Yuni"
chatid Yuni chatid Yuni
armodel suit_ar_skirt armodel suit_ar_skirt
armodel_secondary suit_ar_hoodie armodel suit_ar_hoodie
rotationx 180 rotationx 180
rotationy 90 rotationy 90
wants matchvelocitywith thebe wants matchvelocitywith thebe