add space pizzeria

This commit is contained in:
yuni 2024-03-19 18:15:19 +01:00
parent b0d6c600c6
commit 38307776df
5 changed files with 139 additions and 12 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
target target
assets/tmp assets/tmp
*.blend
*.blend1

BIN
assets/models/pizzeria.glb Normal file

Binary file not shown.

View file

@ -40,21 +40,33 @@
), ),
}, },
), ),
4294967299: ( 4294967299: (
components: { components: {
"outfly::actor::ChatBranch": ( "outfly::actor::ChatBranch": (
id: "hialien", id: "hialien",
name: "Icarus", name: "Icarus",
label: "reply1", label: "reply1",
delay: 1.5, delay: 3.5,
sound: "chat", sound: "chat",
reply: "Not so chatty, huh? That's ok. See you around.", reply: "Not so chatty, huh? That's ok. See you around.",
goto: "disco", goto: "pizza",
), ),
}, },
), ),
4294967300: ( 4294967300: (
components: {
"outfly::actor::ChatBranch": (
id: "hialien",
name: "Icarus",
label: "pizza",
delay: 1.5,
sound: "chat",
reply: "Make sure to check out the Pizza place.",
goto: "disco",
),
},
),
4294967301: (
components: { components: {
"outfly::actor::ChatBranch": ( "outfly::actor::ChatBranch": (
id: "hialien", id: "hialien",
@ -67,5 +79,70 @@
), ),
}, },
), ),
4294967400: (
components: {
"outfly::actor::ChatBranch": (
id: "pizzeria",
name: "Space Pizza™",
label: "INIT",
delay: 1.0,
sound: "ping",
reply: "Requesting permission to communicate...",
goto: "requested",
),
},
),
4294967401: (
components: {
"outfly::actor::ChatBranch": (
id: "pizzeria",
name: "Space Pizza™",
label: "requested",
delay: 5.0,
sound: "connect",
reply: "Welcome to Space Pizza™, best pizza all across the Jovian rings!",
goto: "ask",
),
},
),
4294967402: (
components: {
"outfly::actor::ChatBranch": (
id: "pizzeria",
name: "Space Pizza™",
label: "ask",
delay: 10.0,
sound: "chat",
reply: "Would you like to order today's special Miracle Spacefungi? Freshly blended pizza smoothie ready for your space suit feeding tube!",
goto: "hello?",
),
},
),
4294967403: (
components: {
"outfly::actor::ChatBranch": (
id: "pizzeria",
name: "Space Pizza™",
label: "hello?",
delay: 10.0,
sound: "chat",
reply: "Hello? Are you still there?",
goto: "disco",
),
},
),
4294967304: (
components: {
"outfly::actor::ChatBranch": (
id: "pizzeria",
name: "Space Pizza™",
label: "disco",
delay: 0.0,
sound: "ping",
reply: "Disconnected.",
goto: "EXIT",
),
},
),
}, },
) )

View file

