add "light" command, add cozy illumination to pizza place

This commit is contained in:
yuni 2024-03-31 04:10:54 +02:00
parent b655a04ff5
commit cc198f5465
2 changed files with 48 additions and 3 deletions

View file

@ -78,18 +78,25 @@ actor -8000 -1000 -100 monolith
actor -3300 10 0 pizzeria
scale 40
mass 1000000
rotationy -0.25
rotationy 0.30
angularmomentum 0 0 0
actor -3400 73 -13 pizzasign
scale 20
mass 200
rotationy 0.45
angularmomentum 0.00001 0 0.0003
actor -3295 3 -32 suit
angularmomentum 0.1 0 0.2
actor -3316 0 0 lightorb
scale 0.5
light FF8F4A 1000000
actor -3314 7 -2 lightorb
scale 0.5
light FF8F4A 1000000
actor -3330 10 0 suit
name "Space Pizza™"
chatid pizzeria
mass 200.0
alive yes
angularmomentum 0.02 0.03 0.01
pronoun it
chat pizzeria
name "Space Pizza™"

View file

@ -26,6 +26,7 @@ fn asset_name_to_path(name: &str) -> &'static str {
"asteroid2" => ASSET_ASTEROID2,
"moonlet" => "models/moonlet.glb#Scene0",
"monolith" => "models/monolith_neon.glb#Scene0",
"lightorb" => "models/lightorb.glb#Scene0",
"MeteorAceGT" => "models/MeteorAceGT.glb#Scene0",
"pizzeria" => "models/pizzeria2.glb#Scene0",
"pizzasign" => "models/pizzasign.glb#Scene0",
@ -228,6 +229,8 @@ struct ParserState {
collider: Collider,
camdistance: f32,
suit_integrity: f32,
light_brightness: f32,
light_color: Option<Color>,
// Chat fields
delay: f64,
@ -276,6 +279,8 @@ impl Default for ParserState {
collider: Collider::sphere(1.0),
camdistance: default_actor.camdistance,
suit_integrity: 1.0,
light_brightness: 0.0,
light_color: None,
delay: 0.0,
text: "".to_string(),
@ -529,6 +534,22 @@ pub fn load_defs(
continue;
}
}
["light", color_hex, brightness] => {
if let Ok(brightness_float) = brightness.parse::<f32>() {
if let Ok(color) = Color::hex(color_hex) {
state.light_color = Some(color);
state.light_brightness = brightness_float;
}
else {
error!("Can't parse hexadecimal color code: {line}");
continue;
}
}
else {
error!("Can't parse float: {line}");
continue;
}
}
// Parsing chats
["chat", chat_name] => {
@ -719,6 +740,23 @@ fn spawn_entities(
..default()
});
}
if let Some(color) = state.light_color {
actor.insert(PointLightBundle {
point_light: PointLight {
intensity: state.light_brightness,
color: color,
range: 100.0,
radius: 100.0,
..default()
},
transform: Transform {
translation: state.pos,
scale: Vec3::splat(state.model_scale),
rotation: state.rotation,
},
..default()
});
}
if !state.chat.is_empty() {
actor.insert(actor::Talker {
conv_id: state.chat.clone(),