change WantsNo* to WantsMax*, cuz Icarus likes to rotate a bit
This commit is contained in:
parent
64423630da
commit
6b6cdccee7
28
src/actor.rs
28
src/actor.rs
|
@ -12,8 +12,8 @@ impl Plugin for ActorPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(FixedUpdate, (
|
app.add_systems(FixedUpdate, (
|
||||||
update_physics_lifeforms,
|
update_physics_lifeforms,
|
||||||
handle_wants_norotation,
|
handle_wants_maxrotation,
|
||||||
handle_wants_novelocity,
|
handle_wants_maxvelocity,
|
||||||
));
|
));
|
||||||
app.add_systems(Update, (
|
app.add_systems(Update, (
|
||||||
handle_input,
|
handle_input,
|
||||||
|
@ -62,8 +62,8 @@ impl Default for Actor {
|
||||||
#[derive(Component)] pub struct InConversationWithPlayer;
|
#[derive(Component)] pub struct InConversationWithPlayer;
|
||||||
#[derive(Component)] pub struct ActorEnteringVehicle;
|
#[derive(Component)] pub struct ActorEnteringVehicle;
|
||||||
#[derive(Component)] pub struct ActorVehicleBeingEntered;
|
#[derive(Component)] pub struct ActorVehicleBeingEntered;
|
||||||
#[derive(Component)] pub struct WantsNoRotation;
|
#[derive(Component)] pub struct WantsMaxRotation(pub f64);
|
||||||
#[derive(Component)] pub struct WantsNoVelocity;
|
#[derive(Component)] pub struct WantsMaxVelocity(pub f64);
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct LifeForm {
|
pub struct LifeForm {
|
||||||
|
@ -300,16 +300,16 @@ fn handle_collisions(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_wants_norotation(
|
fn handle_wants_maxrotation(
|
||||||
//time: Res<Time>,
|
//time: Res<Time>,
|
||||||
mut q_angularvelocity: Query<(&mut AngularVelocity, &Engine), With<WantsNoRotation>>,
|
mut query: Query<(&mut AngularVelocity, &Engine, &WantsMaxRotation)>,
|
||||||
) {
|
) {
|
||||||
let epsilon = 0.0001;
|
let epsilon = 0.0001;
|
||||||
//let d = time.delta_seconds();
|
//let d = time.delta_seconds();
|
||||||
for (mut v_ang, engine) in &mut q_angularvelocity {
|
for (mut v_ang, engine, maxrot) in &mut query {
|
||||||
let total = v_ang.0.length();
|
let total = v_ang.0.length();
|
||||||
if total <= epsilon {
|
if total <= maxrot.0 + epsilon {
|
||||||
if total > 0.0 {
|
if total > maxrot.0 {
|
||||||
v_ang.0 = DVec3::splat(0.0);
|
v_ang.0 = DVec3::splat(0.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -320,16 +320,16 @@ fn handle_wants_norotation(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_wants_novelocity(
|
fn handle_wants_maxvelocity(
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
mut q_velocity: Query<(&mut LinearVelocity, &Engine), With<WantsNoVelocity>>,
|
mut query: Query<(&mut LinearVelocity, &Engine, &WantsMaxVelocity)>,
|
||||||
) {
|
) {
|
||||||
let dt = time.delta_seconds();
|
let dt = time.delta_seconds();
|
||||||
let epsilon = 0.0001;
|
let epsilon = 0.0001;
|
||||||
for (mut v, engine) in &mut q_velocity {
|
for (mut v, engine, maxv) in &mut query {
|
||||||
let total = v.0.length();
|
let total = v.0.length();
|
||||||
if total <= epsilon {
|
if total <= maxv.0 + epsilon {
|
||||||
if total > 0.0 {
|
if total > maxv.0 {
|
||||||
v.0 = DVec3::splat(0.0);
|
v.0 = DVec3::splat(0.0);
|
||||||
}
|
}
|
||||||
// already not moving
|
// already not moving
|
||||||
|
|
|
@ -49,8 +49,8 @@ struct ParserState {
|
||||||
is_suited: bool,
|
is_suited: bool,
|
||||||
is_vehicle: bool,
|
is_vehicle: bool,
|
||||||
has_physics: bool,
|
has_physics: bool,
|
||||||
wants_norotation: bool,
|
wants_maxrotation: Option<f64>,
|
||||||
wants_novelocity: bool,
|
wants_maxvelocity: Option<f64>,
|
||||||
collider_is_mesh: bool,
|
collider_is_mesh: bool,
|
||||||
thrust_forward: f32,
|
thrust_forward: f32,
|
||||||
thrust_sideways: f32,
|
thrust_sideways: f32,
|
||||||
|
@ -101,8 +101,8 @@ impl Default for ParserState {
|
||||||
is_suited: false,
|
is_suited: false,
|
||||||
is_vehicle: false,
|
is_vehicle: false,
|
||||||
has_physics: true,
|
has_physics: true,
|
||||||
wants_norotation: false,
|
wants_maxrotation: None,
|
||||||
wants_novelocity: false,
|
wants_maxvelocity: None,
|
||||||
collider_is_mesh: false,
|
collider_is_mesh: false,
|
||||||
thrust_forward: default_engine.thrust_forward,
|
thrust_forward: default_engine.thrust_forward,
|
||||||
thrust_sideways: default_engine.thrust_forward,
|
thrust_sideways: default_engine.thrust_forward,
|
||||||
|
@ -426,11 +426,25 @@ pub fn load_defs(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
["wants", "norotation"] => {
|
["wants", "maxrotation", value] => {
|
||||||
state.wants_norotation = true;
|
// NOTE: requires an engine to slow down velocity
|
||||||
|
if let Ok(value_float) = value.parse::<f64>() {
|
||||||
|
state.wants_maxrotation = Some(value_float);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error!("Can't parse float: {line}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
["wants", "maxvelocity", value] => {
|
||||||
|
// NOTE: requires an engine to slow down velocity
|
||||||
|
if let Ok(value_float) = value.parse::<f64>() {
|
||||||
|
state.wants_maxvelocity = Some(value_float);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
error!("Can't parse float: {line}");
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
["wants", "novelocity"] => {
|
|
||||||
state.wants_novelocity = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parsing chats
|
// Parsing chats
|
||||||
|
@ -622,13 +636,11 @@ fn spawn_entities(
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if state.wants_norotation {
|
if let Some(value) = state.wants_maxrotation {
|
||||||
// NOTE: requires an engine to slow down rotation
|
actor.insert(actor::WantsMaxRotation(value));
|
||||||
actor.insert(actor::WantsNoRotation);
|
|
||||||
}
|
}
|
||||||
if state.wants_novelocity {
|
if let Some(value) = state.wants_maxvelocity {
|
||||||
// NOTE: requires an engine to slow down velocity
|
actor.insert(actor::WantsMaxVelocity(value));
|
||||||
actor.insert(actor::WantsNoVelocity);
|
|
||||||
}
|
}
|
||||||
if let Some(color) = state.light_color {
|
if let Some(color) = state.light_color {
|
||||||
actor.insert(PointLightBundle {
|
actor.insert(PointLightBundle {
|
||||||
|
@ -651,7 +663,12 @@ fn spawn_entities(
|
||||||
if state.is_vehicle {
|
if state.is_vehicle {
|
||||||
actor.insert(actor::Vehicle::default());
|
actor.insert(actor::Vehicle::default());
|
||||||
}
|
}
|
||||||
if state.is_vehicle || state.is_suited {
|
if state.is_vehicle || state.is_suited
|
||||||
|
|| state.thrust_forward > 0.0
|
||||||
|
|| state.thrust_sideways > 0.0
|
||||||
|
|| state.thrust_back > 0.0
|
||||||
|
|| state.reaction_wheels > 0.0
|
||||||
|
{
|
||||||
actor.insert(actor::Engine {
|
actor.insert(actor::Engine {
|
||||||
thrust_forward: state.thrust_forward,
|
thrust_forward: state.thrust_forward,
|
||||||
thrust_back: state.thrust_back,
|
thrust_back: state.thrust_back,
|
||||||
|
|
14
src/defs.txt
14
src/defs.txt
|
@ -90,8 +90,8 @@ actor 3000 0 0 moonlet
|
||||||
actor -200 -110 1000 satellite
|
actor -200 -110 1000 satellite
|
||||||
relativeto player
|
relativeto player
|
||||||
scale 40
|
scale 40
|
||||||
wants norotation
|
wants maxrotation 0
|
||||||
thrust 0 0 0 300 1
|
thrust 0 0 0 30 1
|
||||||
collider capsule 7.5 1
|
collider capsule 7.5 1
|
||||||
rotationy 0.5
|
rotationy 0.5
|
||||||
angularmomentum 0 0 0
|
angularmomentum 0 0 0
|
||||||
|
@ -157,8 +157,8 @@ actor -3300 10 0 pizzeria
|
||||||
mass 200.0
|
mass 200.0
|
||||||
collider capsule 2 1
|
collider capsule 2 1
|
||||||
thrust 1.2 1 1 10 1.5
|
thrust 1.2 1 1 10 1.5
|
||||||
wants norotation
|
wants maxrotation 0
|
||||||
wants novelocity
|
wants maxvelocity 0
|
||||||
pronoun he
|
pronoun he
|
||||||
chat pizzeria
|
chat pizzeria
|
||||||
name "Space Pizza™"
|
name "Space Pizza™"
|
||||||
|
@ -212,10 +212,10 @@ actor 70 -25 -60 suit
|
||||||
alive yes
|
alive yes
|
||||||
mass 200.0
|
mass 200.0
|
||||||
collider capsule 2 1
|
collider capsule 2 1
|
||||||
angularmomentum 0.1 0.2 0.1
|
angularmomentum 0.4 0.2 0.1
|
||||||
thrust 1.2 1 1 10 1.5
|
thrust 1.2 1 1 10 1.5
|
||||||
wants norotation
|
wants maxrotation 0.5
|
||||||
wants novelocity
|
wants maxvelocity 0
|
||||||
pronoun it
|
pronoun it
|
||||||
chat hi_icarus
|
chat hi_icarus
|
||||||
name Icarus
|
name Icarus
|
||||||
|
|
Loading…
Reference in a new issue