-
Notifications
You must be signed in to change notification settings - Fork 390
TimeAndWeather: Reduce night 2 hours #2391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
scenes/game_elements/fx/time_and_weather/components/clouds_shadows_schedule.tres
This file contains hidden or 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,8 @@ | ||
| [gd_resource type="Resource" script_class="EffectSchedule" format=3 uid="uid://jytd1cp6ogb3"] | ||
|
|
||
| [ext_resource type="Script" uid="uid://djxha2otlvvea" path="res://scenes/game_elements/fx/time_and_weather/components/effect_schedule.gd" id="1_mnedg"] | ||
|
|
||
| [resource] | ||
| script = ExtResource("1_mnedg") | ||
| start_time = 7.0 | ||
| stop_time = 17.0 |
This file contains hidden or 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
13 changes: 13 additions & 0 deletions
13
scenes/game_elements/fx/time_and_weather/components/effect_schedule.gd
This file contains hidden or 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,13 @@ | ||
| # SPDX-FileCopyrightText: The Threadbare Authors | ||
| # SPDX-License-Identifier: MPL-2.0 | ||
| class_name EffectSchedule | ||
| extends Resource | ||
| ## @experimental | ||
| ## | ||
| ## Schedule times for effects in [TimeAndWeather]. | ||
|
|
||
| ## The effect start time in the 24-hour clock. For 4 PM set it to 16. | ||
| @export_range(0.0, 24.0, 0.1, "suffix:h") var start_time: float | ||
|
|
||
| ## The effect stop time in the 24-hour clock. For 4 PM set it to 16. | ||
| @export_range(0.0, 24.0, 0.1, "suffix:h") var stop_time: float |
1 change: 1 addition & 0 deletions
1
scenes/game_elements/fx/time_and_weather/components/effect_schedule.gd.uid
This file contains hidden or 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 @@ | ||
| uid://djxha2otlvvea |
8 changes: 8 additions & 0 deletions
8
scenes/game_elements/fx/time_and_weather/components/fog_schedule.tres
This file contains hidden or 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,8 @@ | ||
| [gd_resource type="Resource" script_class="EffectSchedule" format=3 uid="uid://bcoehk7j53s33"] | ||
|
|
||
| [ext_resource type="Script" uid="uid://djxha2otlvvea" path="res://scenes/game_elements/fx/time_and_weather/components/effect_schedule.gd" id="1_gaagd"] | ||
|
|
||
| [resource] | ||
| script = ExtResource("1_gaagd") | ||
| start_time = 23.0 | ||
| stop_time = 4.0 |
8 changes: 8 additions & 0 deletions
8
scenes/game_elements/fx/time_and_weather/components/lights_schedule.tres
This file contains hidden or 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,8 @@ | ||
| [gd_resource type="Resource" script_class="EffectSchedule" format=3 uid="uid://cb514qccge0gq"] | ||
|
|
||
| [ext_resource type="Script" uid="uid://djxha2otlvvea" path="res://scenes/game_elements/fx/time_and_weather/components/effect_schedule.gd" id="1_7gm1k"] | ||
|
|
||
| [resource] | ||
| script = ExtResource("1_7gm1k") | ||
| start_time = 20.0 | ||
| stop_time = 4.0 |
This file contains hidden or 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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,6 +42,17 @@ const SECONDS_PER_DAY: float = 24 * 60 * 60 | |||||||||
| @export_range(1.0, 3600.0, 1.0) var time_scale: float = 144.0: | ||||||||||
| set = _set_time_scale | ||||||||||
|
|
||||||||||
| @export_group("Effects Schedule") | ||||||||||
|
|
||||||||||
| ## When does the lights on/off effect happens. | ||||||||||
| @export var lights_schedule: EffectSchedule = preload("uid://cb514qccge0gq") | ||||||||||
|
|
||||||||||
| ## When does the cloud shadows effect happens. | ||||||||||
| @export var clouds_shadows_schedule: EffectSchedule = preload("uid://jytd1cp6ogb3") | ||||||||||
|
|
||||||||||
| ## When does the fog effect happens. | ||||||||||
| @export var fog_schedule: EffectSchedule = preload("uid://bcoehk7j53s33") | ||||||||||
|
|
||||||||||
| @export_group("Debugging") | ||||||||||
|
|
||||||||||
| ## Display debugging information on screen. | ||||||||||
|
|
@@ -67,8 +78,8 @@ const SECONDS_PER_DAY: float = 24 * 60 * 60 | |||||||||
| @onready var fog_start_timer: Timer = %FogStartTimer | ||||||||||
| @onready var fog_stop_timer: Timer = %FogStopTimer | ||||||||||
|
|
||||||||||
| ## Label to show debug information. | ||||||||||
| @onready var debug_label: Label = %DebugLabel | ||||||||||
| ## Layer with the debug label. | ||||||||||
| @onready var debug_canvas_layer: CanvasLayer = %DebugCanvasLayer | ||||||||||
|
|
||||||||||
|
|
||||||||||
| func _set_use_system_time(new_use_system_time: bool) -> void: | ||||||||||
|
|
@@ -92,10 +103,10 @@ func _set_show_debug_label(new_show_debug_label: bool) -> void: | |||||||||
| show_debug_label = new_show_debug_label | ||||||||||
| if Engine.is_editor_hint(): | ||||||||||
| return | ||||||||||
| if not debug_label: | ||||||||||
| if not is_node_ready(): | ||||||||||
| return | ||||||||||
| debug_label.visible = show_debug_label | ||||||||||
| debug_label.process_mode = ( | ||||||||||
| debug_canvas_layer.visible = show_debug_label | ||||||||||
| debug_canvas_layer.process_mode = ( | ||||||||||
| Node.PROCESS_MODE_INHERIT if show_debug_label else Node.PROCESS_MODE_DISABLED | ||||||||||
| ) | ||||||||||
|
Comment on lines
+109
to
111
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another way to spell this would be:
Suggested change
|
||||||||||
|
|
||||||||||
|
|
@@ -129,20 +140,23 @@ func set_time(new_time: float) -> void: | |||||||||
| _seek_animation(new_time) | ||||||||||
|
|
||||||||||
| # Change game state darkness so artificial lights can turn on/off. | ||||||||||
| var lights_on := new_time < 5 or new_time >= 19 | ||||||||||
| var lights_on := new_time < lights_schedule.stop_time or new_time >= lights_schedule.start_time | ||||||||||
| GameState.scene.set_lights_on(lights_on, true) | ||||||||||
| _schedule_timer(lights_off_timer, 5, new_time) | ||||||||||
| _schedule_timer(lights_on_timer, 19, new_time) | ||||||||||
| _schedule_timer(lights_off_timer, lights_schedule.stop_time, new_time) | ||||||||||
| _schedule_timer(lights_on_timer, lights_schedule.start_time, new_time) | ||||||||||
|
|
||||||||||
| # Cloud shadows during the day: | ||||||||||
| clouds_shadow.visible = new_time >= 6 and new_time < 17 | ||||||||||
| _schedule_timer(clouds_shadow_start_timer, 6, new_time) | ||||||||||
| _schedule_timer(clouds_shadow_stop_timer, 17, new_time) | ||||||||||
| clouds_shadow.visible = ( | ||||||||||
| new_time >= clouds_shadows_schedule.start_time | ||||||||||
| and new_time < clouds_shadows_schedule.stop_time | ||||||||||
| ) | ||||||||||
| _schedule_timer(clouds_shadow_start_timer, clouds_shadows_schedule.start_time, new_time) | ||||||||||
| _schedule_timer(clouds_shadow_stop_timer, clouds_shadows_schedule.stop_time, new_time) | ||||||||||
|
|
||||||||||
| # Fog during late night and early in the morning: | ||||||||||
| fog.visible = new_time < 5 or new_time >= 22 | ||||||||||
| _schedule_timer(fog_start_timer, 22, new_time) | ||||||||||
| _schedule_timer(fog_stop_timer, 5, new_time) | ||||||||||
| fog.visible = new_time < fog_schedule.stop_time or new_time >= fog_schedule.start_time | ||||||||||
| _schedule_timer(fog_start_timer, fog_schedule.start_time, new_time) | ||||||||||
| _schedule_timer(fog_stop_timer, fog_schedule.stop_time, new_time) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| ## Get the current time. | ||||||||||
|
|
||||||||||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea!