"use strict"; (function (global) { const WEATHER_STATES = Object.freeze(["sunny", "cloudy", "light_rain"]); const WeatherSystem = Object.freeze({ states: WEATHER_STATES, chooseNext(current = "sunny") { const choices = current === "light_rain" ? ["sunny", "cloudy"] : ["sunny", "cloudy", "light_rain"]; return pick(choices); }, resetTimer() { return rand(CONFIG.weatherChangeMin, CONFIG.weatherChangeMax); }, shouldDropRainWater(worldRef, dt = 0) { return Boolean( worldRef?.weather === "light_rain" && (worldRef.itemCounts?.water || 0) < 24 && Math.random() < Math.max(0, Number(dt) || 0) * 0.12 ); }, createRainWaterItem(worldRef) { const drop = new Item("water", rand(58, worldRef.w - 58), rand(58, worldRef.h - 58)); drop.amount = rand(24, 58); return drop; }, applyNextWeather(worldRef) { if (!worldRef) return null; const previous = worldRef.weather || "sunny"; const next = this.chooseNext(previous); worldRef.weather = next; worldRef.nextWeatherChange = this.resetTimer(); if (next !== previous) { worldRef.emit?.("weather:changed", { previous, next }); worldRef.log?.(`\u5929\u6c17: ${weatherLabel(next)}`); } return next; }, }); global.TarinaiWeatherSystem = WeatherSystem; })(typeof window !== "undefined" ? window : globalThis);