add sun-blocking moonlet thru defs.txt

This commit is contained in:
yuni 2024-03-20 21:03:22 +01:00
parent b8af14c1dd
commit 6cf99e6b0a
3 changed files with 24 additions and 65 deletions

View file

@ -82,9 +82,13 @@ pub struct Chat {
#[derive(Component)]
#[derive(Clone)]
pub struct Talker {
pub pronoun: String,
pub conv_id: String,
}
impl Default for Talker { fn default() -> Self { Self { conv_id: "".to_string() } } }
impl Default for Talker { fn default() -> Self { Self {
pronoun: "they/them".to_string(),
conv_id: "error".to_string(),
}}}
#[derive(Component)]
pub struct LifeForm {

View file

@ -5,11 +5,21 @@ actor -50 0 0 "icarus"
chatid "hi_icarus"
scale 1
actor 0 0 0 "alien"
chatid "error"
actor 300000 0 500000 "jupiter"
scale 80000
rotationy -1.40
angularmomentum 0 0.0001 0
actor 2000 0 0 "asteroid1"
scale 200
chat "error"
name "ERROR"
msg 0 "INIT" "EXIT" "Unspecified conversation ID"
chat "hialien"
name "Alien"
msg 0 "INIT" "EXIT" "Leave me alone"

View file

@ -10,7 +10,6 @@ use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings};
use std::f32::consts::PI;
const ASTEROID_SIZE: f32 = 100.0;
const MOON_SIZE: f32 = 200.0;
const MARS_SIZE: f32 = 10.0;
const ASTRONAUT_SIZE: f32 = 5.0;
const PIZZERIA_SIZE: f32 = 30.0;
@ -29,6 +28,9 @@ fn asset_name_to_path(name: &str) -> &'static str {
match name {
"astronaut" => ASSET_ASTRONAUT,
"jupiter" => ASSET_JUPITER,
"asteroid1" => ASSET_ASTEROID1,
"asteroid2" => ASSET_ASTEROID2,
"pizzeria" => ASSET_PIZZERIA,
_ => ASSET_ASTRONAUT,
}
}
@ -109,45 +111,6 @@ pub fn setup(
},
));
// Add some hand-placed asteroids
let sphere_handle = meshes.add(Sphere::new(1.0));
let gray_handle = materials.add(StandardMaterial {
base_color: Color::GRAY,
perceptual_roughness: 1.0,
..default()
});
let brown_handle = materials.add(StandardMaterial {
base_color: Color::Rgba { alpha: 1.0, red: 0.8, green: 0.5, blue: 0.1 },
perceptual_roughness: 1.0,
..default()
});
commands.spawn((
actor::Actor::default(),
PbrBundle {
mesh: sphere_handle.clone(),
material: gray_handle.clone(),
transform: Transform::from_xyz(
2000.0,
0.0,
0.0,
).with_scale(Vec3::splat(MOON_SIZE)),
..default()
},
));
commands.spawn((
actor::Actor::default(),
PbrBundle {
mesh: sphere_handle.clone(),
material: brown_handle.clone(),
transform: Transform::from_xyz(
300.0,
40.0,
250.0,
).with_scale(Vec3::splat(MARS_SIZE)),
..default()
},
));
// Generate a bunch of asteriods
let maxdist = 10;
for i in -maxdist..maxdist {
@ -186,6 +149,7 @@ pub fn setup(
}
// Generate starmap
let sphere_handle = meshes.add(Sphere::new(1.0));
for star in nature::STARS {
let brightness = star[3] * 2000.0;
let (r, g, b) = nature::star_color_index_to_rgb(star[4]);
@ -211,28 +175,6 @@ pub fn setup(
));
}
// Add alien
commands.spawn((
actor::Actor {
v: Vec3::new(-0.05, 0.2, 0.35),
..default()
},
actor::Talker { conv_id: "hialien".to_string() },
SceneBundle {
transform: Transform {
translation: Vec3::new(
20.0,
0.0,
0.0,
),
rotation: Quat::from_rotation_y(-PI / 3.),
scale: Vec3::splat(ASTRONAUT_SIZE),
},
scene: asset_server.load(ASSET_ASTRONAUT),
..default()
},
));
// Add pizza alien
commands.spawn((
actor::Actor {
@ -240,7 +182,7 @@ pub fn setup(
angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.0, 0.0001, 0.0),
..default()
},
actor::Talker { conv_id: "pizzeria".to_string() },
actor::Talker { conv_id: "pizzeria".to_string(), pronoun: "it".to_string() },
SceneBundle {
transform: Transform {
translation: Vec3::new(
@ -333,6 +275,7 @@ struct ParserState {
}
impl Default for ParserState {
fn default() -> Self {
let default_actor = actor::Actor::default();
Self {
class: DefClass::None,
name: "NONAME".to_string(),
@ -342,7 +285,7 @@ impl Default for ParserState {
model: "".to_string(),
model_scale: 1.0,
rotation: Quat::IDENTITY,
angular_momentum: Quat::IDENTITY,
angular_momentum: default_actor.angular_momentum,
pronoun: "they/them".to_string(),
is_lifeform: false,
is_alive: false,
@ -501,6 +444,8 @@ pub fn load_defs(
match parts.as_slice() {
// Parsing actors
["actor", x, y, z, model] => {
state.spawn_entities(&mut commands, &asset_server);
state.reset();
state.class = DefClass::Actor;
state.model = model.to_string();
if let (Ok(x_float), Ok(y_float), Ok(z_float)) =