Merge branch 'main' into open-doors
This commit is contained in:
@@ -6,6 +6,14 @@
|
|||||||
),
|
),
|
||||||
"id_card": File(path: "meshes/id_card.glb"),
|
"id_card": File(path: "meshes/id_card.glb"),
|
||||||
"id_card_toolbar": File(path: "images/id_card_toolbar.png"),
|
"id_card_toolbar": File(path: "images/id_card_toolbar.png"),
|
||||||
|
"flash_hold_0": File (path: "images/pixelart/Flashlight_hold_0.png"),
|
||||||
|
"flash_hold_0_pressed": File (path: "images/pixelart/Flashlight_click_0.png"),
|
||||||
|
"flash_hold_1": File (path: "images/pixelart/Flashlight_hold_1.png"),
|
||||||
|
"flash_hold_1_pressed": File (path: "images/pixelart/Flashlight_click_1.png"),
|
||||||
|
"flash_hold_2": File (path: "images/pixelart/Flashlight_hold_2.png"),
|
||||||
|
"flash_hold_2_pressed": File (path: "images/pixelart/Flashlight_click_2.png"),
|
||||||
|
"flash_hold_3": File (path: "images/pixelart/Flashlight_hold_3.png"),
|
||||||
|
"flash_hold_3_pressed": File (path: "images/pixelart/Flashlight_click_3.png"),
|
||||||
"flash_hold_4": File (path: "images/pixelart/Flashlight_hold_4.png"),
|
"flash_hold_4": File (path: "images/pixelart/Flashlight_hold_4.png"),
|
||||||
"flash_hold_4_pressed": File (path: "images/pixelart/Flashlight_click_4.png"),
|
"flash_hold_4_pressed": File (path: "images/pixelart/Flashlight_click_4.png"),
|
||||||
"flashlight_click": File (path: "audio/flashlight-switch.ogg"),
|
"flashlight_click": File (path: "audio/flashlight-switch.ogg"),
|
||||||
|
|||||||
@@ -59,6 +59,22 @@ pub(crate) struct ImageAssets {
|
|||||||
|
|
||||||
#[derive(AssetCollection, Resource, Clone)]
|
#[derive(AssetCollection, Resource, Clone)]
|
||||||
pub(crate) struct FlashlightAssets {
|
pub(crate) struct FlashlightAssets {
|
||||||
|
#[asset(key = "flash_hold_0")]
|
||||||
|
pub(crate) flash_hold_0: Handle<Image>,
|
||||||
|
#[asset(key = "flash_hold_0_pressed")]
|
||||||
|
pub(crate) flash_hold_0_pressed: Handle<Image>,
|
||||||
|
#[asset(key = "flash_hold_1")]
|
||||||
|
pub(crate) flash_hold_1: Handle<Image>,
|
||||||
|
#[asset(key = "flash_hold_1_pressed")]
|
||||||
|
pub(crate) flash_hold_1_pressed: Handle<Image>,
|
||||||
|
#[asset(key = "flash_hold_2")]
|
||||||
|
pub(crate) flash_hold_2: Handle<Image>,
|
||||||
|
#[asset(key = "flash_hold_2_pressed")]
|
||||||
|
pub(crate) flash_hold_2_pressed: Handle<Image>,
|
||||||
|
#[asset(key = "flash_hold_3")]
|
||||||
|
pub(crate) flash_hold_3: Handle<Image>,
|
||||||
|
#[asset(key = "flash_hold_3_pressed")]
|
||||||
|
pub(crate) flash_hold_3_pressed: Handle<Image>,
|
||||||
#[asset(key = "flash_hold_4")]
|
#[asset(key = "flash_hold_4")]
|
||||||
pub(crate) flash_hold_4: Handle<Image>,
|
pub(crate) flash_hold_4: Handle<Image>,
|
||||||
#[asset(key = "flash_hold_4_pressed")]
|
#[asset(key = "flash_hold_4_pressed")]
|
||||||
|
|||||||
@@ -537,8 +537,10 @@ impl GameLevel {
|
|||||||
let end_node = self.nodes.get_mut(&self.end_node).unwrap();
|
let end_node = self.nodes.get_mut(&self.end_node).unwrap();
|
||||||
if self.end_node.1 >= self.end_node.0 {
|
if self.end_node.1 >= self.end_node.0 {
|
||||||
end_node.north = Side::Connection;
|
end_node.north = Side::Connection;
|
||||||
} else if self.end_node.0 >= self.end_node.1 {
|
end_node.south = Side::Connection;
|
||||||
|
} else {
|
||||||
end_node.east = Side::Connection;
|
end_node.east = Side::Connection;
|
||||||
|
end_node.west = Side::Connection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,15 @@ impl Default for HeadBob {
|
|||||||
pub struct BaseTransform(pub Transform);
|
pub struct BaseTransform(pub Transform);
|
||||||
|
|
||||||
#[derive(Debug, Component)]
|
#[derive(Debug, Component)]
|
||||||
pub struct Flashlight;
|
pub struct Flashlight {
|
||||||
|
// 0 - 4
|
||||||
|
pub charge: f32,
|
||||||
|
pub is_on: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Component)]
|
||||||
|
pub struct SpotlightFlashlight {
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Component)]
|
#[derive(Component)]
|
||||||
pub struct FlashlightButtonAnimation {
|
pub struct FlashlightButtonAnimation {
|
||||||
@@ -87,7 +95,7 @@ pub fn plugin(app: &mut App) {
|
|||||||
apply_head_bob,
|
apply_head_bob,
|
||||||
on_resize_system,
|
on_resize_system,
|
||||||
handle_flashlight,
|
handle_flashlight,
|
||||||
update_flashlight_button_animation,
|
(update_flashlight_button_animation, update_flashlight_charge, update_flashlight_sprite).chain(),
|
||||||
)
|
)
|
||||||
.run_if(in_state(GameState::Playing)),
|
.run_if(in_state(GameState::Playing)),
|
||||||
)
|
)
|
||||||
@@ -155,6 +163,7 @@ pub fn init_player(
|
|||||||
let window = window.single();
|
let window = window.single();
|
||||||
let transform = flashlight_base_transform(window.width(), window.height());
|
let transform = flashlight_base_transform(window.width(), window.height());
|
||||||
parent.spawn((
|
parent.spawn((
|
||||||
|
Flashlight { charge: 4.0, is_on: false },
|
||||||
Sprite::from_image(flashlights.flash_hold_4.clone()),
|
Sprite::from_image(flashlights.flash_hold_4.clone()),
|
||||||
transform.0.clone(),
|
transform.0.clone(),
|
||||||
transform,
|
transform,
|
||||||
@@ -164,7 +173,7 @@ pub fn init_player(
|
|||||||
|
|
||||||
// feitelijke pitslamp
|
// feitelijke pitslamp
|
||||||
parent.spawn((
|
parent.spawn((
|
||||||
Flashlight,
|
SpotlightFlashlight{},
|
||||||
SpotLight {
|
SpotLight {
|
||||||
intensity: 0.0,
|
intensity: 0.0,
|
||||||
color: Color::srgba(0.9, 0.628, 0.392, 1.0),
|
color: Color::srgba(0.9, 0.628, 0.392, 1.0),
|
||||||
@@ -400,7 +409,7 @@ pub fn apply_head_bob(
|
|||||||
}
|
}
|
||||||
pub fn handle_flashlight(
|
pub fn handle_flashlight(
|
||||||
player_query: Query<&PlayerAction, With<Player>>,
|
player_query: Query<&PlayerAction, With<Player>>,
|
||||||
mut flashlight_query: Query<&mut SpotLight, With<Flashlight>>,
|
mut flashlight_query: Query<&mut SpotLight, With<SpotlightFlashlight>>,
|
||||||
mut flashlight_sprite_query: Query<&mut FlashlightButtonAnimation>,
|
mut flashlight_sprite_query: Query<&mut FlashlightButtonAnimation>,
|
||||||
audio_assets: Res<AudioAssets>,
|
audio_assets: Res<AudioAssets>,
|
||||||
audio: Res<Audio>,
|
audio: Res<Audio>,
|
||||||
@@ -426,20 +435,59 @@ pub fn handle_flashlight(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_flashlight_charge(
|
||||||
|
time: Res<Time>,
|
||||||
|
mut flashlight_query: Query<&mut Flashlight>,
|
||||||
|
) {
|
||||||
|
for mut flashlight in flashlight_query.iter_mut() {
|
||||||
|
if flashlight.is_on {
|
||||||
|
flashlight.charge = flashlight.charge - time.delta_secs() * 0.1;
|
||||||
|
} else {
|
||||||
|
flashlight.charge = flashlight.charge + time.delta_secs() * 0.1;
|
||||||
|
}
|
||||||
|
flashlight.charge = flashlight.charge.clamp(0.0, 4.0);
|
||||||
|
if flashlight.charge <= 0.0 {
|
||||||
|
flashlight.is_on = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_flashlight_button_animation(
|
pub fn update_flashlight_button_animation(
|
||||||
time: Res<Time>,
|
time: Res<Time>,
|
||||||
mut query: Query<(&mut FlashlightButtonAnimation, &mut Sprite)>,
|
mut query: Query<&mut FlashlightButtonAnimation>,
|
||||||
flashlights: Res<FlashlightAssets>,
|
|
||||||
) {
|
) {
|
||||||
for (mut animation, mut image) in query.iter_mut() {
|
for mut animation in query.iter_mut() {
|
||||||
if animation.is_pressed {
|
if animation.is_pressed {
|
||||||
animation.timer.tick(time.delta());
|
animation.timer.tick(time.delta());
|
||||||
if animation.timer.finished() {
|
if animation.timer.finished() {
|
||||||
*image = Sprite::from_image(flashlights.flash_hold_4.clone());
|
|
||||||
animation.is_pressed = false;
|
animation.is_pressed = false;
|
||||||
} else {
|
} else {
|
||||||
*image = Sprite::from_image(flashlights.flash_hold_4_pressed.clone());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn update_flashlight_sprite(
|
||||||
|
mut query: Query<(&FlashlightButtonAnimation, &mut Sprite, &Flashlight)>,
|
||||||
|
flashlights: Res<FlashlightAssets>,
|
||||||
|
){
|
||||||
|
for (animation, mut image, flashlight) in query.iter_mut() {
|
||||||
|
println!("charge: {}", flashlight.charge);
|
||||||
|
let charge = flashlight.charge.ceil() as i32;
|
||||||
|
println!("charge: {}", charge);
|
||||||
|
let sprite_image = match (charge, animation.is_pressed) {
|
||||||
|
(4, true) => flashlights.flash_hold_4_pressed.clone(),
|
||||||
|
(4, false) => flashlights.flash_hold_4.clone(),
|
||||||
|
(3, true) => flashlights.flash_hold_3_pressed.clone(),
|
||||||
|
(3, false) => flashlights.flash_hold_3.clone(),
|
||||||
|
(2, true) => flashlights.flash_hold_2_pressed.clone(),
|
||||||
|
(2, false) => flashlights.flash_hold_2.clone(),
|
||||||
|
(1, true) => flashlights.flash_hold_1_pressed.clone(),
|
||||||
|
(1, false) => flashlights.flash_hold_1.clone(),
|
||||||
|
(0, true) => flashlights.flash_hold_0_pressed.clone(),
|
||||||
|
(0, false) => flashlights.flash_hold_0.clone(),
|
||||||
|
_ => flashlights.flash_hold_0.clone()
|
||||||
|
};
|
||||||
|
*image = Sprite::from_image(sprite_image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user