Compare commits

...

2 commits

5 changed files with 31 additions and 9 deletions

View file

@ -158,6 +158,8 @@ pub struct ActorEnteringVehicle;
#[derive(Component)] #[derive(Component)]
pub struct ActorVehicleBeingEntered; pub struct ActorVehicleBeingEntered;
#[derive(Component)] #[derive(Component)]
pub struct MessageOnVehicleEntry(pub String);
#[derive(Component)]
pub struct PlayersFlashLight; pub struct PlayersFlashLight;
#[derive(Component)] #[derive(Component)]
pub struct WantsMaxRotation(pub f64); pub struct WantsMaxRotation(pub f64);
@ -422,7 +424,7 @@ pub fn handle_input(
q_camera: Query<&Transform, With<Camera>>, q_camera: Query<&Transform, With<Camera>>,
mut q_flashlight: Query<&mut Visibility, With<PlayersFlashLight>>, mut q_flashlight: Query<&mut Visibility, With<PlayersFlashLight>>,
q_vehicles: Query< q_vehicles: Query<
(Entity, &Actor, &Transform), (Entity, &Actor, &Transform, Option<&MessageOnVehicleEntry>),
( (
With<actor::Vehicle>, With<actor::Vehicle>,
Without<actor::Player>, Without<actor::Player>,
@ -432,6 +434,7 @@ pub fn handle_input(
mut ew_conv: EventWriter<chat::StartConversationEvent>, mut ew_conv: EventWriter<chat::StartConversationEvent>,
mut ew_vehicle: EventWriter<VehicleEnterExitEvent>, mut ew_vehicle: EventWriter<VehicleEnterExitEvent>,
mut ew_sfx: EventWriter<audio::PlaySfxEvent>, mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
mut log: ResMut<hud::Log>,
q_player_drives: Query<Entity, With<PlayerDrivesThis>>, q_player_drives: Query<Entity, With<PlayerDrivesThis>>,
) { ) {
if q_camera.is_empty() || player.is_empty() { if q_camera.is_empty() || player.is_empty() {
@ -457,12 +460,18 @@ pub fn handle_input(
} }
// Entering Vehicles // Entering Vehicles
if q_player_drives.is_empty() { if q_player_drives.is_empty() {
let objects: Vec<((Entity, &Actor), &Transform)> = q_vehicles // Sort vehicles by their distance to the player
let objects: Vec<((Entity, &Actor, Option<&MessageOnVehicleEntry>), &Transform)> =
q_vehicles
.iter() .iter()
.map(|(entity, actor, transform)| ((entity, actor), transform)) .map(|(entity, actor, transform, msg)| ((entity, actor, msg), transform))
.collect(); .collect();
if let (Some((entity, actor)), dist) =
camera::find_closest_target::<(Entity, &Actor)>(objects, camtrans) // Get the vehicle with shortest distance
if let (Some((entity, actor, msg)), dist) =
camera::find_closest_target::<(Entity, &Actor, Option<&MessageOnVehicleEntry>)>(
objects, camtrans,
)
{ {
if dist <= MAX_INTERACT_DISTANCE { if dist <= MAX_INTERACT_DISTANCE {
commands.entity(entity).insert(ActorVehicleBeingEntered); commands.entity(entity).insert(ActorVehicleBeingEntered);
@ -474,6 +483,9 @@ pub fn handle_input(
is_entering: q_player_drives.is_empty(), is_entering: q_player_drives.is_empty(),
is_player: true, is_player: true,
}); });
if let Some(msg) = msg {
log.warning(msg.0.clone());
}
} }
} }
} }

View file

@ -79,6 +79,7 @@ struct ParserState {
velocity: DVec3, velocity: DVec3,
angular_momentum: DVec3, angular_momentum: DVec3,
pronoun: Option<String>, pronoun: Option<String>,
message_on_entry: Option<String>,
is_sphere: bool, is_sphere: bool,
is_player: bool, is_player: bool,
is_lifeform: bool, is_lifeform: bool,
@ -138,6 +139,7 @@ impl Default for ParserState {
velocity: DVec3::splat(0.0), velocity: DVec3::splat(0.0),
angular_momentum: DVec3::new(0.03, 0.3, 0.09), angular_momentum: DVec3::new(0.03, 0.3, 0.09),
pronoun: None, pronoun: None,
message_on_entry: None,
is_sphere: false, is_sphere: false,
is_player: false, is_player: false,
is_lifeform: false, is_lifeform: false,
@ -683,6 +685,9 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
continue; continue;
} }
} }
["message_on_entry", message] => {
state.message_on_entry = Some(message.to_string());
}
_ => { _ => {
error!("No match for [{}]", parts.join(",")); error!("No match for [{}]", parts.join(","));
} }
@ -895,6 +900,9 @@ fn spawn_entities(
if orbits_jupiter { if orbits_jupiter {
actor.insert(actor::OrbitsJupiter); actor.insert(actor::OrbitsJupiter);
} }
if let Some(message) = &state.message_on_entry {
actor.insert(actor::MessageOnVehicleEntry(message.clone()));
}
actor.insert(world::DespawnOnPlayerDeath); actor.insert(world::DespawnOnPlayerDeath);
actor.insert(actor::HitPoints::default()); actor.insert(actor::HitPoints::default());
actor.insert(Position::from(absolute_pos)); actor.insert(Position::from(absolute_pos));

View file

@ -298,7 +298,7 @@ actor 700 -100 -1100 suitv2
scene 22 0 0 workshop scene 22 0 0 workshop
relativeto Luna relativeto Luna
actor -20 10 -23 MeteorAceGT actor -20 10 -23 MeteorAceGT
name "MeteorAceGT" name "Luna's experimental MeteorAceGT"
relativeto Luna relativeto Luna
scale 5 scale 5
vehicle yes vehicle yes
@ -309,6 +309,7 @@ actor 700 -100 -1100 suitv2
density 500 density 500
angularmomentum 0 0 0.2 angularmomentum 0 0 0.2
pointofinterest yes pointofinterest yes
message_on_entry "NOT DESIGNED FOR HUMAN USE"
actor -9 4 11 lightorb actor -9 4 11 lightorb
relativeto Luna relativeto Luna
name "Light Orb" name "Light Orb"

View file

@ -942,6 +942,7 @@ fn update_hud(
} else { } else {
|msg: &&Message| match msg.level { |msg: &&Message| match msg.level {
LogLevel::Always => true, LogLevel::Always => true,
LogLevel::Warning => true,
LogLevel::Achievement => true, LogLevel::Achievement => true,
_ => false, _ => false,
} }

View file

@ -527,7 +527,7 @@ pub fn update_menu(
let state = match settings.reactor_state { let state = match settings.reactor_state {
0 => "Off", 0 => "Off",
1 => "On", 1 => "On",
2 => "OVERLOAD", 2 => "OVERLOAD",
_ => "ERROR", _ => "ERROR",
}; };
let p = actor::POWER_GAIN_REACTOR[settings.reactor_state]; let p = actor::POWER_GAIN_REACTOR[settings.reactor_state];