Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions asset_sources/folder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions asset_sources/gear.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/fonts/ChakraPetch-Regular-PixieWrangler.ttf
Binary file not shown.
54 changes: 30 additions & 24 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ fn main() {
));

app.init_state::<GameState>();
app.enable_state_scoped_entities::<GameState>();

app.add_systems(
OnEnter(GameState::Playing),
(reset_game, spawn_level, spawn_game_ui).chain(),
);
app.add_systems(OnExit(GameState::Playing), playing_exit_system);

app.configure_sets(Update, DrawingInput.run_if(in_state(GameState::Playing)));
app.add_systems(
Expand Down Expand Up @@ -562,12 +562,15 @@ fn pixie_button_system(
let mut timer = Timer::from_seconds(duration * *count as f32, TimerMode::Repeating);
timer.set_elapsed(Duration::from_secs_f32((*i + 1) as f32 * duration));

commands.spawn(PixieEmitter {
flavor: *flavor,
path: world_path.clone(),
remaining: pixies,
timer,
});
commands.spawn((
PixieEmitter {
flavor: *flavor,
path: world_path.clone(),
remaining: pixies,
timer,
},
StateScoped(GameState::Playing),
));

*i += 1;
}
Expand Down Expand Up @@ -679,9 +682,11 @@ fn draw_mouse_system(
ShapeBuilder::with(&shape).stroke((color, 2.0)).build(),
Transform::from_translation(mouse_snapped.0.extend(layer::CURSOR)),
Cursor,
StateScoped(GameState::Playing),
));
}

// TODO move this bit to a separate system in road_drawing.rs
if !line_drawing.is_changed() {
return;
}
Expand All @@ -704,6 +709,7 @@ fn draw_mouse_system(
.build(),
Transform::from_xyz(0.0, 0.0, layer::ROAD_OVERLAY),
DrawingLine,
StateScoped(GameState::Playing),
));
}
}
Expand Down Expand Up @@ -851,6 +857,7 @@ fn spawn_road_segment(
.build(),
Transform::from_xyz(0.0, 0.0, layer::ROAD - segment.layer as f32),
segment.clone(),
StateScoped(GameState::Playing),
))
.with_children(|parent| {
parent.spawn((
Expand Down Expand Up @@ -890,6 +897,7 @@ fn spawn_obstacle(commands: &mut Commands, obstacle: &Obstacle) {
.fill(theme::OBSTACLE)
.build(),
Transform::from_translation(origin.extend(layer::OBSTACLE)),
StateScoped(GameState::Playing),
))
.with_children(|parent| {
parent.spawn((
Expand Down Expand Up @@ -942,6 +950,7 @@ fn spawn_name(
TextColor(theme::LEVEL_NAME.into()),
Anchor::TopLeft,
Transform::from_translation((name_position + Vec2::new(8., -8.)).extend(layer::GRID)),
StateScoped(GameState::Playing),
));
}

Expand All @@ -965,6 +974,7 @@ fn spawn_terminus(
.build(),
Transform::from_translation(terminus.point.extend(layer::TERMINUS)),
terminus.clone(),
StateScoped(GameState::Playing),
))
.with_children(|parent| {
parent.spawn((Collider::Point(terminus.point), ColliderLayer(1)));
Expand Down Expand Up @@ -1176,15 +1186,6 @@ fn update_elapsed_text_system(
}
}

fn playing_exit_system(
mut commands: Commands,
query: Query<Entity, (Without<MainCamera>, Without<Window>)>,
) {
for entity in query.iter() {
commands.entity(entity).despawn();
}
}

fn save_solution_system(
query: Query<&RoadSegment>,
graph: Res<RoadGraph>,
Expand Down Expand Up @@ -1236,6 +1237,7 @@ fn spawn_level(
.build(),
Transform::from_xyz(x as f32, y as f32, layer::GRID),
GridPoint,
StateScoped(GameState::Playing),
));
}
}
Expand Down Expand Up @@ -1308,14 +1310,18 @@ fn spawn_game_ui(
let mut tool_button_ids = vec![];

commands
.spawn(Node {
width: Val::Percent(100.),
height: Val::Percent(100.),
flex_direction: FlexDirection::ColumnReverse,
justify_content: JustifyContent::FlexStart,
align_items: AlignItems::Center,
..default()
})
.spawn((
Name::new("GameUiRoot"),
Node {
width: Val::Percent(100.),
height: Val::Percent(100.),
flex_direction: FlexDirection::ColumnReverse,
justify_content: JustifyContent::FlexStart,
align_items: AlignItems::Center,
..default()
},
StateScoped(GameState::Playing),
))
.with_children(|parent| {
// bottom bar
parent
Expand Down
5 changes: 3 additions & 2 deletions src/net_ripping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use crate::{
collision::{point_segment_collision, PointCollision},
layer,
sim::SimulationState,
Collider, ColliderLayer, DrawingInteraction, DrawingMouseMovement, MouseSnappedPos, RoadGraph,
RoadSegment, SegmentGraphNodes, SelectedTool, Tool,
Collider, ColliderLayer, DrawingInteraction, DrawingMouseMovement, GameState, MouseSnappedPos,
RoadGraph, RoadSegment, SegmentGraphNodes, SelectedTool, Tool,
};

pub struct NetRippingPlugin;
Expand Down Expand Up @@ -159,6 +159,7 @@ fn draw_net_ripping_system(
.build(),
Transform::from_xyz(0.0, 0.0, layer::ROAD_OVERLAY),
RippingLine,
StateScoped(GameState::Playing),
));
}
}
2 changes: 2 additions & 0 deletions src/pixie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ pub fn explode_pixies_system(mut commands: Commands, query: Query<(Entity, &Pixi
direction: Vec2::new(cos, sin),
..default()
},
StateScoped(GameState::Playing),
));
}
}
Expand Down Expand Up @@ -518,6 +519,7 @@ pub fn emit_pixies_system(mut q_emitters: Query<&mut PixieEmitter>, mut commands
path_index: 0,
..default()
},
StateScoped(GameState::Playing),
));

emitter.remaining -= 1;
Expand Down
Loading
Loading