add "targeted yes" command

This commit is contained in:
yuni 2024-04-16 15:55:37 +02:00
parent 4d4ccb9d9f
commit fd16d6931e

View file

@ -49,6 +49,7 @@ struct ParserState {
is_suited: bool,
is_vehicle: bool,
is_clickable: bool,
is_targeted_on_startup: bool,
has_physics: bool,
wants_maxrotation: Option<f64>,
wants_maxvelocity: Option<f64>,
@ -93,6 +94,7 @@ impl Default for ParserState {
is_suited: false,
is_vehicle: false,
is_clickable: true,
is_targeted_on_startup: false,
has_physics: true,
wants_maxrotation: None,
wants_maxvelocity: None,
@ -186,6 +188,7 @@ pub fn load_defs(
["relativeto", id] => {
// NOTE: call this command before "id", otherwise actors that
// set their position relative to this actor will get the wrong offset
// TODO: fix the above
match id2pos.get(&id.to_string()) {
Some(pos) => {
state.pos += *pos;
@ -419,6 +422,9 @@ pub fn load_defs(
["armodel", asset_name] => {
state.ar_model = Some(asset_name.to_string());
}
["targeted", "yes"] => {
state.is_targeted_on_startup = true;
}
_ => {
error!("No match for [{}]", parts.join(","));
}
@ -514,6 +520,9 @@ fn spawn_entities(
actor.insert(actor::Player);
actor.insert(actor::PlayerCamera);
}
if state.is_targeted_on_startup {
actor.insert(hud::IsTargeted);
}
if state.is_player || state.is_vehicle {
// used to apply mouse movement to actor rotation
actor.insert(ExternalTorque::ZERO.with_persistence(false));