-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
262 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use specs::prelude::*; | ||
|
||
#[derive(Debug, Copy, Clone, Default)] | ||
pub struct Hidden; | ||
|
||
impl Component for Hidden { | ||
type Storage = NullStorage<Self>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use specs::prelude::*; | ||
use crate::{ | ||
resources::events::{ | ||
GeometryAction, GeometryActionChannel, GeometryActionReader, | ||
SketchEvent, SketchEventChannel, | ||
}, | ||
components::{Selected}, | ||
}; | ||
|
||
pub struct HideSelectedHandler { | ||
geometry_action_reader: Option<GeometryActionReader>, | ||
} | ||
|
||
impl Default for HideSelectedHandler { | ||
fn default() -> Self { | ||
Self { geometry_action_reader: None } | ||
} | ||
} | ||
|
||
impl<'a> System<'a> for HideSelectedHandler { | ||
type SystemData = ( | ||
Entities<'a>, | ||
Read<'a, GeometryActionChannel>, | ||
Write<'a, SketchEventChannel>, | ||
ReadStorage<'a, Selected>, | ||
); | ||
|
||
fn setup(&mut self, world: &mut World) { | ||
Self::SystemData::setup(world); | ||
self.geometry_action_reader = Some(world.fetch_mut::<GeometryActionChannel>().register_reader()); | ||
} | ||
|
||
fn run(&mut self, (entities, geometry_action_channel, mut sketch_event_channel, selected): Self::SystemData) { | ||
if let Some(reader_id) = &mut self.geometry_action_reader { | ||
for event in geometry_action_channel.read(reader_id) { | ||
match event { | ||
GeometryAction::HideSelected => { | ||
for (entity, _) in (&entities, &selected).join() { | ||
sketch_event_channel.single_write(SketchEvent::hide(entity)); | ||
} | ||
break; | ||
}, | ||
_ => () | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.