implement retrograde motion marker
This commit is contained in:
parent
07de91e51f
commit
cde59dcdd0
7 changed files with 61 additions and 1 deletions
assets/models
src
BIN
assets/models/marker_motion_retrograde.glb
Normal file
BIN
assets/models/marker_motion_retrograde.glb
Normal file
Binary file not shown.
|
@ -172,6 +172,13 @@ impl Default for ExperiencesGForce {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Component, Default)]
|
||||
pub struct MatchingVelocity {
|
||||
pub entity: Option<Entity>,
|
||||
pub pos: Option<DVec3>,
|
||||
pub v: DVec3,
|
||||
}
|
||||
|
||||
#[derive(Component, Default)]
|
||||
pub struct WantsAcceleration {
|
||||
pub direction: DVec3,
|
||||
|
|
BIN
src/blender/marker_motion_retrograde.blend
Normal file
BIN
src/blender/marker_motion_retrograde.blend
Normal file
Binary file not shown.
|
@ -1513,6 +1513,7 @@ fn spawn_entities(
|
|||
actor.insert(actor::ExperiencesAtmosphere);
|
||||
}
|
||||
if state.is_player || state.is_vehicle {
|
||||
actor.insert(MatchingVelocity::default());
|
||||
// previously used to apply mouse movement to actor rotation, but currently unused
|
||||
actor.insert(ExternalTorque::ZERO.with_persistence(false));
|
||||
}
|
||||
|
|
52
src/hud.rs
52
src/hud.rs
|
@ -102,6 +102,11 @@ impl Plugin for HudPlugin {
|
|||
.after(PhysicsSet::Sync)
|
||||
.after(camera::apply_input_to_player)
|
||||
.before(TransformSystem::TransformPropagate),
|
||||
update_motion_marker
|
||||
.run_if(game_running)
|
||||
.after(PhysicsSet::Sync)
|
||||
.after(camera::apply_input_to_player)
|
||||
.before(TransformSystem::TransformPropagate),
|
||||
),
|
||||
);
|
||||
app.insert_resource(Log {
|
||||
|
@ -156,6 +161,8 @@ pub struct ToggleableHudMapElement;
|
|||
#[derive(Component)]
|
||||
struct Selectagon;
|
||||
#[derive(Component)]
|
||||
struct MarkerMotionRetrograde;
|
||||
#[derive(Component)]
|
||||
struct PlayerAvatar;
|
||||
#[derive(Component)]
|
||||
pub struct IsTargeted;
|
||||
|
@ -798,6 +805,23 @@ pub fn setup(
|
|||
));
|
||||
load_asset("selectagon", &mut entitycmd, &*asset_server);
|
||||
|
||||
// Retrograde Motion Marker
|
||||
let mut entitycmd = commands.spawn((
|
||||
MarkerMotionRetrograde,
|
||||
NotShadowCaster,
|
||||
NotShadowReceiver,
|
||||
IsClickable {
|
||||
name: Some("Retrograde Motion Marker".to_string()),
|
||||
..default()
|
||||
},
|
||||
SpatialBundle {
|
||||
visibility: Visibility::Hidden,
|
||||
transform: Transform::from_scale(Vec3::splat(0.05)),
|
||||
..default()
|
||||
},
|
||||
));
|
||||
load_asset("marker_motion_retrograde", &mut entitycmd, &*asset_server);
|
||||
|
||||
ew_updateoverlays.send(UpdateOverlayVisibility);
|
||||
}
|
||||
|
||||
|
@ -1028,7 +1052,6 @@ fn update_hud(
|
|||
target_multiple = true;
|
||||
target = None;
|
||||
} else {
|
||||
target_error = true;
|
||||
target = None;
|
||||
}
|
||||
if let Some(target_pos) = target {
|
||||
|
@ -1313,6 +1336,33 @@ fn update_target_selectagon(
|
|||
}
|
||||
}
|
||||
|
||||
fn update_motion_marker(
|
||||
settings: Res<Settings>,
|
||||
q_player: Query<(&Transform, &LinearVelocity, &MatchingVelocity), With<actor::PlayerCamera>>,
|
||||
mut q_retrograde: Query<
|
||||
(&mut Transform, &mut Visibility),
|
||||
(With<MarkerMotionRetrograde>, Without<actor::PlayerCamera>),
|
||||
>,
|
||||
) {
|
||||
if let Ok((mut trans, mut vis)) = q_retrograde.get_single_mut() {
|
||||
if settings.hud_active && !settings.third_person {
|
||||
if let Ok((player_trans, player_v, player_mv)) = q_player.get_single() {
|
||||
let dv = player_v.0 - player_mv.v;
|
||||
if dv.length() > 1.0 {
|
||||
*vis = Visibility::Inherited;
|
||||
trans.translation =
|
||||
player_trans.translation - (dv.as_vec3().normalize() * 2.0);
|
||||
trans.look_at(player_trans.translation, player_trans.up());
|
||||
} else {
|
||||
*vis = Visibility::Hidden;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
*vis = Visibility::Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn update_ar_overlays(
|
||||
q_owners: Query<
|
||||
(Entity, &Transform, &Visibility),
|
||||
|
|
|
@ -73,6 +73,7 @@ pub fn asset_name_to_path(name: &str) -> &'static str {
|
|||
"marker_planets" => "models/marker_planets.glb#Scene0",
|
||||
"marker_player" => "models/marker_player.glb#Scene0",
|
||||
"marker_race" => "models/marker_race.glb#Scene0",
|
||||
"marker_motion_retrograde" => "models/marker_motion_retrograde.glb#Scene0",
|
||||
"point_of_interest" => "models/point_of_interest.glb#Scene0",
|
||||
"metis" => "models/metis.gltf#Scene0",
|
||||
"thebe" => "models/thebe.gltf#Scene0",
|
||||
|
|
|
@ -34,6 +34,7 @@ pub mod prelude {
|
|||
pub use crate::{
|
||||
actor, audio, camera, chat, cmd, common, game, hud, load, menu, nature, var, visual, world,
|
||||
};
|
||||
pub use actor::MatchingVelocity;
|
||||
pub use game::Cycle::Next;
|
||||
pub use game::Turn::Toggle;
|
||||
pub use game::{GameEvent, Turn};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue