Compare commits
2 Commits
828a0ca0b3
...
a019e8b5c7
Author | SHA1 | Date | |
---|---|---|---|
a019e8b5c7 | |||
a1edab98f9 |
|
@ -242,6 +242,7 @@ fn spawn_colliders<D: 'static + Clone + Default + Send + Sync>(
|
||||||
.spawn()
|
.spawn()
|
||||||
.insert(Collider::cuboid(0.5, 0.5))
|
.insert(Collider::cuboid(0.5, 0.5))
|
||||||
.insert(Transform::from_xyz(x as f32 + 0.5, y as f32 + 0.5, 0.))
|
.insert(Transform::from_xyz(x as f32 + 0.5, y as f32 + 0.5, 0.))
|
||||||
|
.insert(GlobalTransform::default())
|
||||||
.insert(MapObstruction)
|
.insert(MapObstruction)
|
||||||
.id();
|
.id();
|
||||||
if tile.blocks_visibility() {
|
if tile.blocks_visibility() {
|
||||||
|
@ -326,6 +327,7 @@ fn spawn_colliders<D: 'static + Clone + Default + Send + Sync>(
|
||||||
.spawn()
|
.spawn()
|
||||||
.insert(Collider::cuboid(half_width, half_height))
|
.insert(Collider::cuboid(half_width, half_height))
|
||||||
.insert(Transform::from_xyz(center.x(), center.y(), 0.))
|
.insert(Transform::from_xyz(center.x(), center.y(), 0.))
|
||||||
|
.insert(GlobalTransform::default())
|
||||||
.insert(MapObstruction)
|
.insert(MapObstruction)
|
||||||
.id();
|
.id();
|
||||||
if map.at(x as usize, y as usize).blocks_visibility() {
|
if map.at(x as usize, y as usize).blocks_visibility() {
|
||||||
|
@ -428,6 +430,7 @@ fn spawn_portal_colliders<D: 'static + Clone + Default + Send + Sync>(
|
||||||
commands
|
commands
|
||||||
.entity(portal_entity)
|
.entity(portal_entity)
|
||||||
.insert(Transform::from_xyz(position.x(), position.y(), 0.))
|
.insert(Transform::from_xyz(position.x(), position.y(), 0.))
|
||||||
|
.insert(GlobalTransform::default())
|
||||||
.insert(Collider::cuboid(0.5, 0.5))
|
.insert(Collider::cuboid(0.5, 0.5))
|
||||||
.insert(Sensor(true))
|
.insert(Sensor(true))
|
||||||
.insert(ActiveEvents::COLLISION_EVENTS);
|
.insert(ActiveEvents::COLLISION_EVENTS);
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
commands::RunIfExistsExt,
|
commands::RunIfExistsExt,
|
||||||
core::Player,
|
core::Player,
|
||||||
exploration::ExplorationFocused,
|
exploration::ExplorationFocused,
|
||||||
visibility::{Visible, VisibleEntities},
|
visibility::{VisibilityChanged, Visible, VisibleEntities},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Component, Clone, Debug)]
|
#[derive(Component, Clone, Debug)]
|
||||||
|
@ -242,6 +242,38 @@ fn exploration_focus_removed(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn reset_timer_on_visibility_gain(
|
||||||
|
mut events: EventReader<VisibilityChanged>,
|
||||||
|
player: Query<Entity, With<Player>>,
|
||||||
|
mut icons: Query<&mut SoundIcon>,
|
||||||
|
children: Query<&Children>,
|
||||||
|
) {
|
||||||
|
for event in events.iter() {
|
||||||
|
if let VisibilityChanged::Gained { viewer, viewed } = event {
|
||||||
|
if player.get(*viewer).is_ok() {
|
||||||
|
let mut targets = vec![];
|
||||||
|
if icons.get(*viewed).is_ok() {
|
||||||
|
targets.push(viewed);
|
||||||
|
}
|
||||||
|
if let Ok(children) = children.get(*viewed) {
|
||||||
|
for child in children.iter() {
|
||||||
|
if icons.get(*child).is_ok() {
|
||||||
|
targets.push(&*child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for icon in targets.iter_mut() {
|
||||||
|
if let Ok(mut icon) = icons.get_mut(**icon) {
|
||||||
|
if let Some(timer) = icon.interval.as_mut() {
|
||||||
|
timer.set_elapsed(timer.duration());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct SoundIconConfig<S> {
|
pub struct SoundIconConfig<S> {
|
||||||
pub states: Vec<S>,
|
pub states: Vec<S>,
|
||||||
|
@ -273,6 +305,7 @@ where
|
||||||
.add_system_to_stage(
|
.add_system_to_stage(
|
||||||
CoreStage::PostUpdate,
|
CoreStage::PostUpdate,
|
||||||
exploration_focus_removed.after(exploration_focus_changed),
|
exploration_focus_removed.after(exploration_focus_changed),
|
||||||
);
|
)
|
||||||
|
.add_system_to_stage(CoreStage::PostUpdate, reset_timer_on_visibility_gain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user