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