Remove remaining unnecessary casts in examples

This commit is contained in:
Ryan 2022-12-19 06:11:03 -08:00
parent 985f7891e4
commit 4e302ca09f
4 changed files with 10 additions and 20 deletions

View file

@ -86,7 +86,7 @@ impl Config for Game {
for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 { for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 {
for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 { for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 {
world.chunks.insert( world.chunks.insert(
[chunk_x as i32, chunk_z as i32], [chunk_x, chunk_z],
UnloadedChunk::default(), UnloadedChunk::default(),
(), (),
); );

View file

@ -90,11 +90,9 @@ impl Config for Game {
for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 { for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 {
for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 { for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 {
world.chunks.insert( world
[chunk_x as i32, chunk_z as i32], .chunks
UnloadedChunk::default(), .insert([chunk_x, chunk_z], UnloadedChunk::default(), ());
(),
);
} }
} }
} }
@ -267,10 +265,7 @@ impl Config for Game {
for chunk_x in 0..Integer::div_ceil(&SIZE_X, &16) { for chunk_x in 0..Integer::div_ceil(&SIZE_X, &16) {
for chunk_z in 0..Integer::div_ceil(&SIZE_Z, &16) { for chunk_z in 0..Integer::div_ceil(&SIZE_Z, &16) {
let chunk = world let chunk = world.chunks.get_mut([chunk_x, chunk_z]).unwrap();
.chunks
.get_mut((chunk_x as i32, chunk_z as i32))
.unwrap();
for x in 0..16 { for x in 0..16 {
for z in 0..16 { for z in 0..16 {
let cell_x = chunk_x * 16 + x; let cell_x = chunk_x * 16 + x;

View file

@ -78,21 +78,16 @@ impl Config for Game {
// initialize chunks // initialize chunks
for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 { for chunk_z in -2..Integer::div_ceil(&(SIZE_Z as i32), &16) + 2 {
for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 { for chunk_x in -2..Integer::div_ceil(&(SIZE_X as i32), &16) + 2 {
world.chunks.insert( world
[chunk_x as i32, chunk_z as i32], .chunks
UnloadedChunk::default(), .insert([chunk_x, chunk_z], UnloadedChunk::default(), ());
(),
);
} }
} }
// initialize blocks in the chunks // initialize blocks in the chunks
for chunk_x in 0..Integer::div_ceil(&SIZE_X, &16) { for chunk_x in 0..Integer::div_ceil(&SIZE_X, &16) {
for chunk_z in 0..Integer::div_ceil(&SIZE_Z, &16) { for chunk_z in 0..Integer::div_ceil(&SIZE_Z, &16) {
let chunk = world let chunk = world.chunks.get_mut([chunk_x, chunk_z]).unwrap();
.chunks
.get_mut((chunk_x as i32, chunk_z as i32))
.unwrap();
for x in 0..16 { for x in 0..16 {
for z in 0..16 { for z in 0..16 {
let cell_x = chunk_x * 16 + x; let cell_x = chunk_x * 16 + x;

View file

@ -257,7 +257,7 @@ fn reset(client: &mut Client<Game>, world: &mut World<Game>) {
for chunk_z in -1..3 { for chunk_z in -1..3 {
for chunk_x in -2..2 { for chunk_x in -2..2 {
world.chunks.insert( world.chunks.insert(
(chunk_x, chunk_z), [chunk_x, chunk_z],
UnloadedChunk::default(), UnloadedChunk::default(),
ChunkState { keep_loaded: true }, ChunkState { keep_loaded: true },
); );