fix velocity after traveling with busses

This commit is contained in:
yuni 2024-06-11 02:54:13 +02:00
parent 3d26b0915d
commit 4dd195e17a

View file

@ -827,6 +827,7 @@ pub fn handle_chat_scripts(
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
mut ew_achievement: EventWriter<game::AchievementEvent>,
id2pos: Res<game::Id2Pos>,
id2v: Res<game::Id2V>,
) {
for script in er_chatscript.read() {
// Parse the script string
@ -892,15 +893,22 @@ pub fn handle_chat_scripts(
_ => None,
};
if let Some(station) = busstop {
if let Some(target) = id2pos.0.get(&station.to_string()) {
pos.0 = *target + DVec3::new(0.0, -1000.0, 0.0);
v.0 = DVec3::ZERO;
if let Some(target_pos) = id2pos.0.get(&station.to_string()) {
pos.0 = *target_pos + DVec3::new(0.0, -1000.0, 0.0);
} else {
error!(
"Could not determine position of actor with ID: '{}'",
station
);
}
if let Some(target_v) = id2v.0.get(&station.to_string()) {
v.0 = *target_v;
} else {
error!(
"Could not determine velocity of actor with ID: '{}'",
station
);
}
} else {
error!("Invalid destination for cryotrip chat script: '{}'", param1);
}