add "wants norotation" command to satellite and icarus
This commit is contained in:
parent
beb241e9d6
commit
83de08034a
22
src/actor.rs
22
src/actor.rs
|
@ -1,5 +1,6 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_xpbd_3d::prelude::*;
|
||||
use bevy::math::DVec3;
|
||||
use crate::{actor, audio, chat, nature, settings};
|
||||
|
||||
pub const ENGINE_SPEED_FACTOR: f32 = 30.0;
|
||||
|
@ -11,6 +12,7 @@ impl Plugin for ActorPlugin {
|
|||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(FixedUpdate, (
|
||||
update_physics_lifeforms,
|
||||
handle_wants_norotation,
|
||||
));
|
||||
app.add_systems(Update, (
|
||||
handle_input,
|
||||
|
@ -59,6 +61,7 @@ impl Default for Actor {
|
|||
#[derive(Component)] pub struct InConversationWithPlayer;
|
||||
#[derive(Component)] pub struct ActorEnteringVehicle;
|
||||
#[derive(Component)] pub struct ActorVehicleBeingEntered;
|
||||
#[derive(Component)] pub struct WantsNoRotation;
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct LifeForm {
|
||||
|
@ -294,3 +297,22 @@ fn handle_collisions(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_wants_norotation(
|
||||
time: Res<Time>,
|
||||
mut q_v_ang: Query<(&mut AngularVelocity, &Engine), With<WantsNoRotation>>,
|
||||
) {
|
||||
let d = time.delta_seconds();
|
||||
for (mut v_ang, engine) in &mut q_v_ang {
|
||||
let total = v_ang.0.length();
|
||||
if total <= 0.0001 {
|
||||
if total > 0.0 {
|
||||
v_ang.0 = DVec3::splat(0.0);
|
||||
}
|
||||
}
|
||||
else {
|
||||
let angular_slowdown: f64 = (2.0 - engine.reaction_wheels.powf(0.01).clamp(1.001, 1.1)) as f64;
|
||||
v_ang.0 *= angular_slowdown;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ struct ParserState {
|
|||
is_suited: bool,
|
||||
is_vehicle: bool,
|
||||
has_physics: bool,
|
||||
wants_norotation: bool,
|
||||
collider_is_mesh: bool,
|
||||
thrust_forward: f32,
|
||||
thrust_sideways: f32,
|
||||
|
@ -99,6 +100,7 @@ impl Default for ParserState {
|
|||
is_suited: false,
|
||||
is_vehicle: false,
|
||||
has_physics: true,
|
||||
wants_norotation: false,
|
||||
collider_is_mesh: false,
|
||||
thrust_forward: default_engine.thrust_forward,
|
||||
thrust_sideways: default_engine.thrust_forward,
|
||||
|
@ -422,6 +424,9 @@ pub fn load_defs(
|
|||
continue;
|
||||
}
|
||||
}
|
||||
["wants", "norotation"] => {
|
||||
state.wants_norotation = true;
|
||||
}
|
||||
|
||||
// Parsing chats
|
||||
["chat", chat_name] => {
|
||||
|
@ -612,6 +617,9 @@ fn spawn_entities(
|
|||
..default()
|
||||
});
|
||||
}
|
||||
if state.wants_norotation {
|
||||
actor.insert(actor::WantsNoRotation);
|
||||
}
|
||||
if let Some(color) = state.light_color {
|
||||
actor.insert(PointLightBundle {
|
||||
point_light: PointLight {
|
||||
|
|
|
@ -90,6 +90,8 @@ actor 3000 0 0 moonlet
|
|||
actor -200 -110 1000 satellite
|
||||
relativeto player
|
||||
scale 40
|
||||
wants norotation
|
||||
thrust 0 0 0 300 1
|
||||
collider capsule 7.5 1
|
||||
rotationy 0.5
|
||||
angularmomentum 0 0 0
|
||||
|
@ -208,6 +210,8 @@ actor 70 -25 -60 suit
|
|||
mass 200.0
|
||||
collider capsule 2 1
|
||||
angularmomentum 0.1 0.2 0.1
|
||||
thrust 1.2 1 1 3 1.5
|
||||
wants norotation
|
||||
pronoun it
|
||||
chat hi_icarus
|
||||
name Icarus
|
||||
|
|
Loading…
Reference in a new issue