Seasons: snow above ground in winter, glowing pumpkins at Halloween
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
95f9512b83
commit
74837f1c34
3 files changed
+62
-2
No files matched your search
+30
-2
@@ -440,6 +440,24 @@ impl MB {
|
||||
}
|
||||
}
|
||||
|
||||
// the season of the real date: 0 none, 1 Halloween (20 Oct - 5 Nov), 2 winter (Dec - Feb)
|
||||
pub fn season() -> u8 {
|
||||
thread_local! {
|
||||
static SEASON: std::cell::Cell<u8> = const { std::cell::Cell::new(255) };
|
||||
}
|
||||
SEASON.with(|s| {
|
||||
if s.get() == 255 {
|
||||
let (_, m, d, _, _) = crate::cloud::civil(macroquad::miniquad::date::now() as i64);
|
||||
s.set(match (m, d) {
|
||||
(10, 20..=31) | (11, 1..=5) => 1,
|
||||
(12, _) | (1, _) | (2, _) => 2,
|
||||
_ => 0,
|
||||
});
|
||||
}
|
||||
s.get()
|
||||
})
|
||||
}
|
||||
|
||||
// the researched level of the room on tile t (1: none)
|
||||
fn room_level_at(map: &Map, t: &Tile) -> u8 {
|
||||
if map.upgrades.is_empty() {
|
||||
@@ -693,7 +711,7 @@ fn build_chunk(map: &Map, amb: &[f32], glow: &[f32], cx: i32, cz: i32, atlas: &T
|
||||
let mut tex = Gfx::tile_tex(t.kind, t.owner, t.var, t.reinforced);
|
||||
// open land above ground is grass (until a master claims it)
|
||||
if map.sky(idx(x, z)) && t.kind == Kind::Floor && t.owner == Owner::None {
|
||||
tex = T_GRASS + (t.var as u32 & 3);
|
||||
tex = if season() == 2 { T_SNOW } else { T_GRASS } + (t.var as u32 & 3);
|
||||
}
|
||||
let (ua, ub) = cell_uv(tex);
|
||||
let (xf, zf) = (x as f32, z as f32);
|
||||
@@ -889,6 +907,15 @@ fn build_chunk(map: &Map, amb: &[f32], glow: &[f32], cx: i32, cz: i32, atlas: &T
|
||||
}
|
||||
// room decor
|
||||
let dc = col(lava_lit(Vec3::splat(amb_at(amb, xf + 0.5, zf + 0.5)), lava_at(glow, xf + 0.5, zf + 0.5)), 1.0);
|
||||
// Halloween: now and then a glowing pumpkin on the dungeon's plain floor
|
||||
if season() == 1 && t.kind == Kind::Floor && t.owner == Owner::Player {
|
||||
let hsh = (x as u32).wrapping_mul(2246822519) ^ (z as u32).wrapping_mul(3266489917);
|
||||
if (hsh >> 7) % 37 == 0 {
|
||||
let (cx, cz) = (xf + 0.3 + ((hsh >> 3) % 4) as f32 * 0.1, zf + 0.35);
|
||||
let pc = col(Vec3::splat(1.4), 1.0);
|
||||
mb.boxy(vec3(cx - 0.14, 0.0, cz - 0.14), vec3(cx + 0.14, 0.24, cz + 0.14), T_PUMPKIN, pc, pc);
|
||||
}
|
||||
}
|
||||
if t.plant() {
|
||||
// a giant mushroom or a tree (marked for felling: a yellow tint)
|
||||
let (cx, cz) = (xf + 0.5, zf + 0.5);
|
||||
@@ -908,7 +935,8 @@ fn build_chunk(map: &Map, amb: &[f32], glow: &[f32], cx: i32, cz: i32, atlas: &T
|
||||
let tc = tint(Vec3::splat(a.max(0.3)));
|
||||
mb.boxy(vec3(cx - 0.12, 0.0, cz - 0.12), vec3(cx + 0.12, 0.9 * s, cz + 0.12), T_BARK, tc, tc);
|
||||
let lc = tint(Vec3::splat(a.max(0.3) * 0.9));
|
||||
let top = tint(Vec3::splat(a.max(0.3) * 1.1));
|
||||
// snow on the crowns in winter
|
||||
let top = if season() == 2 { col(Vec3::splat(a.max(0.3) * 2.2), 1.0) } else { tint(Vec3::splat(a.max(0.3) * 1.1)) };
|
||||
let leaves = T_LEAVES + (t.var as u32 & 1);
|
||||
mb.boxy(vec3(cx - 0.48, 0.75 * s, cz - 0.48), vec3(cx + 0.48, 1.55 * s, cz + 0.48), leaves, lc, top);
|
||||
mb.boxy(vec3(cx - 0.3, 1.55 * s, cz - 0.3), vec3(cx + 0.3, 1.95 * s, cz + 0.3), leaves, lc, top);
|
||||
|
||||
Reference in new issue
Block a user