add fence to static worldgen
All checks were successful
Rust / rustfmt (pull_request) Successful in 20s
Rust / clippy (pull_request) Successful in 58s
Rust / build (pull_request) Successful in 2m13s

This commit is contained in:
Dominic 2024-07-06 23:17:18 +02:00
parent c03ad41f45
commit 3a5ae15c41
Signed by: msrd0
GPG key ID: AAF7C8430CA3345D

View file

@ -28,6 +28,13 @@ pub enum Tile {
bottom: bool bottom: bool
}, },
Fence {
left: bool,
right: bool,
top: bool,
bottom: bool
},
House { House {
texture: TextureHandle, texture: TextureHandle,
door: bool door: bool
@ -71,6 +78,38 @@ impl Tile {
vec![ASSETS.overworld.grass, path_texture] vec![ASSETS.overworld.grass, path_texture]
}, },
Self::Fence {
left,
right,
top,
bottom
} => {
let path_texture = match (left, right, top, bottom) {
(true, true, false, false) => ASSETS.overworld.fence_horiz,
(false, false, true, true) => ASSETS.overworld.fence_vert,
(true, false, true, false) => ASSETS.overworld.fence_top_left,
(true, false, false, true) => ASSETS.overworld.fence_bottom_left,
(false, true, true, false) => ASSETS.overworld.fence_top_right,
(false, true, false, true) => ASSETS.overworld.fence_bottom_right,
(true, true, true, false)
| (true, true, false, true)
| (true, false, true, true)
| (false, true, true, true) => unimplemented!(),
(true, true, true, true) => unimplemented!(),
(true, false, false, false)
| (false, true, false, false)
| (false, false, true, false)
| (false, false, false, true) => panic!("We don't have no dead ends"),
(false, false, false, false) => panic!("I think you meant grass?!?")
};
vec![ASSETS.overworld.grass, path_texture]
},
Self::House { texture, .. } => { Self::House { texture, .. } => {
vec![ASSETS.overworld.grass, *texture] vec![ASSETS.overworld.grass, *texture]
} }
@ -123,15 +162,6 @@ impl Chunk {
// TODO real worldgen // TODO real worldgen
// for the time being we just copy this pre-made house block into the chunk // for the time being we just copy this pre-made house block into the chunk
fn path(left: bool, right: bool, top: bool, bottom: bool) -> Tile {
Tile::Path {
left,
right,
top,
bottom
}
}
fn house(texture: TextureHandle) -> Tile { fn house(texture: TextureHandle) -> Tile {
Tile::House { Tile::House {
texture, texture,
@ -139,14 +169,42 @@ impl Chunk {
} }
} }
let path_horiz = path(true, true, false, false); let path_horiz = Tile::Path {
let path_vert = path(false, false, true, true); left: true,
let path_crossing = path(true, true, true, true); right: true,
top: false,
bottom: false
};
let path_vert = Tile::Path {
left: false,
right: false,
top: true,
bottom: true
};
let path_crossing = Tile::Path {
left: true,
right: true,
top: true,
bottom: true
};
let fence_horiz = Tile::Fence {
left: true,
right: true,
top: false,
bottom: false
};
let fence_vert = Tile::Fence {
left: false,
right: false,
top: true,
bottom: true
};
let grass = Tile::Grass; let grass = Tile::Grass;
let block = [ let block = [
[ [
path_crossing, path_horiz,
path_horiz,
path_horiz, path_horiz,
path_horiz, path_horiz,
path_horiz, path_horiz,
@ -159,7 +217,31 @@ impl Chunk {
path_crossing path_crossing
], ],
[ [
path_vert, Tile::Fence {
left: false,
right: true,
top: false,
bottom: true
},
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
Tile::Fence {
left: true,
right: false,
top: false,
bottom: true
},
path_vert
],
[
fence_vert,
grass, grass,
grass, grass,
grass, grass,
@ -169,10 +251,11 @@ impl Chunk {
grass, grass,
grass, grass,
grass, grass,
fence_vert,
path_vert path_vert
], ],
[ [
path_vert, fence_vert,
grass, grass,
grass, grass,
house(ASSETS.overworld.house_roof_mid_left), house(ASSETS.overworld.house_roof_mid_left),
@ -182,10 +265,11 @@ impl Chunk {
grass, grass,
grass, grass,
grass, grass,
fence_vert,
path_vert path_vert
], ],
[ [
path_vert, fence_vert,
grass, grass,
house(ASSETS.overworld.house_roof_left), house(ASSETS.overworld.house_roof_left),
house(ASSETS.overworld.house_mid_window), house(ASSETS.overworld.house_mid_window),
@ -195,10 +279,11 @@ impl Chunk {
grass, grass,
grass, grass,
grass, grass,
fence_vert,
path_vert path_vert
], ],
[ [
path_vert, fence_vert,
grass, grass,
house(ASSETS.overworld.house_bottom_left), house(ASSETS.overworld.house_bottom_left),
house(ASSETS.overworld.house_bottom_door), house(ASSETS.overworld.house_bottom_door),
@ -208,27 +293,63 @@ impl Chunk {
grass, grass,
grass, grass,
grass, grass,
fence_vert,
path_vert path_vert
], ],
[ [
path_vert, fence_vert,
grass, grass,
grass, grass,
path(false, true, true, false), Tile::Path {
left: false,
right: true,
top: true,
bottom: false
},
path_horiz, path_horiz,
path_horiz, path_horiz,
path_horiz, path_horiz,
path_horiz, path_horiz,
path_horiz, path_horiz,
path_horiz, path_horiz,
path(true, false, true, true) fence_vert,
Tile::Path {
left: true,
right: false,
top: true,
bottom: true
}
], ],
[ [
path_vert, grass, grass, grass, grass, grass, grass, grass, grass, grass, fence_vert, grass, grass, grass, grass, grass, grass, grass, grass,
path_vert grass, fence_vert, path_vert
], ],
[ [
path_vert, grass, grass, grass, grass, grass, grass, grass, grass, grass, fence_vert, grass, grass, grass, grass, grass, grass, grass, grass,
grass, fence_vert, path_vert
],
[
Tile::Fence {
left: false,
right: true,
top: true,
bottom: false
},
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
fence_horiz,
Tile::Fence {
left: true,
right: false,
top: true,
bottom: false
},
path_vert path_vert
] ]
]; ];