@ -25,7 +25,7 @@ impl Plugin for ActorPlugin {
#[derive(Event)] #[derive(Event)]
pub struct StartConversationEvent { pub struct StartConversationEvent {
pub conv: String pub talker: Talker,
} }
#[derive(Component)] #[derive(Component)]
@ -80,8 +80,9 @@ pub struct Chat {
} }
#[derive(Component)] #[derive(Component)]
#[derive(Clone)]
pub struct Talker { pub struct Talker {
pub conv: String, pub conv_id: String,
} }
#[derive(Component)] #[derive(Component)]
@ -166,7 +167,7 @@ pub fn handle_input(
if let Ok(player) = player.get_single() { if let Ok(player) = player.get_single() {
for (talker, transform) in &query { for (talker, transform) in &query {
if transform.translation.distance_squared(player.translation) <= mindist { if transform.translation.distance_squared(player.translation) <= mindist {
ew_conv.send(StartConversationEvent{conv: talker.conv.clone()}); ew_conv.send(StartConversationEvent{talker: talker.clone()});
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Ping)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Ping));
break; break;
} }
@ -182,11 +183,11 @@ pub fn handle_new_conversations(
q_conv: Query<&Chat>, q_conv: Query<&Chat>,
time: Res<Time>, time: Res<Time>,
) { ) {
let id = "hialien";
let label = "INIT"; let label = "INIT";
for _my_event in er_conv.read() { for event in er_conv.read() {
// check for existing chats with this id // check for existing chats with this id
let chats: Vec<&Chat> = q_conv.iter().filter(|c| c.id == id).collect(); let id = &event.talker.conv_id;
let chats: Vec<&Chat> = q_conv.iter().filter(|c| c.id == *id).collect();
if chats.len() > 0 { if chats.len() > 0 {
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Ping)); ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Ping));
continue; continue;

View file

@ -11,6 +11,7 @@ const ASTEROID_SIZE: f32 = 100.0;
const MOON_SIZE: f32 = 200.0; const MOON_SIZE: f32 = 200.0;
const MARS_SIZE: f32 = 10.0; const MARS_SIZE: f32 = 10.0;
const ASTRONAUT_SIZE: f32 = 5.0; const ASTRONAUT_SIZE: f32 = 5.0;
const PIZZERIA_SIZE: f32 = 30.0;
//const SKYBOX_BRIGHTNESS: f32 = 300.0; //const SKYBOX_BRIGHTNESS: f32 = 300.0;
//const SKYBOX_BRIGHTNESS_AR: f32 = 100.0; //const SKYBOX_BRIGHTNESS_AR: f32 = 100.0;
@ -18,6 +19,7 @@ const ASTRONAUT_SIZE: f32 = 5.0;
//const ASSET_CUBEMAP: &str = "textures/cubemap-fs8.png"; //const ASSET_CUBEMAP: &str = "textures/cubemap-fs8.png";
//const ASSET_CUBEMAP_AR: &str = "textures/out.png"; //const ASSET_CUBEMAP_AR: &str = "textures/out.png";
const ASSET_ASTRONAUT: &str = "tmp/alien.glb#Scene0"; const ASSET_ASTRONAUT: &str = "tmp/alien.glb#Scene0";
const ASSET_PIZZERIA: &str = "models/pizzeria.glb#Scene0";
pub struct WorldPlugin; pub struct WorldPlugin;
impl Plugin for WorldPlugin { impl Plugin for WorldPlugin {
@ -195,10 +197,10 @@ pub fn setup(
// Add alien // Add alien
commands.spawn(( commands.spawn((
actor::Actor { actor::Actor {
v: Vec3::new(-0.005, 0.01, 0.015), v: Vec3::new(-0.05, 0.2, 0.35),
..default() ..default()
}, },
actor::Talker { conv: "Hello World!".to_string() }, actor::Talker { conv_id: "hialien".to_string() },
SceneBundle { SceneBundle {
transform: Transform { transform: Transform {
translation: Vec3::new( translation: Vec3::new(
@ -214,10 +216,55 @@ pub fn setup(
}, },
)); ));
// Add pizza alien
commands.spawn((
actor::Actor {
v: Vec3::new(-0.05, 0.2, 0.35),
angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.0, 0.0001, 0.0),
..default()
},
actor::Talker { conv_id: "pizzeria".to_string() },
SceneBundle {
transform: Transform {
translation: Vec3::new(
-65.0,
10.0,
0.0,
),
rotation: Quat::from_rotation_y(-PI / 3.),
scale: Vec3::splat(ASTRONAUT_SIZE),
},
scene: asset_server.load(ASSET_ASTRONAUT),
..default()
},
));
// Add pizza place
commands.spawn((
actor::Actor {
v: Vec3::new(0.0, 0.0, 0.0),
angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.0, 0.0001, 0.0),
..default()
},
SceneBundle {
transform: Transform {
translation: Vec3::new(
-100.0,
10.0,
0.0,
),
rotation: Quat::from_rotation_y(-2.0 * -PI / 2.),
scale: Vec3::splat(PIZZERIA_SIZE),
},
scene: asset_server.load(ASSET_PIZZERIA),
..default()
},
));
// Space is DARK // Space is DARK
ambient_light.brightness = 0.0; ambient_light.brightness = 0.0;
// Add Light // Add Light from the Sun
commands.spawn(DirectionalLightBundle { commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight { directional_light: DirectionalLight {
illuminance: 1000.0, illuminance: 1000.0,