175 lines
4.3 KiB
GDScript3
175 lines
4.3 KiB
GDScript3
|
class_name ScreenEffectsConfiguration extends Resource
|
||
|
|
||
|
enum Weather {
|
||
|
CLEAR,
|
||
|
SPRINKLE,
|
||
|
DRIZZLE,
|
||
|
RAIN,
|
||
|
DOWNPOUR,
|
||
|
STORM,
|
||
|
SNOW,
|
||
|
SNOWSTORM
|
||
|
}
|
||
|
|
||
|
enum TimeOfDay {
|
||
|
MORNING,
|
||
|
DAY,
|
||
|
AFTERNOON,
|
||
|
EVENING,
|
||
|
NIGHT
|
||
|
}
|
||
|
|
||
|
@export var transition: float = ScreenEffects.LONGEST_DEFAULT_TRANSITION
|
||
|
@export var set_light_source := false
|
||
|
@export var light_source := Vector3.UP - Vector3.BACK
|
||
|
@export var set_tint := false
|
||
|
@export var tint := Color.WHITE
|
||
|
@export var set_fade := false
|
||
|
@export var fade := Color.TRANSPARENT
|
||
|
@export var set_weather := false
|
||
|
@export var weather := Weather.CLEAR
|
||
|
@export var set_time_of_day := false
|
||
|
@export var time_of_day := TimeOfDay.DAY
|
||
|
@export var override_overcast := false
|
||
|
@export var overcast_override: float = ScreenEffects.NORMAL_OVERCAST
|
||
|
@export var override_brightness := false
|
||
|
@export var brightness_override: float = ScreenEffects.NORMAL_BRIGHTNESS
|
||
|
@export var override_wind := false
|
||
|
@export var wind_override: float = ScreenEffects.NORMAL_WIND
|
||
|
@export var set_twist := false
|
||
|
@export var twist: float = ScreenEffects.NORMAL_TWIST
|
||
|
@export var set_psychedelic := false
|
||
|
@export var psychedelic: float = ScreenEffects.NORMAL_PSYCHEDELIC
|
||
|
|
||
|
func apply(
|
||
|
transition_override: float = -1.0
|
||
|
) -> void:
|
||
|
var jobs: Array[Callable] = []
|
||
|
var job: Callable
|
||
|
if transition_override < 0.0:
|
||
|
transition_override = transition
|
||
|
if set_light_source:
|
||
|
job = func():
|
||
|
await FX.light_source(light_source, transition_override)
|
||
|
jobs.push_back(job)
|
||
|
if set_tint:
|
||
|
job = func():
|
||
|
await FX.tint(tint, transition_override)
|
||
|
jobs.push_back(job)
|
||
|
if set_fade:
|
||
|
job = func():
|
||
|
await FX.fade(fade, transition_override)
|
||
|
jobs.push_back(job)
|
||
|
if set_weather:
|
||
|
match weather:
|
||
|
Weather.CLEAR:
|
||
|
job = func():
|
||
|
await FX.stop_weather(
|
||
|
transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
Weather.SPRINKLE:
|
||
|
job = func():
|
||
|
await FX.rain(
|
||
|
1, transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
Weather.DRIZZLE:
|
||
|
job = func():
|
||
|
await FX.rain(
|
||
|
2, transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
Weather.RAIN:
|
||
|
job = func():
|
||
|
await FX.rain(
|
||
|
3, transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
Weather.DOWNPOUR:
|
||
|
job = func():
|
||
|
await FX.rain(
|
||
|
4, transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
Weather.STORM:
|
||
|
job = func():
|
||
|
await FX.rain(
|
||
|
5, transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
Weather.SNOW:
|
||
|
job = func():
|
||
|
await FX.snow(
|
||
|
1, transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
Weather.SNOWSTORM:
|
||
|
job = func():
|
||
|
await FX.snow(
|
||
|
2, transition_override,
|
||
|
bool(override_overcast),
|
||
|
bool(override_brightness),
|
||
|
bool(override_wind)
|
||
|
)
|
||
|
_: job = func():
|
||
|
push_warning("Invalid weather %d" % weather)
|
||
|
jobs.push_back(job)
|
||
|
if override_overcast:
|
||
|
job = func():
|
||
|
await FX.overcast(
|
||
|
overcast_override,
|
||
|
transition_override,
|
||
|
bool(override_brightness)
|
||
|
)
|
||
|
jobs.push_back(job)
|
||
|
if override_brightness:
|
||
|
job = func():
|
||
|
await FX.brightness(brightness_override, transition_override)
|
||
|
jobs.push_back(job)
|
||
|
if override_wind:
|
||
|
job = func():
|
||
|
FX.wind(wind_override, transition_override)
|
||
|
jobs.push_back(job)
|
||
|
if set_twist:
|
||
|
job = func():
|
||
|
FX.twist(twist, transition_override)
|
||
|
if set_psychedelic:
|
||
|
job = func():
|
||
|
FX.psychedelic(psychedelic, transition_override)
|
||
|
if set_time_of_day:
|
||
|
match time_of_day:
|
||
|
TimeOfDay.MORNING:
|
||
|
job = func():
|
||
|
await FX.morning(transition_override)
|
||
|
TimeOfDay.DAY:
|
||
|
job = func():
|
||
|
await FX.day(transition_override)
|
||
|
TimeOfDay.AFTERNOON:
|
||
|
job = func():
|
||
|
await FX.afternoon(transition_override)
|
||
|
TimeOfDay.EVENING:
|
||
|
job = func():
|
||
|
await FX.evening(transition_override)
|
||
|
TimeOfDay.NIGHT:
|
||
|
job = func():
|
||
|
await FX.night(transition_override)
|
||
|
_: job = func():
|
||
|
push_warning("Invalid time of day %d" % time_of_day)
|
||
|
jobs.push_back(job)
|
||
|
await Promise.new(jobs).join()
|