Compare commits

...

2 commits

5 changed files with 31 additions and 9 deletions

View file

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

View file

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

View file

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

View file

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

View file

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