Skip to content

Commit

Permalink
fix back/replay
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed Dec 19, 2023
1 parent 1decef3 commit bbbe714
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
24 changes: 15 additions & 9 deletions src/buildings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ impl BuildingInventory {
inventory.items.pop_front();

let new_building = get_random_building(&mut rng);
let new_item = params.command.spawn(new_building).id();
let new_item = params
.command
.spawn((new_building, MarkerGameStatePlaying))
.id();

inventory.items.push_back(new_item);

Expand Down Expand Up @@ -158,14 +161,17 @@ const PADDING: f32 = 10f32;

pub(crate) fn spawn_layout(mut commands: Commands, window_size: ResMut<WindowSize>) {
let mut rng = crate::random::RandomDeterministic::new_from_seed(0);
let inventory = vec![
commands.spawn(get_random_building(&mut rng)).id(),
commands.spawn(get_random_building(&mut rng)).id(),
commands.spawn(get_random_building(&mut rng)).id(),
commands.spawn(get_random_building(&mut rng)).id(),
commands.spawn(get_random_building(&mut rng)).id(),
commands.spawn(get_random_building(&mut rng)).id(),
];
let inventory = {
let mut inventory = vec![];
for _ in 0..6 {
inventory.push(
commands
.spawn((get_random_building(&mut rng), MarkerGameStatePlaying))
.id(),
);
}
inventory
};
let anchor_point = Vec3::new(
-window_size.size.x / 2f32 + ITEM_VISUAL_SIZE / 2f32 + PADDING,
-window_size.size.y / 2f32 + (ITEM_VISUAL_SIZE + PADDING) * 5.5f32 + PADDING,
Expand Down
15 changes: 5 additions & 10 deletions src/grid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ fn update_distances(
grid: Res<HexGrid>,
mut hexes: Query<(&mut HexCell, &Handle<HexMaterial>)>,
mut materials: ResMut<Assets<HexMaterial>>,
mut colored: Local<bool>,
) {
let center = Hex::ZERO;
let mut queue = vec![center];
Expand Down Expand Up @@ -155,21 +154,17 @@ fn update_distances(
processed.insert(neighbor);
next_queue.push(neighbor);
}
// TODO: debug purposes only, find a better way to color the field
if !*colored {
let v = dist as f32 / MAP_RADIUS as f32;
let material = materials.get_mut(hex_material).unwrap();
material.color.x = v;
material.color.y = v;
material.color.z = v;
}
let v = dist as f32 / (MAP_RADIUS * 2) as f32;
let material = materials.get_mut(hex_material).unwrap();
material.color.x = v;
material.color.y = v;
material.color.z = v;
}
}
}
queue = next_queue;
dist += 1;
}
*colored = true;
}

fn update_unconstructible_hexes(
Expand Down

0 comments on commit bbbe714

Please sign in to comment.