-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Очередной костыль от наобновления погоды
- Loading branch information
1 parent
bc52abc
commit 7411c8c
Showing
5 changed files
with
85 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
Game/Resources_SoC_1.0006/gamedata/scripts/level_weathers.script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
class "WeatherManager" | ||
function WeatherManager:__init() | ||
--printf ("WeatherManager:WeatherManager()") | ||
self.weather_change_day = 0 | ||
self.update_time = 0 | ||
self.update_level = "" | ||
end | ||
|
||
function WeatherManager:reset() | ||
--printf ("WeatherManager:WeatherManager():Reset()") | ||
-- Загрузить кондлист с погодой. | ||
local ini = game_ini() --KRodin: так быстрее же, чем через ini_file(). | ||
local weather = utils.cfg_get_string(ini, level.name(), "weathers", db.actor, false, "", "default") | ||
local postprocess = utils.cfg_get_string(ini, level.name(), "postprocess", db.actor, false, "") | ||
if postprocess ~= nil then | ||
printf("LEVEL POSTPROCESS: level: [%s], postprocess: [%s]", level.name(), postprocess) | ||
level.add_pp_effector(postprocess, 999, true) | ||
else | ||
printf("LEVEL POSTPROCESS: level: [%s], postprocess: [none]", level.name()) | ||
level.remove_pp_effector(999) | ||
end | ||
|
||
if weather == "default" then | ||
-- сетим дефолтовую погоду | ||
self.weather_list = xr_logic.parse_condlist(db.actor, level.name(), "weather", "default") | ||
else | ||
self.weather_list = xr_logic.parse_condlist(db.actor, level.name(), "weather", weather) | ||
end | ||
self:select_weather(true) | ||
end | ||
|
||
function WeatherManager:select_weather(now) | ||
self.weather_change_day = level.get_time_days() | ||
self.update_level = level.name() | ||
local weather = xr_logic.pick_section_from_condlist(db.actor, db.actor, self.weather_list) | ||
--printf("WEATHER: '%s' now '%s'", weather, tostring(now)) | ||
|
||
--KRodin: из-за фикса солнца в движке, погоду нужно устанавливать не ранее, чем на первом апдейте! | ||
level.add_call( | ||
function() return true end, | ||
function() level.set_weather(weather, now) end | ||
) | ||
end | ||
|
||
function WeatherManager:load(F) | ||
self.update_level = F:r_stringZ(); | ||
self.update_time = F:r_u32(); | ||
end | ||
|
||
function WeatherManager:save(F) | ||
F:w_stringZ (self.update_level); | ||
F:w_u32 (self.update_time); | ||
end | ||
|
||
function WeatherManager:update() | ||
if self.update_time <= time_global() then | ||
printf("weather_update day [%s]", level.get_time_days()) | ||
|
||
if self.update_level ~= level.name() then | ||
self:select_weather(true) | ||
end | ||
|
||
if self.weather_change_day ~= level.get_time_days() then | ||
self:select_weather(false) | ||
end | ||
self.update_time = self.update_time + 10000 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters