implement command suitmod
(same as armodel
but always visible)
This commit is contained in:
parent
6e1b8d4502
commit
2a48a718b6
21
src/cmd.rs
21
src/cmd.rs
|
@ -128,6 +128,7 @@ struct ParserState {
|
|||
light_brightness: f32,
|
||||
light_color: Option<Color>,
|
||||
ar_models: Vec<String>,
|
||||
suit_mod_models: Vec<String>,
|
||||
show_only_in_map_at_distance: Option<(f64, String)>,
|
||||
}
|
||||
impl Default for ParserState {
|
||||
|
@ -191,6 +192,7 @@ impl Default for ParserState {
|
|||
light_brightness: 0.0,
|
||||
light_color: None,
|
||||
ar_models: vec![],
|
||||
suit_mod_models: vec![],
|
||||
show_only_in_map_at_distance: None,
|
||||
}
|
||||
}
|
||||
|
@ -699,6 +701,9 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
|
|||
["armodel", asset_name] => {
|
||||
state.ar_models.push(asset_name.to_string());
|
||||
}
|
||||
["suitmod", asset_name] => {
|
||||
state.suit_mod_models.push(asset_name.to_string());
|
||||
}
|
||||
["targeted", "yes"] => {
|
||||
state.is_targeted_on_startup = true;
|
||||
}
|
||||
|
@ -1599,6 +1604,7 @@ fn spawn_entities(
|
|||
hud::AugmentedRealityOverlay {
|
||||
owner: actor_entity,
|
||||
scale: 1.0,
|
||||
always_visible: false,
|
||||
},
|
||||
world::DespawnOnPlayerDeath,
|
||||
SpatialBundle {
|
||||
|
@ -1610,6 +1616,21 @@ fn spawn_entities(
|
|||
load_asset(ar_asset_name.as_str(), &mut entitycmd, &*asset_server);
|
||||
}
|
||||
|
||||
for ar_asset_name in &state.suit_mod_models {
|
||||
let mut entitycmd = commands.spawn((
|
||||
hud::AugmentedRealityOverlay {
|
||||
owner: actor_entity,
|
||||
scale: 1.0,
|
||||
always_visible: true,
|
||||
},
|
||||
world::DespawnOnPlayerDeath,
|
||||
SpatialBundle {
|
||||
..default()
|
||||
},
|
||||
));
|
||||
load_asset(ar_asset_name.as_str(), &mut entitycmd, &*asset_server);
|
||||
}
|
||||
|
||||
if state.is_point_of_interest || state.is_moon || state.is_planet {
|
||||
let mut entitycmd = commands.spawn((
|
||||
hud::PointOfInterestMarker(actor_entity),
|
||||
|
|
56
src/hud.rs
56
src/hud.rs
|
@ -105,9 +105,6 @@ impl Plugin for HudPlugin {
|
|||
.before(TransformSystem::TransformPropagate),
|
||||
),
|
||||
);
|
||||
app.insert_resource(AugmentedRealityState {
|
||||
overlays_visible: false,
|
||||
});
|
||||
app.insert_resource(Log {
|
||||
logs: VecDeque::with_capacity(LOG_MAX),
|
||||
needs_rerendering: true,
|
||||
|
@ -180,17 +177,13 @@ enum Gauge {
|
|||
//Integrity,
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
pub struct AugmentedRealityState {
|
||||
pub overlays_visible: bool,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct AugmentedRealityOverlayBroadcaster;
|
||||
#[derive(Component)]
|
||||
pub struct AugmentedRealityOverlay {
|
||||
pub owner: Entity,
|
||||
pub scale: f32,
|
||||
pub always_visible: bool,
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
|
@ -1230,40 +1223,24 @@ fn update_ar_overlays(
|
|||
Without<AugmentedRealityOverlay>,
|
||||
),
|
||||
>,
|
||||
mut q_overlays: Query<(
|
||||
&mut Transform,
|
||||
&mut Visibility,
|
||||
&AugmentedRealityOverlay,
|
||||
)>,
|
||||
mut q_overlays: Query<(&mut Transform, &mut Visibility, &AugmentedRealityOverlay)>,
|
||||
settings: ResMut<Settings>,
|
||||
mut state: ResMut<AugmentedRealityState>,
|
||||
) {
|
||||
let (need_activate, need_clean, need_update);
|
||||
if settings.hud_active {
|
||||
need_activate = !state.overlays_visible;
|
||||
need_clean = false;
|
||||
} else {
|
||||
need_activate = false;
|
||||
need_clean = state.overlays_visible;
|
||||
}
|
||||
need_update = settings.hud_active;
|
||||
state.overlays_visible = settings.hud_active;
|
||||
|
||||
if need_update || need_clean || need_activate {
|
||||
for (mut trans, mut vis, ar) in &mut q_overlays {
|
||||
for (owner_id, owner_trans, owner_vis) in &q_owners {
|
||||
if owner_id == ar.owner {
|
||||
*trans = *owner_trans;
|
||||
if ar.scale != 1.0 {
|
||||
trans.scale *= ar.scale;
|
||||
}
|
||||
if need_clean {
|
||||
*vis = Visibility::Hidden;
|
||||
} else {
|
||||
*vis = *owner_vis;
|
||||
}
|
||||
break;
|
||||
for (mut trans, mut vis, ar) in &mut q_overlays {
|
||||
if !ar.always_visible && !settings.hud_active {
|
||||
*vis = Visibility::Hidden;
|
||||
continue;
|
||||
}
|
||||
for (owner_id, owner_trans, owner_vis) in &q_owners {
|
||||
if owner_id == ar.owner {
|
||||
*trans = *owner_trans;
|
||||
if ar.scale != 1.0 {
|
||||
trans.scale *= ar.scale;
|
||||
}
|
||||
if ar.always_visible || settings.hud_active {
|
||||
*vis = *owner_vis;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1408,6 +1385,7 @@ fn update_avatar(
|
|||
hud::AugmentedRealityOverlay {
|
||||
owner: player_entity,
|
||||
scale: model_scale,
|
||||
always_visible: false,
|
||||
},
|
||||
world::DespawnOnPlayerDeath,
|
||||
PlayerAvatar,
|
||||
|
|
Loading…
Reference in a new issue