Winter Is Coming


Adds dynamic winter - summer cycles with a moving cold snow front that gradually freezes and thaws the map. Turns natural bodies of water into ice and back. And a Christmas tree as a bonus :)

Content
8 days ago
2.0
257
Environment

g Winter Detection Hooks

10 days ago
(updated 9 days ago)

Hello!

Love the look of this. It's both awesome and terrifying. :)

Are there any hooks for detecting when it's winter? My treez mod has some tile upgrade mechanics with nitrate pellets and I want to work out and make sure these two place nice. I was inspired by TerrainEvolution's tile devolution and evolution mechanics.

The my first idea would be to have the upgrade tile code check if it's winter (and of course if winter is coming is installed). If it is winter, do nothing until it's not. If it's not winter, then proceed with tile restoration/destruction. That'd leave the tile swapping to winter is coming which hopefully should allow the two to place nice.

Alternatively if it makes more sense to just avoid the problem entirely by marking our mods as incompatible I'm completely fine with that solution as well. What are your thoughts?

8 days ago

Hello!
Thanks for the interest!

Winter Is Coming keeps an internal snapshot of the "warm" terrain tiles, then replaces the visible tiles with winter variants while freezing is active. When the world thaws, it restores the terrain from that warm snapshot.

So for compatibility, the important part is that terrain-changing mods raise tile-change events when they modify terrain:

surface.set_tiles(..., raise_event = true)

That raise_event = true allows Winter Is Coming to detect the change and update its warm-tile snapshot. If the changed position is currently behind the snow front / in winter, WIC can then immediately redraw the visible tile using the winter version.

Winter tile selection works like this:

  1. explicit WIC mappings, for special cases like water -> ice and vanilla dirt/grass -> snow variants
  2. frozen-<tile-name>, if such a tile prototype exists
  3. fallback to snow-flat

So if another mod provides a tile called my-soil, and also provides frozen-my-soil, WIC should automatically use frozen-my-soil as the winter display tile. If no frozen variant exists, it falls back to snow.

For Treez specifically, if your tile upgrades are intended to change the underlying/base terrain, I think the best integration approach is to keep doing the upgrades, but call surface.set_tiles with raise_event = true. Then WIC can treat your change as the new warm terrain and handle the winter rendering itself.

I also think your idea of exposing seasonal state hooks makes sense, although perhaps for slightly different goals.

What do you think?

8 days ago

That sounds good and quite work-able, thank ya! :) That should be easy enough to modify and add, I'll try coding that up today.

8 days ago

Cool!

Please use the latest 0.3.1 version. I've fixed some bugs and brought the behavior in line with what I described above

New response