Compare commits
13 Commits
polish1
...
70d3dfe15c
| Author | SHA1 | Date | |
|---|---|---|---|
| 70d3dfe15c | |||
| 72d06560b1 | |||
| 9d62d97422 | |||
| c1e99a3b8e | |||
| 8e1ba915a2 | |||
|
|
577b4570da | ||
| 36dff9c070 | |||
| 56591bb907 | |||
| 9f254d9725 | |||
| abae8434fc | |||
| 3c7cbdc662 | |||
| 8c7f1c3c82 | |||
| b7308c5d66 |
13
.idea/.gitignore
generated
vendored
Normal file
13
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Rider ignored files
|
||||
/contentModel.xml
|
||||
/modules.xml
|
||||
/projectSettingsUpdater.xml
|
||||
/.idea.tgcc.iml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
4
.idea/encodings.xml
generated
Normal file
4
.idea/encodings.xml
generated
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
|
||||
</project>
|
||||
8
.idea/indexLayout.xml
generated
Normal file
8
.idea/indexLayout.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="UserContentModel">
|
||||
<attachedFolders />
|
||||
<explicitIncludes />
|
||||
<explicitExcludes />
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
51
core/ai/agents/base/ai_base.gd
Normal file
51
core/ai/agents/base/ai_base.gd
Normal file
@@ -0,0 +1,51 @@
|
||||
extends CharacterBody3D
|
||||
|
||||
class_name AIBase
|
||||
|
||||
@export var speed: float = 4.0
|
||||
var _enable_state_machine: bool = true
|
||||
@export var enable_state_machine: bool:
|
||||
set(value):
|
||||
_enable_state_machine = value
|
||||
toggle_enable_state_machine()
|
||||
get:
|
||||
return _enable_state_machine
|
||||
|
||||
|
||||
@onready var patrol_radius_shape: CollisionShape3D = $%PatrolRadiusShape
|
||||
@onready var nav_agent: NavigationAgent3D = $%NavigationAgent3D
|
||||
@onready var state_machine: StateMachine = $%StateMachine
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
randomize()
|
||||
toggle_enable_state_machine()
|
||||
|
||||
func toggle_enable_state_machine() -> void:
|
||||
state_machine.enable = _enable_state_machine
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if !_enable_state_machine:
|
||||
return
|
||||
|
||||
state_machine.physics_process(delta)
|
||||
|
||||
if nav_agent.is_navigation_finished():
|
||||
velocity = Vector3.ZERO
|
||||
move_and_slide()
|
||||
return
|
||||
|
||||
var next_point = nav_agent.get_next_path_position()
|
||||
var direction = global_position.direction_to(next_point)
|
||||
|
||||
velocity.x = direction.x * speed
|
||||
velocity.z = direction.z * speed
|
||||
|
||||
move_and_slide()
|
||||
|
||||
func navigate_to_random_point() -> void:
|
||||
var nav_map_rid = get_world_3d().get_navigation_map()
|
||||
var patrol_radius = patrol_radius_shape.shape.radius
|
||||
var target_point_in_space = global_position + Vector3(randf_range(-1, 1), 0, randf_range(-1, 1)).normalized() * randf_range(0, patrol_radius)
|
||||
var closest_valid_point = NavigationServer3D.map_get_closest_point(nav_map_rid, target_point_in_space)
|
||||
nav_agent.target_position = closest_valid_point
|
||||
1
core/ai/agents/base/ai_base.gd.uid
Normal file
1
core/ai/agents/base/ai_base.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b30p1yqojbbbk
|
||||
44
core/ai/agents/base/ai_base.tscn
Normal file
44
core/ai/agents/base/ai_base.tscn
Normal file
@@ -0,0 +1,44 @@
|
||||
[gd_scene format=3 uid="uid://clx701xdwelgx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b30p1yqojbbbk" path="res://core/ai/agents/base/ai_base.gd" id="1_4d1nn"]
|
||||
[ext_resource type="Script" uid="uid://ps3vlu2qvmop" path="res://core/ai/framework/state_machine.gd" id="2_q1hg3"]
|
||||
[ext_resource type="Script" uid="uid://nga8qx56iwgu" path="res://core/ai/agents/base/idle_state.gd" id="3_26faq"]
|
||||
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/agents/base/patrol_state.gd" id="4_lim44"]
|
||||
|
||||
[sub_resource type="CapsuleMesh" id="CapsuleMesh_mh3lg"]
|
||||
|
||||
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_mh3lg"]
|
||||
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_lim44"]
|
||||
radius = 20.0
|
||||
|
||||
[node name="AiBase" type="CharacterBody3D" unique_id=1228675528]
|
||||
script = ExtResource("1_4d1nn")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="." unique_id=214482161]
|
||||
mesh = SubResource("CapsuleMesh_mh3lg")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=92811823]
|
||||
shape = SubResource("CapsuleShape3D_mh3lg")
|
||||
|
||||
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." unique_id=1370024449]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="StateMachine" type="Node" parent="." unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
|
||||
unique_name_in_owner = true
|
||||
script = ExtResource("2_q1hg3")
|
||||
initial_state = NodePath("IdleState")
|
||||
|
||||
[node name="IdleState" type="Node" parent="StateMachine" unique_id=763668255]
|
||||
script = ExtResource("3_26faq")
|
||||
state_id = &"idle"
|
||||
|
||||
[node name="PatrolState" type="Node" parent="StateMachine" unique_id=2054606629]
|
||||
script = ExtResource("4_lim44")
|
||||
state_id = &"patrol"
|
||||
|
||||
[node name="PatrolRadiusShape" type="CollisionShape3D" parent="." unique_id=1379515938]
|
||||
unique_name_in_owner = true
|
||||
shape = SubResource("SphereShape3D_lim44")
|
||||
disabled = true
|
||||
debug_color = Color(1, 1, 0, 1)
|
||||
26
core/ai/agents/base/idle_state.gd
Normal file
26
core/ai/agents/base/idle_state.gd
Normal file
@@ -0,0 +1,26 @@
|
||||
extends State
|
||||
|
||||
const PATROL_STATE_ID: StringName = &"patrol"
|
||||
|
||||
@export var wait_time: float = 3.0
|
||||
|
||||
var runtime_timer: Timer
|
||||
|
||||
func enter() -> void:
|
||||
runtime_timer = Timer.new()
|
||||
runtime_timer.name = "IdleTimer"
|
||||
add_child(runtime_timer)
|
||||
runtime_timer.one_shot = true
|
||||
runtime_timer.timeout.connect(_on_timer_timeout)
|
||||
runtime_timer.start(wait_time)
|
||||
|
||||
func exit() -> void:
|
||||
if runtime_timer:
|
||||
if runtime_timer.is_connected("timeout", _on_timer_timeout):
|
||||
runtime_timer.timeout.disconnect(_on_timer_timeout)
|
||||
|
||||
runtime_timer.queue_free()
|
||||
runtime_timer = null
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
transitioned.emit(self, PATROL_STATE_ID)
|
||||
1
core/ai/agents/base/idle_state.gd.uid
Normal file
1
core/ai/agents/base/idle_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://nga8qx56iwgu
|
||||
12
core/ai/agents/base/patrol_state.gd
Normal file
12
core/ai/agents/base/patrol_state.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends State
|
||||
|
||||
const IDLE_STATE_ID: StringName = &"idle"
|
||||
|
||||
@onready var agent: AIBase = owner
|
||||
|
||||
func enter() -> void:
|
||||
agent.navigate_to_random_point()
|
||||
|
||||
func physics_update(_delta) -> void:
|
||||
if agent.nav_agent.is_navigation_finished():
|
||||
transitioned.emit(self, IDLE_STATE_ID)
|
||||
1
core/ai/agents/base/patrol_state.gd.uid
Normal file
1
core/ai/agents/base/patrol_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bngfthvt04ivv
|
||||
20
core/ai/framework/state.gd
Normal file
20
core/ai/framework/state.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
extends Node
|
||||
|
||||
class_name State
|
||||
|
||||
@export var state_id: StringName = &""
|
||||
|
||||
@warning_ignore("unused_signal")
|
||||
signal transitioned(state: State, new_state_id: StringName)
|
||||
|
||||
func enter() -> void:
|
||||
pass
|
||||
|
||||
func exit() -> void:
|
||||
pass
|
||||
|
||||
func update(_delta) -> void:
|
||||
pass
|
||||
|
||||
func physics_update(_delta) -> void:
|
||||
pass
|
||||
1
core/ai/framework/state.gd.uid
Normal file
1
core/ai/framework/state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dpso7abi5ftyw
|
||||
61
core/ai/framework/state_machine.gd
Normal file
61
core/ai/framework/state_machine.gd
Normal file
@@ -0,0 +1,61 @@
|
||||
extends Node
|
||||
|
||||
class_name StateMachine
|
||||
|
||||
@export var initial_state: State
|
||||
|
||||
var current_state: State
|
||||
var states: Dictionary[StringName, State] = {}
|
||||
var is_initialized: bool = false
|
||||
var _enabled: bool = true
|
||||
var enable: bool:
|
||||
set(value):
|
||||
_enabled = value
|
||||
_set_enabled(value)
|
||||
get:
|
||||
return _enabled
|
||||
|
||||
func _ready() -> void:
|
||||
_initialize_states()
|
||||
_set_enabled(enable)
|
||||
|
||||
func _initialize_states() -> void:
|
||||
if is_initialized:
|
||||
return
|
||||
|
||||
for state in get_children():
|
||||
if state is State:
|
||||
states[state.state_id] = state
|
||||
state.transitioned.connect(_on_state_transition)
|
||||
|
||||
is_initialized = true
|
||||
|
||||
func _set_enabled(value: bool) -> void:
|
||||
_enabled = value
|
||||
|
||||
if not _enabled:
|
||||
return
|
||||
|
||||
_initialize_states()
|
||||
|
||||
if initial_state and current_state == null:
|
||||
current_state = initial_state
|
||||
current_state.enter()
|
||||
|
||||
func physics_process(delta) -> void:
|
||||
if current_state and _enabled:
|
||||
current_state.physics_update(delta)
|
||||
|
||||
func _on_state_transition(state: State, new_state_id: StringName) -> void:
|
||||
if state != current_state:
|
||||
return
|
||||
|
||||
var new_state = states.get(new_state_id)
|
||||
if not new_state:
|
||||
return
|
||||
|
||||
if current_state:
|
||||
current_state.exit()
|
||||
|
||||
current_state = new_state
|
||||
current_state.enter()
|
||||
1
core/ai/framework/state_machine.gd.uid
Normal file
1
core/ai/framework/state_machine.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ps3vlu2qvmop
|
||||
31
core/audio/audio_manager.gd
Normal file
31
core/audio/audio_manager.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends Node
|
||||
|
||||
const MIN_VOLUME: float = 0.0
|
||||
const MAX_VOLUME: float = 1.0
|
||||
|
||||
func _ready() -> void:
|
||||
load_save_data()
|
||||
|
||||
func load_save_data() -> void:
|
||||
for bus_name in GameState.save_data.audio_bus_volumes:
|
||||
_apply_audio_bus_volume(bus_name, GameState.save_data.audio_bus_volumes[bus_name])
|
||||
|
||||
func set_audio_bus_volume(bus_name: StringName, linear_value: float) -> void:
|
||||
var normalized_bus_name := str(bus_name)
|
||||
var clamped_value := clampf(linear_value, MIN_VOLUME, MAX_VOLUME)
|
||||
|
||||
GameState.save_data.audio_bus_volumes[normalized_bus_name] = clamped_value
|
||||
_apply_audio_bus_volume(normalized_bus_name, clamped_value)
|
||||
GameState.save_game()
|
||||
|
||||
func get_audio_bus_volume(bus_name: StringName, default_value: float = 1.0) -> float:
|
||||
return float(GameState.save_data.audio_bus_volumes.get(str(bus_name), default_value))
|
||||
|
||||
func _apply_audio_bus_volume(bus_name: String, linear_value: float) -> void:
|
||||
var bus_index := AudioServer.get_bus_index(bus_name)
|
||||
if bus_index == -1:
|
||||
return
|
||||
|
||||
var clamped_value := clampf(linear_value, MIN_VOLUME, MAX_VOLUME)
|
||||
AudioServer.set_bus_volume_db(bus_index, linear_to_db(clamped_value))
|
||||
AudioServer.set_bus_mute(bus_index, is_zero_approx(clamped_value))
|
||||
1
core/audio/audio_manager.gd.uid
Normal file
1
core/audio/audio_manager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dcttbbavtwtsg
|
||||
56
core/audio/settings/audio_option.gd
Normal file
56
core/audio/settings/audio_option.gd
Normal file
@@ -0,0 +1,56 @@
|
||||
extends VBoxContainer
|
||||
|
||||
class_name AudioOption
|
||||
|
||||
const MIN_VOLUME: float = 0.0
|
||||
const MAX_VOLUME: float = 1.0
|
||||
|
||||
@export var bus_name: StringName = &"Master"
|
||||
@export var label_text: String = "Master Volume"
|
||||
@export_range(0.0, 1.0, 0.01) var default_volume: float = 1.0
|
||||
|
||||
@onready var label: Label = $Label
|
||||
@onready var slider: HSlider = $HSlider
|
||||
|
||||
func _ready() -> void:
|
||||
slider.min_value = MIN_VOLUME
|
||||
slider.max_value = MAX_VOLUME
|
||||
slider.step = 0.01
|
||||
slider.value_changed.connect(_on_slider_value_changed)
|
||||
refresh()
|
||||
|
||||
func refresh() -> void:
|
||||
label.text = label_text
|
||||
|
||||
if not has_bus():
|
||||
slider.set_value_no_signal(default_volume)
|
||||
slider.editable = false
|
||||
label.text = "%s (bus missing)" % label_text
|
||||
return
|
||||
|
||||
slider.editable = true
|
||||
var saved_volume := AudioManager.get_audio_bus_volume(bus_name, default_volume)
|
||||
slider.set_value_no_signal(saved_volume)
|
||||
apply_current_value()
|
||||
|
||||
func reset_to_default() -> void:
|
||||
slider.value = default_volume
|
||||
|
||||
func apply_current_value() -> void:
|
||||
_set_bus_volume(slider.value)
|
||||
|
||||
func has_bus() -> bool:
|
||||
return get_bus_index() != -1
|
||||
|
||||
func get_bus_index() -> int:
|
||||
return AudioServer.get_bus_index(bus_name)
|
||||
|
||||
func _set_bus_volume(linear_value: float) -> void:
|
||||
if not has_bus():
|
||||
return
|
||||
|
||||
var clamped_value := clampf(linear_value, MIN_VOLUME, MAX_VOLUME)
|
||||
AudioManager.set_audio_bus_volume(bus_name, clamped_value)
|
||||
|
||||
func _on_slider_value_changed(value: float) -> void:
|
||||
_set_bus_volume(value)
|
||||
1
core/audio/settings/audio_option.gd.uid
Normal file
1
core/audio/settings/audio_option.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bnh1y560h55vc
|
||||
14
core/audio/settings/audio_option.tscn
Normal file
14
core/audio/settings/audio_option.tscn
Normal file
@@ -0,0 +1,14 @@
|
||||
[gd_scene format=3 uid="uid://cescrovsjlwke"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bnh1y560h55vc" path="res://core/audio/settings/audio_option.gd" id="1_orafl"]
|
||||
|
||||
[node name="AudioOption" type="VBoxContainer" unique_id=1509773712]
|
||||
custom_minimum_size = Vector2(300, 0)
|
||||
script = ExtResource("1_orafl")
|
||||
|
||||
[node name="Label" type="Label" parent="." unique_id=781845786]
|
||||
layout_mode = 2
|
||||
text = "Master Volume"
|
||||
|
||||
[node name="HSlider" type="HSlider" parent="." unique_id=1286896253]
|
||||
layout_mode = 2
|
||||
36
core/audio/settings/settings_menu.gd
Normal file
36
core/audio/settings/settings_menu.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends Control
|
||||
|
||||
class_name SettingsMenu
|
||||
|
||||
@onready var audio_options_container: VBoxContainer = $%AudioOptionsContainer
|
||||
@onready var reset_button: Button = $%ResetToDefault_Button
|
||||
@onready var close_button: Button = $%Close_Button
|
||||
|
||||
func _ready() -> void:
|
||||
reset_button.pressed.connect(_on_reset_to_default_button_pressed)
|
||||
close_button.pressed.connect(_on_close_button_pressed)
|
||||
_refresh_audio_options()
|
||||
|
||||
func _get_audio_options() -> Array[AudioOption]:
|
||||
var audio_options: Array[AudioOption] = []
|
||||
|
||||
for child in audio_options_container.get_children():
|
||||
if child is AudioOption:
|
||||
audio_options.append(child)
|
||||
|
||||
return audio_options
|
||||
|
||||
func _refresh_audio_options() -> void:
|
||||
for audio_option in _get_audio_options():
|
||||
audio_option.refresh()
|
||||
|
||||
func _apply_current_audio_values() -> void:
|
||||
for audio_option in _get_audio_options():
|
||||
audio_option.apply_current_value()
|
||||
|
||||
func _on_reset_to_default_button_pressed() -> void:
|
||||
for audio_option in _get_audio_options():
|
||||
audio_option.reset_to_default()
|
||||
|
||||
func _on_close_button_pressed() -> void:
|
||||
visible = false
|
||||
1
core/audio/settings/settings_menu.gd.uid
Normal file
1
core/audio/settings/settings_menu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvr25q1blyxg
|
||||
74
core/audio/settings/settings_menu.tscn
Normal file
74
core/audio/settings/settings_menu.tscn
Normal file
@@ -0,0 +1,74 @@
|
||||
[gd_scene format=3 uid="uid://caqf471x0kttc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cvr25q1blyxg" path="res://core/audio/settings/settings_menu.gd" id="1_4lekq"]
|
||||
[ext_resource type="PackedScene" uid="uid://cescrovsjlwke" path="res://core/audio/settings/audio_option.tscn" id="1_hwcco"]
|
||||
|
||||
[node name="SettingsMenu" type="Control" unique_id=1639777294]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_4lekq")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=315821242]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -79.5
|
||||
offset_top = -110.0
|
||||
offset_right = 79.5
|
||||
offset_bottom = 110.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer" unique_id=648635784]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="AudioOptionsContainer" type="VBoxContainer" parent="PanelContainer/MarginContainer" unique_id=824023653]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 12
|
||||
|
||||
[node name="MasterVolume_AudioOption" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=1509773712 instance=ExtResource("1_hwcco")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=1053430754]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MusicVolume_AudioOption" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=690924616 instance=ExtResource("1_hwcco")]
|
||||
layout_mode = 2
|
||||
bus_name = &"Music"
|
||||
label_text = "Music Volume"
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=453716295]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SFXVolume_AudioOption" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=2096291127 instance=ExtResource("1_hwcco")]
|
||||
layout_mode = 2
|
||||
bus_name = &"SFX"
|
||||
label_text = "SFX Volume"
|
||||
|
||||
[node name="HSeparator3" type="HSeparator" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=498553283]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ResetToDefault_Button" type="Button" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=720420423]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
text = "Reset To Default"
|
||||
|
||||
[node name="Close_Button" type="Button" parent="PanelContainer/MarginContainer/AudioOptionsContainer" unique_id=1137906684]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
text = "Close"
|
||||
@@ -1,5 +1,14 @@
|
||||
extends Node3D
|
||||
|
||||
const CHUNK_TYPE_BIOME: int = 0
|
||||
const CHUNK_TYPE_STRAIGHT_TRACK: int = 1
|
||||
const CHUNK_TYPE_CURVED_TRACK: int = 2
|
||||
|
||||
const CHUNK_GENERATION_STEPS_PER_FRAME: int = 2
|
||||
const CHUNK_CLEANUP_STEPS_PER_FRAME: int = 4
|
||||
const LAMPPOST_WIRE_STEPS_PER_FRAME: int = 1
|
||||
const RAILWAY_SCENE_DIRECTORY: String = "res://tgcc/chunk/railway/scene"
|
||||
|
||||
@export_group("Rails")
|
||||
@export var rail_path: Path3D
|
||||
|
||||
@@ -14,18 +23,29 @@ extends Node3D
|
||||
@export_group("Lamppost")
|
||||
@export var lamppost_wire_material: ShaderMaterial
|
||||
@export_range(0.01, 1.0) var wire_thickness: float = 0.05
|
||||
@export var lamppost_dist_factor: int = 10
|
||||
|
||||
var board: Dictionary = {}
|
||||
var last_pos_train: Vector2i = Vector2i(999999, 999999)
|
||||
var noise_generator: FastNoiseLite
|
||||
var altitude_generator: FastNoiseLite
|
||||
var wire_connections: Dictionary = {}
|
||||
var chunk_candidate_cache: Dictionary = {}
|
||||
var pending_generation_cells: Array[Vector2i] = []
|
||||
var pending_cleanup_cells: Array[Vector2i] = []
|
||||
var pending_wire_cells: Array[Vector2i] = []
|
||||
var pending_wire_lookup: Dictionary = {}
|
||||
var pending_radar_update: bool = false
|
||||
var rail_chunk_catalogue: Dictionary = {}
|
||||
|
||||
var manual_biome: Biome = null
|
||||
|
||||
func _ready() -> void:
|
||||
if biome_list.is_empty() or rail_path == null: return
|
||||
|
||||
#connect events
|
||||
UIEvents.update_rail_chunks.connect(_update_rail_chunks)
|
||||
|
||||
noise_generator = FastNoiseLite.new()
|
||||
noise_generator.noise_type = FastNoiseLite.TYPE_PERLIN
|
||||
noise_generator.seed = randi()
|
||||
@@ -36,6 +56,8 @@ func _ready() -> void:
|
||||
altitude_generator.seed = randi()
|
||||
altitude_generator.frequency = district_scale * 0.5
|
||||
|
||||
_warm_chunk_candidate_cache()
|
||||
_warm_rail_chunk_catalogue()
|
||||
_update_set_pieces()
|
||||
|
||||
func _update_set_pieces() -> void:
|
||||
@@ -67,15 +89,18 @@ func _update_set_pieces() -> void:
|
||||
print(" ❌ Temple is an invisible ghost.")
|
||||
|
||||
func _destroy_and_regenrate_world() -> void:
|
||||
_warm_chunk_candidate_cache()
|
||||
_clear_pending_world_work()
|
||||
|
||||
#Turn off old temples
|
||||
_update_set_pieces()
|
||||
|
||||
#Destroy all models
|
||||
for pos in board.keys():
|
||||
var cella = board[pos]
|
||||
if cella["tipo"] == "bioma":
|
||||
if cella.has("nodo") and is_instance_valid(cella["nodo"]):
|
||||
cella["nodo"].queue_free()
|
||||
if cella["type"] != "obstacle":
|
||||
if cella.has("node") and is_instance_valid(cella["node"]):
|
||||
cella["node"].queue_free()
|
||||
|
||||
#Clean board and wire connections
|
||||
board.clear()
|
||||
@@ -83,9 +108,19 @@ func _destroy_and_regenrate_world() -> void:
|
||||
|
||||
#Create train
|
||||
last_pos_train = Vector2i(999999, 999999)
|
||||
_train_radar()
|
||||
last_pos_train = Vector2i(999999, 999999)
|
||||
_train_radar()
|
||||
if rail_path != null and rail_path.train_instance != null:
|
||||
var train_pos = rail_path.train_instance.global_position
|
||||
var current_pos = Vector2i(roundi(train_pos.x / chunk_size), roundi(train_pos.z / chunk_size))
|
||||
_refresh_world(current_pos)
|
||||
pending_radar_update = true
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
_drain_cleanup_queue()
|
||||
_drain_generation_queue()
|
||||
_drain_wire_queue()
|
||||
|
||||
if pending_radar_update:
|
||||
pending_radar_update = false
|
||||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
if rail_path == null or rail_path.train_instance == null: return
|
||||
@@ -97,9 +132,8 @@ func _physics_process(_delta: float) -> void:
|
||||
|
||||
if current_pos != last_pos_train:
|
||||
last_pos_train = current_pos
|
||||
_generate_pieces_around_train(current_pos)
|
||||
_clean_far_chunks(current_pos)
|
||||
_train_radar()
|
||||
_refresh_world(current_pos)
|
||||
pending_radar_update = true
|
||||
|
||||
func collect_all_chunkinfo(root: Node, list: Array[Node]) -> void:
|
||||
if root == null: return
|
||||
@@ -110,6 +144,292 @@ func collect_all_chunkinfo(root: Node, list: Array[Node]) -> void:
|
||||
for child in root.get_children():
|
||||
collect_all_chunkinfo(child, list)
|
||||
|
||||
func _warm_chunk_candidate_cache() -> void:
|
||||
var unique_scenes: Dictionary = {}
|
||||
|
||||
for biome in biome_list:
|
||||
if biome == null:
|
||||
continue
|
||||
for scene in biome.available_chunks:
|
||||
if scene == null:
|
||||
continue
|
||||
unique_scenes[_get_chunk_scene_cache_key(scene)] = scene
|
||||
|
||||
if manual_biome != null:
|
||||
for scene in manual_biome.available_chunks:
|
||||
if scene == null:
|
||||
continue
|
||||
unique_scenes[_get_chunk_scene_cache_key(scene)] = scene
|
||||
|
||||
for scene in unique_scenes.values():
|
||||
_get_chunk_scene_metadata(scene)
|
||||
|
||||
func _warm_rail_chunk_catalogue() -> void:
|
||||
rail_chunk_catalogue.clear()
|
||||
|
||||
var directory := DirAccess.open(RAILWAY_SCENE_DIRECTORY)
|
||||
if directory == null:
|
||||
return
|
||||
|
||||
directory.list_dir_begin()
|
||||
var file_name := directory.get_next()
|
||||
while file_name != "":
|
||||
if not directory.current_is_dir() and file_name.ends_with(".tscn"):
|
||||
var scene_path := "%s/%s" % [RAILWAY_SCENE_DIRECTORY, file_name]
|
||||
var scene := load(scene_path) as PackedScene
|
||||
if scene != null:
|
||||
var chunk_type = _get_chunk_type_from_scene(scene)
|
||||
if chunk_type == CHUNK_TYPE_STRAIGHT_TRACK or chunk_type == CHUNK_TYPE_CURVED_TRACK:
|
||||
if not rail_chunk_catalogue.has(chunk_type):
|
||||
rail_chunk_catalogue[chunk_type] = []
|
||||
rail_chunk_catalogue[chunk_type].append(scene)
|
||||
file_name = directory.get_next()
|
||||
directory.list_dir_end()
|
||||
|
||||
func _get_chunk_scene_cache_key(scene: PackedScene) -> String:
|
||||
if scene == null:
|
||||
return ""
|
||||
if scene.resource_path != "":
|
||||
return scene.resource_path
|
||||
return "scene_%s" % scene.get_instance_id()
|
||||
|
||||
func _get_chunk_scene_metadata(scene: PackedScene) -> Dictionary:
|
||||
if scene == null:
|
||||
return {}
|
||||
|
||||
var key = _get_chunk_scene_cache_key(scene)
|
||||
if chunk_candidate_cache.has(key):
|
||||
return chunk_candidate_cache[key]
|
||||
|
||||
var preview_chunk = scene.instantiate()
|
||||
var info_list: Array[Node] = []
|
||||
collect_all_chunkinfo(preview_chunk, info_list)
|
||||
var info_node = info_list[0] if info_list.size() > 0 else null
|
||||
|
||||
if info_node == null or not info_node.has_method("get_rotated_data"):
|
||||
preview_chunk.queue_free()
|
||||
chunk_candidate_cache[key] = {}
|
||||
return {}
|
||||
|
||||
var info_path: NodePath = NodePath(".")
|
||||
if info_node != preview_chunk:
|
||||
info_path = preview_chunk.get_path_to(info_node)
|
||||
|
||||
var rotations = []
|
||||
for rot in range(4):
|
||||
rotations.append({
|
||||
"rotation": rot,
|
||||
"data": info_node.get_rotated_data(rot)
|
||||
})
|
||||
|
||||
var metadata = {
|
||||
"info_path": info_path,
|
||||
"rotations": rotations,
|
||||
"has_lamppost": "have_lamppost" in info_node and info_node.have_lamppost,
|
||||
}
|
||||
preview_chunk.queue_free()
|
||||
chunk_candidate_cache[key] = metadata
|
||||
return metadata
|
||||
|
||||
func _get_cached_chunk_info(instance: Node, scene: PackedScene) -> Node:
|
||||
var metadata = _get_chunk_scene_metadata(scene)
|
||||
if metadata.is_empty():
|
||||
return null
|
||||
|
||||
var info_path: NodePath = metadata["info_path"]
|
||||
if String(info_path) == ".":
|
||||
return instance
|
||||
return instance.get_node_or_null(info_path)
|
||||
|
||||
func _get_chunk_type_from_scene(scene: PackedScene) -> int:
|
||||
if scene == null:
|
||||
return CHUNK_TYPE_BIOME
|
||||
|
||||
var preview_chunk = scene.instantiate()
|
||||
var info_list: Array[Node] = []
|
||||
collect_all_chunkinfo(preview_chunk, info_list)
|
||||
var info_node = info_list[0] if info_list.size() > 0 else null
|
||||
var chunk_type = CHUNK_TYPE_BIOME
|
||||
if info_node != null and "chunk_type" in info_node:
|
||||
chunk_type = info_node.chunk_type
|
||||
preview_chunk.queue_free()
|
||||
return chunk_type
|
||||
|
||||
func _clear_pending_world_work() -> void:
|
||||
pending_generation_cells.clear()
|
||||
pending_cleanup_cells.clear()
|
||||
pending_wire_cells.clear()
|
||||
pending_wire_lookup.clear()
|
||||
pending_radar_update = false
|
||||
|
||||
func _collect_replaceable_rail_chunks(root: Node, result: Array[Node3D]) -> void:
|
||||
if root == null:
|
||||
return
|
||||
|
||||
if root is Node3D:
|
||||
var node_3d := root as Node3D
|
||||
if node_3d.scene_file_path.begins_with(RAILWAY_SCENE_DIRECTORY):
|
||||
var info_list: Array[Node] = []
|
||||
collect_all_chunkinfo(node_3d, info_list)
|
||||
var info_node = info_list[0] if info_list.size() > 0 else null
|
||||
if info_node != null and "chunk_type" in info_node:
|
||||
var chunk_type = info_node.chunk_type
|
||||
if chunk_type == CHUNK_TYPE_STRAIGHT_TRACK or chunk_type == CHUNK_TYPE_CURVED_TRACK:
|
||||
result.append(node_3d)
|
||||
return
|
||||
|
||||
for child in root.get_children():
|
||||
_collect_replaceable_rail_chunks(child, result)
|
||||
|
||||
func _pick_replacement_rail_scene(chunk_type: int, current_scene_path: String) -> PackedScene:
|
||||
var candidates: Array = rail_chunk_catalogue.get(chunk_type, [])
|
||||
if candidates.is_empty():
|
||||
return null
|
||||
|
||||
var alternatives: Array[PackedScene] = []
|
||||
for candidate in candidates:
|
||||
var scene := candidate as PackedScene
|
||||
if scene != null and scene.resource_path != current_scene_path:
|
||||
alternatives.append(scene)
|
||||
|
||||
if not alternatives.is_empty():
|
||||
return alternatives.pick_random()
|
||||
return candidates.pick_random() as PackedScene
|
||||
|
||||
func _replace_rail_chunk_instance(chunk_root: Node3D) -> bool:
|
||||
if chunk_root == null or not is_instance_valid(chunk_root):
|
||||
return false
|
||||
|
||||
var info_list: Array[Node] = []
|
||||
collect_all_chunkinfo(chunk_root, info_list)
|
||||
var info_node = info_list[0] if info_list.size() > 0 else null
|
||||
if info_node == null or not "chunk_type" in info_node:
|
||||
return false
|
||||
|
||||
var replacement_scene = _pick_replacement_rail_scene(info_node.chunk_type, chunk_root.scene_file_path)
|
||||
if replacement_scene == null:
|
||||
return false
|
||||
|
||||
var chunk_parent = chunk_root.get_parent()
|
||||
var replacement = replacement_scene.instantiate() as Node3D
|
||||
if chunk_parent == null or replacement == null:
|
||||
return false
|
||||
|
||||
var chunk_index = chunk_root.get_index()
|
||||
var chunk_name = chunk_root.name
|
||||
chunk_root.name = "%s_old" % chunk_name
|
||||
|
||||
replacement.transform = chunk_root.transform
|
||||
chunk_parent.add_child(replacement)
|
||||
chunk_parent.move_child(replacement, chunk_index)
|
||||
replacement.name = chunk_name
|
||||
replacement.owner = chunk_root.owner
|
||||
chunk_root.queue_free()
|
||||
return true
|
||||
|
||||
func _refresh_rail_chunks() -> void:
|
||||
print("update rail chunks")
|
||||
_warm_rail_chunk_catalogue()
|
||||
|
||||
var current_scene: Node = get_tree().current_scene
|
||||
if current_scene == null:
|
||||
return
|
||||
|
||||
var replaceable_chunks: Array[Node3D] = []
|
||||
_collect_replaceable_rail_chunks(current_scene, replaceable_chunks)
|
||||
|
||||
var replaced_count = 0
|
||||
for chunk_root in replaceable_chunks:
|
||||
if _replace_rail_chunk_instance(chunk_root):
|
||||
replaced_count += 1
|
||||
|
||||
if replaced_count > 0:
|
||||
await get_tree().process_frame
|
||||
_destroy_and_regenrate_world()
|
||||
|
||||
func _update_rail_chunks() -> void:
|
||||
call_deferred("_refresh_rail_chunks")
|
||||
|
||||
func _refresh_world(center: Vector2i) -> void:
|
||||
_rebuild_generation_queue(center)
|
||||
_rebuild_cleanup_queue(center)
|
||||
|
||||
func _rebuild_generation_queue(center: Vector2i) -> void:
|
||||
pending_generation_cells.clear()
|
||||
|
||||
for radius in range(eye_line + 1):
|
||||
for x in range(-radius, radius + 1):
|
||||
for z in range(-radius, radius + 1):
|
||||
if maxi(abs(x), abs(z)) != radius:
|
||||
continue
|
||||
|
||||
var grid_pos = center + Vector2i(x, z)
|
||||
if board.has(grid_pos):
|
||||
continue
|
||||
pending_generation_cells.append(grid_pos)
|
||||
|
||||
func _rebuild_cleanup_queue(center: Vector2i) -> void:
|
||||
pending_cleanup_cells.clear()
|
||||
var safe_margin = 2
|
||||
|
||||
for grid_pos in board.keys():
|
||||
var cell = board[grid_pos]
|
||||
if cell["type"] == "obstacle":
|
||||
continue
|
||||
|
||||
var dist_x = abs(grid_pos.x - center.x)
|
||||
var dist_z = abs(grid_pos.y - center.y)
|
||||
if dist_x > eye_line + safe_margin or dist_z > eye_line + safe_margin:
|
||||
pending_cleanup_cells.append(grid_pos)
|
||||
|
||||
func _drain_generation_queue() -> void:
|
||||
var processed = 0
|
||||
while processed < CHUNK_GENERATION_STEPS_PER_FRAME and not pending_generation_cells.is_empty():
|
||||
var grid_pos = pending_generation_cells.pop_front()
|
||||
if board.has(grid_pos):
|
||||
continue
|
||||
|
||||
var is_obstacle = _register_cell_with_ray(grid_pos)
|
||||
if not is_obstacle:
|
||||
_add_compatible_biome(grid_pos)
|
||||
processed += 1
|
||||
|
||||
func _drain_cleanup_queue() -> void:
|
||||
var processed = 0
|
||||
while processed < CHUNK_CLEANUP_STEPS_PER_FRAME and not pending_cleanup_cells.is_empty():
|
||||
var grid_pos = pending_cleanup_cells.pop_front()
|
||||
if not board.has(grid_pos):
|
||||
continue
|
||||
|
||||
var cell = board[grid_pos]
|
||||
if cell["type"] == "obstacle":
|
||||
continue
|
||||
|
||||
if cell.has("node") and is_instance_valid(cell["node"]):
|
||||
cell["node"].queue_free()
|
||||
board.erase(grid_pos)
|
||||
processed += 1
|
||||
|
||||
func _queue_lamppost_wire_connection(grid_pos: Vector2i) -> void:
|
||||
if pending_wire_lookup.has(grid_pos):
|
||||
return
|
||||
pending_wire_lookup[grid_pos] = true
|
||||
pending_wire_cells.append(grid_pos)
|
||||
|
||||
func _drain_wire_queue() -> void:
|
||||
var processed = 0
|
||||
while processed < LAMPPOST_WIRE_STEPS_PER_FRAME and not pending_wire_cells.is_empty():
|
||||
var grid_pos = pending_wire_cells.pop_front()
|
||||
pending_wire_lookup.erase(grid_pos)
|
||||
|
||||
if not board.has(grid_pos):
|
||||
continue
|
||||
if not board[grid_pos].get("have_lamppost", false):
|
||||
continue
|
||||
|
||||
_connect_lamppost_wires(grid_pos)
|
||||
processed += 1
|
||||
|
||||
func _generate_pieces_around_train(center: Vector2i) -> void:
|
||||
for x in range(-eye_line, eye_line + 1):
|
||||
for z in range(-eye_line, eye_line + 1):
|
||||
@@ -181,6 +501,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
right_info_node = info_list[0]
|
||||
|
||||
var exit_found = {"north": false, "est": false, "south": false, "west": false}
|
||||
var river_exit_found = {"north": false, "est": false, "south": false, "west": false}
|
||||
var height_found = {"north": 0, "est": 0, "south": 0, "west": 0}
|
||||
var have_lamppost = false
|
||||
|
||||
@@ -190,6 +511,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
var rotation_steps = roundi(rad_to_deg(right_info_node.global_rotation.y) / -90.0)
|
||||
var data = right_info_node.get_rotated_data(rotation_steps)
|
||||
exit_found = data["connections"]
|
||||
river_exit_found = data["river_connections"]
|
||||
height_found = data["heights"]
|
||||
|
||||
if "have_lamppost" in right_info_node:
|
||||
@@ -199,6 +521,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
board[grid_pos] = {
|
||||
"type": "obstacle",
|
||||
"exit": exit_found,
|
||||
"river_exit": river_exit_found,
|
||||
"heights": height_found,
|
||||
"node": root_chunk,
|
||||
"info": right_info_node,
|
||||
@@ -206,7 +529,7 @@ func _register_cell_with_ray(grid_pos: Vector2i) -> bool:
|
||||
}
|
||||
|
||||
if have_lamppost:
|
||||
_connect_lamppost_wires(grid_pos)
|
||||
_queue_lamppost_wire_connection(grid_pos)
|
||||
|
||||
return true
|
||||
return false
|
||||
@@ -216,6 +539,10 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
var req_conn_est = _needed_connection(grid_pos + Vector2i(1, 0), "west")
|
||||
var req_conn_south = _needed_connection(grid_pos + Vector2i(0, 1), "north")
|
||||
var req_conn_west = _needed_connection(grid_pos + Vector2i(-1, 0), "est")
|
||||
var req_river_north = _needed_river_connection(grid_pos + Vector2i(0, -1), "south")
|
||||
var req_river_est = _needed_river_connection(grid_pos + Vector2i(1, 0), "west")
|
||||
var req_river_south = _needed_river_connection(grid_pos + Vector2i(0, 1), "north")
|
||||
var req_river_west = _needed_river_connection(grid_pos + Vector2i(-1, 0), "est")
|
||||
|
||||
var req_height_north = _needed_heights(grid_pos + Vector2i(0, -1), "south")
|
||||
var req_height_est = _needed_heights(grid_pos + Vector2i(1, 0), "west")
|
||||
@@ -229,43 +556,45 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
var valid_candidates = []
|
||||
|
||||
for scene in zone_catalogue:
|
||||
var test_chunk = scene.instantiate()
|
||||
var test_list: Array[Node] = []
|
||||
collect_all_chunkinfo(test_chunk, test_list)
|
||||
var info_test = test_list[0] if test_list.size() > 0 else null
|
||||
var metadata = _get_chunk_scene_metadata(scene)
|
||||
if metadata.is_empty():
|
||||
continue
|
||||
|
||||
if info_test != null and info_test.has_method("get_rotated_data"):
|
||||
for rot in range(4):
|
||||
var data = test_chunk.get_rotated_data(rot)
|
||||
var u_conn = data["connections"]
|
||||
var u_height = data["heights"]
|
||||
for candidate in metadata["rotations"]:
|
||||
var rot = candidate["rotation"]
|
||||
var data = candidate["data"]
|
||||
var u_conn = data["connections"]
|
||||
var u_river_conn = data["river_connections"]
|
||||
var u_height = data["heights"]
|
||||
|
||||
var match_conn_n = (req_conn_north == -1) or ((req_conn_north == 1) == u_conn["north"])
|
||||
var match_conn_e = (req_conn_est == -1) or ((req_conn_est == 1) == u_conn["est"])
|
||||
var match_conn_s = (req_conn_south == -1) or ((req_conn_south == 1) == u_conn["south"])
|
||||
var match_conn_o = (req_conn_west == -1) or ((req_conn_west == 1) == u_conn["west"])
|
||||
var match_conn_n = (req_conn_north == -1) or ((req_conn_north == 1) == u_conn["north"])
|
||||
var match_conn_e = (req_conn_est == -1) or ((req_conn_est == 1) == u_conn["est"])
|
||||
var match_conn_s = (req_conn_south == -1) or ((req_conn_south == 1) == u_conn["south"])
|
||||
var match_conn_o = (req_conn_west == -1) or ((req_conn_west == 1) == u_conn["west"])
|
||||
var match_river_n = (req_river_north == -1) or ((req_river_north == 1) == u_river_conn["north"])
|
||||
var match_river_e = (req_river_est == -1) or ((req_river_est == 1) == u_river_conn["est"])
|
||||
var match_river_s = (req_river_south == -1) or ((req_river_south == 1) == u_river_conn["south"])
|
||||
var match_river_o = (req_river_west == -1) or ((req_river_west == 1) == u_river_conn["west"])
|
||||
|
||||
var match_alt_n = (req_height_north == -1) or (req_height_north == u_height["north"])
|
||||
var match_alt_e = (req_height_est == -1) or (req_height_est == u_height["est"])
|
||||
var match_alt_s = (req_height_south == -1) or (req_height_south == u_height["south"])
|
||||
var match_alt_o = (req_height_west == -1) or (req_height_west == u_height["west"])
|
||||
var match_alt_n = (req_height_north == -1) or (req_height_north == u_height["north"])
|
||||
var match_alt_e = (req_height_est == -1) or (req_height_est == u_height["est"])
|
||||
var match_alt_s = (req_height_south == -1) or (req_height_south == u_height["south"])
|
||||
var match_alt_o = (req_height_west == -1) or (req_height_west == u_height["west"])
|
||||
|
||||
var diff_n = abs(u_height["north"] - height_target) if req_height_north == -1 else 0
|
||||
var diff_e = abs(u_height["est"] - height_target) if req_height_est == -1 else 0
|
||||
var diff_s = abs(u_height["south"] - height_target) if req_height_south == -1 else 0
|
||||
var diff_o = abs(u_height["west"] - height_target) if req_height_west == -1 else 0
|
||||
var excessive_jumps = diff_n > 1 or diff_e > 1 or diff_s > 1 or diff_o > 1
|
||||
var diff_n = abs(u_height["north"] - height_target) if req_height_north == -1 else 0
|
||||
var diff_e = abs(u_height["est"] - height_target) if req_height_est == -1 else 0
|
||||
var diff_s = abs(u_height["south"] - height_target) if req_height_south == -1 else 0
|
||||
var diff_o = abs(u_height["west"] - height_target) if req_height_west == -1 else 0
|
||||
var excessive_jumps = diff_n > 1 or diff_e > 1 or diff_s > 1 or diff_o > 1
|
||||
|
||||
if match_conn_n and match_conn_e and match_conn_s and match_conn_o and match_alt_n and match_alt_e and match_alt_s and match_alt_o and not excessive_jumps:
|
||||
var score = 0
|
||||
if req_height_north == -1 and u_height["north"] == height_target: score += 1
|
||||
if req_height_est == -1 and u_height["est"] == height_target: score += 1
|
||||
if req_height_south == -1 and u_height["south"] == height_target: score += 1
|
||||
if req_height_west == -1 and u_height["west"] == height_target: score += 1
|
||||
if match_conn_n and match_conn_e and match_conn_s and match_conn_o and match_river_n and match_river_e and match_river_s and match_river_o and match_alt_n and match_alt_e and match_alt_s and match_alt_o and not excessive_jumps:
|
||||
var score = 0
|
||||
if req_height_north == -1 and u_height["north"] == height_target: score += 1
|
||||
if req_height_est == -1 and u_height["est"] == height_target: score += 1
|
||||
if req_height_south == -1 and u_height["south"] == height_target: score += 1
|
||||
if req_height_west == -1 and u_height["west"] == height_target: score += 1
|
||||
|
||||
valid_candidates.append({"scene": scene, "rotation": rot, "data": data, "score": score})
|
||||
|
||||
test_chunk.queue_free()
|
||||
valid_candidates.append({"scene": scene, "rotation": rot, "data": data, "score": score})
|
||||
|
||||
if valid_candidates.size() > 0:
|
||||
var max_score = -1
|
||||
@@ -278,21 +607,20 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
|
||||
var choise = best_candidate.pick_random()
|
||||
var new_chunk = choise.scene.instantiate()
|
||||
add_child(new_chunk)
|
||||
new_chunk.position = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
new_chunk.rotation.y = choise.rotation * (-PI / 2.0)
|
||||
add_child(new_chunk)
|
||||
|
||||
var new_list: Array[Node] = []
|
||||
collect_all_chunkinfo(new_chunk, new_list)
|
||||
var info_new = new_list[0] if new_list.size() > 0 else null
|
||||
var info_new = _get_cached_chunk_info(new_chunk, choise.scene)
|
||||
|
||||
var have_lamppost = false
|
||||
if info_new != null and "have_lamppost" in new_chunk:
|
||||
if info_new != null and "have_lamppost" in info_new:
|
||||
have_lamppost = info_new.have_lamppost
|
||||
|
||||
board[grid_pos] = {
|
||||
"type": "bioma",
|
||||
"exit": choise.data["connections"],
|
||||
"river_exit": choise.data["river_connections"],
|
||||
"heights": choise.data["heights"],
|
||||
"node": new_chunk,
|
||||
"info": info_new,
|
||||
@@ -300,16 +628,14 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
}
|
||||
|
||||
if have_lamppost:
|
||||
_connect_lamppost_wires(grid_pos)
|
||||
_queue_lamppost_wire_connection(grid_pos)
|
||||
|
||||
else:
|
||||
var backup = zone_catalogue[0].instantiate()
|
||||
add_child(backup)
|
||||
backup.position = Vector3(grid_pos.x * chunk_size, 0, grid_pos.y * chunk_size)
|
||||
add_child(backup)
|
||||
|
||||
var backup_list: Array[Node] = []
|
||||
collect_all_chunkinfo(backup, backup_list)
|
||||
var info_backup = backup_list[0] if backup_list.size() > 0 else null
|
||||
var info_backup = _get_cached_chunk_info(backup, zone_catalogue[0])
|
||||
|
||||
var safe_heights = {
|
||||
"north": req_height_north if req_height_north != -1 else height_target,
|
||||
@@ -320,6 +646,7 @@ func _add_compatible_biome(grid_pos: Vector2i) -> void:
|
||||
board[grid_pos] = {
|
||||
"type": "biome",
|
||||
"exit": {"north":false, "est":false, "south":false, "west":false},
|
||||
"river_exit": {"north":false, "est":false, "south":false, "west":false},
|
||||
"heights": safe_heights,
|
||||
"node": backup,
|
||||
"info": info_backup,
|
||||
@@ -333,75 +660,28 @@ func _needed_connection(near_pos: Vector2i, side_needed: String) -> int:
|
||||
return 1 if board[near_pos]["exit"][side_needed] else 0
|
||||
return -1
|
||||
|
||||
func _needed_river_connection(near_pos: Vector2i, side_needed: String) -> int:
|
||||
if not board.has(near_pos):
|
||||
_register_cell_with_ray(near_pos)
|
||||
if board.has(near_pos) and board[near_pos].has("river_exit"):
|
||||
return 1 if board[near_pos]["river_exit"][side_needed] else 0
|
||||
return -1
|
||||
|
||||
func _needed_heights(near_pos: Vector2i, side_needed: String) -> int:
|
||||
if board.has(near_pos) and board[near_pos].has("heights"):
|
||||
return board[near_pos]["heights"][side_needed]
|
||||
return -1
|
||||
|
||||
func _train_radar() -> void:
|
||||
if rail_path == null or rail_path.curve == null or rail_path.train_instance == null: return
|
||||
|
||||
if manual_biome != null:
|
||||
return
|
||||
|
||||
var train_pos = rail_path.train_instance.global_position
|
||||
var grid_x = roundi(train_pos.x / chunk_size)
|
||||
var grid_z = roundi(train_pos.z / chunk_size)
|
||||
var current_biome = _get_procedural_biome_name(noise_generator.get_noise_2d(grid_x, grid_z))
|
||||
|
||||
var current_progress = rail_path.train_progress
|
||||
var total_length = rail_path.curve.get_baked_length()
|
||||
#var exchange_distance = 0.0
|
||||
#var next_biome = ""
|
||||
|
||||
for step in range(1, 31):
|
||||
var next_progress = wrapf(current_progress + (step * chunk_size), 0.0, total_length)
|
||||
var next_local_pos = rail_path.curve.sample_baked(next_progress, true)
|
||||
var next_global_pos = rail_path.to_global(next_local_pos)
|
||||
|
||||
var f_x = roundi(next_global_pos.x / chunk_size)
|
||||
var f_z = roundi(next_global_pos.z / chunk_size)
|
||||
var future_biome = _get_procedural_biome_name(noise_generator.get_noise_2d(f_x, f_z))
|
||||
|
||||
if future_biome != current_biome:
|
||||
#exchange_distance = step * chunk_size
|
||||
#next_biome = future_biome
|
||||
break
|
||||
|
||||
func _clean_far_chunks(centro_attuale: Vector2i) -> void:
|
||||
var cells_to_remove = []
|
||||
var safe_margin = 2
|
||||
|
||||
for grid_pos in board.keys():
|
||||
var cell = board[grid_pos]
|
||||
if cell["type"] == "obstacle": continue
|
||||
|
||||
var dist_x = abs(grid_pos.x - centro_attuale.x)
|
||||
var dist_z = abs(grid_pos.y - centro_attuale.y)
|
||||
|
||||
if dist_x > eye_line + safe_margin or dist_z > eye_line + safe_margin:
|
||||
if cell.has("node") and is_instance_valid(cell["node"]):
|
||||
cell["node"].queue_free()
|
||||
cells_to_remove.append(grid_pos)
|
||||
|
||||
for pos in cells_to_remove:
|
||||
board.erase(pos)
|
||||
|
||||
|
||||
func _get_lampposts(info_node: Node, side: String) -> Array[Node3D]:
|
||||
var lampposts: Array[Node3D] = []
|
||||
if side == "sx":
|
||||
if "connection_left" in info_node and info_node.connection_left != null:
|
||||
for p in info_node.connection_left:
|
||||
if is_instance_valid(p): lampposts.append(p)
|
||||
#if lampposts.is_empty() and "nodo_attacco_sx" in nodo_info and is_instance_valid(nodo_info.get("nodo_attacco_sx")):
|
||||
# lampposts.append(nodo_info.get("nodo_attacco_sx"))
|
||||
else:
|
||||
if "connection_right" in info_node and info_node.connection_right != null:
|
||||
for p in info_node.connection_right:
|
||||
if is_instance_valid(p): lampposts.append(p)
|
||||
#if lampposts.is_empty() and "nodo_attacco_dx" in nodo_info and is_instance_valid(nodo_info.get("nodo_attacco_dx")):
|
||||
# lampposts.append(nodo_info.get("nodo_attacco_dx"))
|
||||
return lampposts
|
||||
|
||||
func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
@@ -425,7 +705,7 @@ func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
var p_sx_your_best = null; var p_dx_your_best = null
|
||||
var best_closest_to_root = null
|
||||
var best_distance = 999999.0
|
||||
var ray_research = 3
|
||||
var ray_research = 6
|
||||
|
||||
for x in range(-ray_research, ray_research + 1):
|
||||
for z in range(-ray_research, ray_research + 1):
|
||||
@@ -493,7 +773,7 @@ func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
p_sx_your_best = closest_sx[i_t]
|
||||
p_dx_your_best = closest_dx[i_t]
|
||||
|
||||
var max_dist = chunk_size * 8.0
|
||||
var max_dist = chunk_size * lamppost_dist_factor
|
||||
|
||||
if best_closest_to_root != null and best_distance < max_dist:
|
||||
var dist_streight = p_sx_my_best.global_position.distance_to(p_sx_your_best.global_position) + p_dx_my_best.global_position.distance_to(p_dx_your_best.global_position)
|
||||
@@ -511,6 +791,7 @@ func _connect_lamppost_wires(new_board_pos: Vector2i) -> void:
|
||||
if not wire_connections.has(closest_id): wire_connections[closest_id] = 0
|
||||
wire_connections[closest_id] += 1
|
||||
|
||||
#draw lamppost
|
||||
func _draw_parable(p1: Vector3, p2: Vector3, parent: Node3D) -> void:
|
||||
var segments = 15
|
||||
var lowering = 1.5
|
||||
|
||||
@@ -12,6 +12,12 @@ class_name ChunkInfo
|
||||
@export var south: bool = false
|
||||
@export var west: bool = false
|
||||
|
||||
@export_group("River exit")
|
||||
@export var river_north: bool = false
|
||||
@export var river_est: bool = false
|
||||
@export var river_south: bool = false
|
||||
@export var river_west: bool = false
|
||||
|
||||
@export_group("Margin heights (level 0, 1, 2)")
|
||||
@export_range(0, 2, 1) var height_north: int = 0
|
||||
@export_range(0, 2, 1) var height_est: int = 0
|
||||
@@ -29,14 +35,17 @@ func _ready() -> void:
|
||||
|
||||
func get_rotated_data(steps_90: int) -> Dictionary:
|
||||
var original_exit = [north, est, south, west]
|
||||
var original_river_exit = [river_north, river_est, river_south, river_west]
|
||||
var original_height = [height_north, height_est, height_south, height_west]
|
||||
|
||||
var calculated_exit = []
|
||||
var calculated_river_exit = []
|
||||
var calculated_height = []
|
||||
|
||||
for i in range(4):
|
||||
var index = (i - steps_90 + 4) % 4
|
||||
calculated_exit.append(original_exit[index])
|
||||
calculated_river_exit.append(original_river_exit[index])
|
||||
calculated_height.append(original_height[index])
|
||||
|
||||
return {
|
||||
@@ -44,6 +53,10 @@ func get_rotated_data(steps_90: int) -> Dictionary:
|
||||
"north": calculated_exit[0], "est": calculated_exit[1],
|
||||
"south": calculated_exit[2], "west": calculated_exit[3]
|
||||
},
|
||||
"river_connections": {
|
||||
"north": calculated_river_exit[0], "est": calculated_river_exit[1],
|
||||
"south": calculated_river_exit[2], "west": calculated_river_exit[3]
|
||||
},
|
||||
"heights": {
|
||||
"north": calculated_height[0], "est": calculated_height[1],
|
||||
"south": calculated_height[2], "west": calculated_height[3]
|
||||
|
||||
@@ -268,7 +268,7 @@ shader_parameter/edge_softness_x = 0.5
|
||||
shader_parameter/night_intensity = 0.0
|
||||
shader_parameter/sun_color = Color(1, 1, 1, 1)
|
||||
|
||||
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows")]
|
||||
[node name="EnvironmentManager" type="Node3D" unique_id=1611939731 node_paths=PackedStringArray("particles_wind", "particles_snow", "particles_fireflies", "particles_rain", "environment_dust", "blur", "environment_shadows", "fog")]
|
||||
script = ExtResource("1_wecen")
|
||||
environment_config = SubResource("Resource_r4tfj")
|
||||
particles_wind = NodePath("Particles_Wind")
|
||||
@@ -279,6 +279,7 @@ godray = ExtResource("5_411rw")
|
||||
environment_dust = NodePath("EnvironmentDust")
|
||||
blur = NodePath("Blur")
|
||||
environment_shadows = NodePath("EnvironmentCloudsShadows")
|
||||
fog = NodePath("Fog")
|
||||
|
||||
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
|
||||
@@ -343,11 +344,11 @@ surface_material_override/0 = SubResource("ShaderMaterial_oqt1s")
|
||||
[node name="Fog" type="Node3D" parent="." unique_id=1626352238]
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Fog" unique_id=96635311]
|
||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, -67, 14, 0)
|
||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, -41.926987, 14, 0)
|
||||
mesh = SubResource("QuadMesh_yn8v8")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
||||
|
||||
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Fog" unique_id=10121049]
|
||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, 67, 14, 0)
|
||||
transform = Transform3D(-42.075005, 7.553328e-06, 1.7196172e-13, 0, -3.7766642e-06, 45, 3.6783138e-06, 86.4, 1.9670128e-06, 59.320038, 14, 0)
|
||||
mesh = SubResource("QuadMesh_yn8v8")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
|
||||
|
||||
@@ -4,6 +4,7 @@ extends Node3D
|
||||
const NOISE_TEXTURE: Texture2D = preload("res://core/daynight/noise.tres")
|
||||
const WEATHER_SHADER: Material = preload("res://core/daynight/weather_overlay.tres")
|
||||
const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plain_shader.tres")
|
||||
const DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME: int = 2 #how many update of the environment (apply materials) will be done per frame
|
||||
|
||||
@export var environment_config: EnvironmentConfig
|
||||
|
||||
@@ -20,6 +21,7 @@ const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plai
|
||||
@export var environment_dust: ColorRect
|
||||
@export var blur: ColorRect
|
||||
@export var environment_shadows: MeshInstance3D
|
||||
@export var fog: Node3D
|
||||
|
||||
@export_group("Sound")
|
||||
@export var thunder_sounds: Array[AudioStream]
|
||||
@@ -28,19 +30,18 @@ const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plai
|
||||
#environment nodes
|
||||
@onready var sun: DirectionalLight3D = $"../DirectionalLight3D"
|
||||
@onready var environment: WorldEnvironment = $"../WorldEnvironment"
|
||||
@onready var fog_node: Node3D = $Fog
|
||||
|
||||
var day_night_controller: DayNightController
|
||||
var weather_controller: WeatherController
|
||||
|
||||
var day_tween: Tween
|
||||
var day_time: float = 0.0
|
||||
var pending_environment_nodes: Dictionary = {}
|
||||
|
||||
func _ready() -> void:
|
||||
|
||||
#connect shader when new node is added
|
||||
get_tree().node_added.connect(_on_tree_node_added)
|
||||
UIEvents.toggle_fog.connect(toggle_fog)
|
||||
|
||||
#set noise texture 2d to materials in special group
|
||||
ApplyWindNoiseToMaterials()
|
||||
@@ -64,6 +65,7 @@ func _ready() -> void:
|
||||
godray,
|
||||
environment_dust,
|
||||
blur,
|
||||
fog,
|
||||
environment_shadows,
|
||||
sun,
|
||||
environment,
|
||||
@@ -76,9 +78,50 @@ func _ready() -> void:
|
||||
weather_controller.name = "WeatherController"
|
||||
add_child(weather_controller)
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
_process_pending_environment_nodes()
|
||||
|
||||
func _on_tree_node_added(node: Node) -> void:
|
||||
if node.is_in_group("wind_node") or node.is_in_group("weather_node") or node.is_in_group("weather_vegetables_node"):
|
||||
call_deferred("_apply_dynamic_environment_materials", node)
|
||||
_queue_dynamic_environment_node(node)
|
||||
|
||||
func _queue_dynamic_environment_node(node: Node) -> void:
|
||||
if not is_instance_valid(node):
|
||||
return
|
||||
|
||||
var ancestor = node.get_parent()
|
||||
while ancestor != null:
|
||||
if pending_environment_nodes.has(ancestor.get_instance_id()):
|
||||
return
|
||||
ancestor = ancestor.get_parent()
|
||||
|
||||
var stale_ids: Array[int] = []
|
||||
for node_id in pending_environment_nodes.keys():
|
||||
var pending_node = pending_environment_nodes[node_id]
|
||||
if not is_instance_valid(pending_node):
|
||||
stale_ids.append(node_id)
|
||||
continue
|
||||
if node.is_ancestor_of(pending_node):
|
||||
stale_ids.append(node_id)
|
||||
|
||||
for node_id in stale_ids:
|
||||
pending_environment_nodes.erase(node_id)
|
||||
|
||||
pending_environment_nodes[node.get_instance_id()] = node
|
||||
|
||||
func _process_pending_environment_nodes() -> void:
|
||||
var processed = 0
|
||||
for node_id in pending_environment_nodes.keys():
|
||||
if processed >= DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME:
|
||||
break
|
||||
|
||||
var node = pending_environment_nodes[node_id]
|
||||
pending_environment_nodes.erase(node_id)
|
||||
if not is_instance_valid(node):
|
||||
continue
|
||||
|
||||
_apply_dynamic_environment_materials(node)
|
||||
processed += 1
|
||||
|
||||
func _apply_dynamic_environment_materials(node: Node) -> void:
|
||||
if not is_instance_valid(node):
|
||||
@@ -160,7 +203,3 @@ func select_day_time(normalized_time: float) -> void:
|
||||
|
||||
if weather_controller:
|
||||
weather_controller.day_time = day_time
|
||||
|
||||
func toggle_fog(value: bool) -> void:
|
||||
if fog_node:
|
||||
fog_node.visible = value
|
||||
|
||||
@@ -20,17 +20,14 @@ const SNOW_CAP_SHADER: Shader = preload("res://core/daynight/snow_cap.gdshader")
|
||||
|
||||
var _mesh_instance: MeshInstance3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("weather_overlay_ignore")
|
||||
_ensure_mesh_instance()
|
||||
_rebuild()
|
||||
|
||||
|
||||
func rebuild() -> void:
|
||||
_rebuild()
|
||||
|
||||
|
||||
func _ensure_mesh_instance() -> void:
|
||||
_mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D
|
||||
if _mesh_instance != null:
|
||||
@@ -41,7 +38,6 @@ func _ensure_mesh_instance() -> void:
|
||||
_mesh_instance.add_to_group("weather_overlay_ignore")
|
||||
add_child(_mesh_instance)
|
||||
|
||||
|
||||
func _rebuild() -> void:
|
||||
var cap_width: float = 0.0
|
||||
var cap_depth: float = 0.0
|
||||
@@ -78,7 +74,6 @@ func _rebuild() -> void:
|
||||
_mesh_instance.material_override = _build_material(cap_width, cap_depth)
|
||||
_mesh_instance.visible = true
|
||||
|
||||
|
||||
func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
|
||||
var material := ShaderMaterial.new()
|
||||
material.shader = SNOW_CAP_SHADER
|
||||
@@ -87,7 +82,6 @@ func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
|
||||
material.set_shader_parameter("half_depth", cap_depth * 0.5)
|
||||
return material
|
||||
|
||||
|
||||
func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
|
||||
var points: Array[Vector3] = []
|
||||
for point in _get_aabb_points(target_mesh.get_aabb()):
|
||||
@@ -98,7 +92,6 @@ func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
|
||||
merged = merged.expand(point)
|
||||
return merged
|
||||
|
||||
|
||||
func _get_aabb_points(aabb: AABB) -> Array[Vector3]:
|
||||
var p: Vector3 = aabb.position
|
||||
var s: Vector3 = aabb.size
|
||||
|
||||
@@ -14,6 +14,7 @@ var godray: PackedScene
|
||||
var environment_dust: ColorRect
|
||||
var blur: ColorRect
|
||||
var environment_shadows: MeshInstance3D
|
||||
var fog: Node3D
|
||||
|
||||
var sun: DirectionalLight3D
|
||||
var environment: WorldEnvironment
|
||||
@@ -50,10 +51,12 @@ var current_wind_strength: float = 0.0
|
||||
var current_wind_fade: float = 0.0
|
||||
var max_wind_amount: int = 0
|
||||
var random_weather_restore_tween: Tween
|
||||
var random_event_remaining: float = 0.0
|
||||
var random_event_label_seconds: int = -1
|
||||
|
||||
func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
fireflies: GPUParticles3D, rain: GPUParticles3D, ray: PackedScene,
|
||||
dust: ColorRect, blurr: ColorRect, envshadows: MeshInstance3D,
|
||||
dust: ColorRect, blurr: ColorRect, thefog: Node3D, envshadows: MeshInstance3D,
|
||||
thesun: DirectionalLight3D, theenvironment: WorldEnvironment, environmentconfig: EnvironmentConfig,
|
||||
thecamera: Camera3D, thecamerapivot: Node3D, thundersounds: Array[AudioStream], rainsounds: Array[AudioStream]) -> void:
|
||||
particles_wind = wind
|
||||
@@ -64,6 +67,7 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
sun = thesun
|
||||
environment_dust = dust
|
||||
blur = blurr
|
||||
fog = thefog
|
||||
environment_shadows = envshadows
|
||||
environment = theenvironment
|
||||
environment_config = environmentconfig
|
||||
@@ -87,6 +91,7 @@ func _init(wind: GPUParticles3D, snow: GPUParticles3D,
|
||||
|
||||
toggle_dust(environment_config.enable_dust)
|
||||
toggle_blur(environment_config.enable_blur)
|
||||
toggle_fog(environment_config.enable_fog)
|
||||
|
||||
#set camera pivot if available
|
||||
if camera_pivot:
|
||||
@@ -104,10 +109,12 @@ func _ready() -> void:
|
||||
UIEvents.toggle_storm.connect(toggle_storm)
|
||||
UIEvents.toggle_dust.connect(toggle_dust)
|
||||
UIEvents.toggle_blur.connect(toggle_blur)
|
||||
UIEvents.toggle_fog.connect(toggle_fog)
|
||||
UIEvents.toggle_shadows.connect(toggle_shadows)
|
||||
_emit_weather_event_label()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
_update_random_event_label(delta)
|
||||
|
||||
_follow_camera()
|
||||
|
||||
@@ -273,6 +280,23 @@ func _get_weather_anchor_position() -> Variant:
|
||||
return camera.global_position
|
||||
return null
|
||||
|
||||
func _get_weather_anchor_basis() -> Variant:
|
||||
var source_basis: Basis
|
||||
if camera_pivot and is_instance_valid(camera_pivot):
|
||||
source_basis = camera_pivot.global_basis
|
||||
elif camera and is_instance_valid(camera):
|
||||
source_basis = camera.global_basis
|
||||
else:
|
||||
return null
|
||||
|
||||
var forward := -source_basis.z
|
||||
forward.y = 0.0
|
||||
if forward.length_squared() <= 0.0001:
|
||||
return Basis.IDENTITY
|
||||
forward = forward.normalized()
|
||||
var right := forward.cross(Vector3.UP).normalized()
|
||||
return Basis(right, Vector3.UP, -forward)
|
||||
|
||||
func _follow_camera() -> void:
|
||||
var cam_pos = _get_weather_anchor_position()
|
||||
if cam_pos == null:
|
||||
@@ -285,6 +309,12 @@ func _follow_camera() -> void:
|
||||
particles_wind.global_position = Vector3(cam_pos.x, cam_pos.y, cam_pos.z)
|
||||
if particles_fireflies:
|
||||
particles_fireflies.global_position = Vector3(cam_pos.x, particles_fireflies.position.y, cam_pos.z)
|
||||
if fog:
|
||||
fog.global_position = Vector3(cam_pos.x, fog.global_position.y, cam_pos.z)
|
||||
#used to follow camera pivot or camera
|
||||
var anchor_basis = _get_weather_anchor_basis()
|
||||
if anchor_basis != null:
|
||||
fog.global_basis = anchor_basis
|
||||
#endregion
|
||||
|
||||
#region Fireflies
|
||||
@@ -422,6 +452,8 @@ func _update_wind_amount_from_strength(value: float) -> void:
|
||||
func trigger_random_weather_event(duration: float = 0.0) -> void:
|
||||
if random_weather_restore_tween and random_weather_restore_tween.is_valid():
|
||||
random_weather_restore_tween.kill()
|
||||
random_event_remaining = 0.0
|
||||
random_event_label_seconds = -1
|
||||
|
||||
var previous_rain: bool = is_raining
|
||||
var previous_snow: bool = is_snowing
|
||||
@@ -439,12 +471,26 @@ func trigger_random_weather_event(duration: float = 0.0) -> void:
|
||||
_apply_weather_event_state(true, false, false, true)
|
||||
|
||||
if duration > 0.0:
|
||||
random_event_remaining = duration
|
||||
_emit_weather_event_label()
|
||||
random_weather_restore_tween = create_tween()
|
||||
random_weather_restore_tween.tween_interval(duration)
|
||||
random_weather_restore_tween.tween_callback(func():
|
||||
random_event_remaining = 0.0
|
||||
random_event_label_seconds = -1
|
||||
_apply_weather_event_state(previous_rain, previous_snow, previous_wind, previous_storm)
|
||||
)
|
||||
|
||||
func _update_random_event_label(delta: float) -> void:
|
||||
if random_event_remaining <= 0.0:
|
||||
return
|
||||
|
||||
random_event_remaining = maxf(random_event_remaining - delta, 0.0)
|
||||
var display_seconds: int = ceili(random_event_remaining)
|
||||
if display_seconds != random_event_label_seconds:
|
||||
random_event_label_seconds = display_seconds
|
||||
_emit_weather_event_label()
|
||||
|
||||
func _apply_weather_event_state(rain_enabled: bool, snow_enabled: bool, wind_enabled: bool, storm_enabled: bool = false) -> void:
|
||||
if is_storm and not storm_enabled:
|
||||
toggle_storm(false)
|
||||
@@ -758,6 +804,8 @@ func _emit_weather_event_label() -> void:
|
||||
active_events.append("Wind")
|
||||
if not active_events.is_empty():
|
||||
weather_label = "Weather: %s" % " + ".join(active_events)
|
||||
if random_event_remaining > 0.0:
|
||||
weather_label += " (%s'')" % ceili(random_event_remaining)
|
||||
UIEvents.weather_event_changed.emit(weather_label)
|
||||
|
||||
#disable snow and set default values and shader
|
||||
@@ -809,6 +857,10 @@ func toggle_blur(value: bool) -> void:
|
||||
|
||||
ApplyPostProcessBlurConfig()
|
||||
|
||||
func toggle_fog(value: bool) -> void:
|
||||
if fog:
|
||||
fog.visible = value
|
||||
|
||||
func toggle_shadows(value: bool) -> void:
|
||||
if environment_shadows:
|
||||
environment_shadows.visible = value
|
||||
|
||||
@@ -83,7 +83,7 @@ extends Resource
|
||||
@export var enable_dust: bool = false #Floating dust particles overlay
|
||||
@export var enable_blur: bool = true #Screen blur effect
|
||||
@export var enable_environment_shadows: bool = true #Cloud shadow projection on terrain
|
||||
@export var enable_fog: bool = true #Enable fog around the train
|
||||
@export var enable_fog: bool = false #Enable fog around the train
|
||||
@export var blur_amount: float = 0.6
|
||||
|
||||
@export_group("Dust")
|
||||
@@ -184,3 +184,7 @@ extends Resource
|
||||
@export var water_color_afternoon: Color = Color(0.889, 0.733, 0.205, 1.0) #Tint for afternoon (sunset)
|
||||
@export var water_color_night: Color = Color(0.728, 0.54, 0.986, 1.0); #Tint for night
|
||||
@export var water_darkening_rain: float = 0.7 #Percentage of darkening when is rainy
|
||||
|
||||
#Random events
|
||||
@export_group("Random Events")
|
||||
@export var random_event_duration: float = 30.0 #Duration time for random event
|
||||
|
||||
32
core/game_state/game_state.gd
Normal file
32
core/game_state/game_state.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
extends Node
|
||||
|
||||
const SAVE_PATH: String = "user://savegame.json"
|
||||
|
||||
var save_data: SaveGameData = SaveGameData.new()
|
||||
var is_loaded: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
load_game()
|
||||
|
||||
func save_game() -> void:
|
||||
var save_file = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
|
||||
var json_string = JSON.stringify(save_data.to_dictionary())
|
||||
save_file.store_line(json_string)
|
||||
|
||||
func load_game() -> void:
|
||||
if not FileAccess.file_exists(SAVE_PATH):
|
||||
save_data = SaveGameData.new()
|
||||
is_loaded = true
|
||||
return
|
||||
|
||||
var file = FileAccess.open(SAVE_PATH, FileAccess.READ)
|
||||
var json_string = file.get_as_text()
|
||||
|
||||
var json = JSON.new()
|
||||
var parse_result = json.parse(json_string)
|
||||
|
||||
save_data = SaveGameData.new()
|
||||
if parse_result == OK and json.data is Dictionary:
|
||||
save_data = SaveGameData.from_dictionary(json.data)
|
||||
|
||||
is_loaded = true
|
||||
1
core/game_state/game_state.gd.uid
Normal file
1
core/game_state/game_state.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b17g2w2g101o6
|
||||
34
core/game_state/save_game_data.gd
Normal file
34
core/game_state/save_game_data.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
class_name SaveGameData
|
||||
extends Resource
|
||||
|
||||
var unlocked_collectibles_ids: Array[StringName] = []
|
||||
var saved_photos: Array[String] = []
|
||||
var audio_bus_volumes: Dictionary[String, float] = {}
|
||||
|
||||
func to_dictionary() -> Dictionary:
|
||||
var serialized_collectible_ids: Array[String] = []
|
||||
for collectible_id in unlocked_collectibles_ids:
|
||||
serialized_collectible_ids.append(str(collectible_id))
|
||||
|
||||
return {
|
||||
"unlocked_collectibles_ids": serialized_collectible_ids,
|
||||
"saved_photos": saved_photos,
|
||||
"audio_bus_volumes": audio_bus_volumes,
|
||||
}
|
||||
|
||||
static func from_dictionary(data: Dictionary) -> SaveGameData:
|
||||
var save_game_data := SaveGameData.new()
|
||||
|
||||
if data.has("unlocked_collectibles_ids"):
|
||||
for collectible_id in data["unlocked_collectibles_ids"]:
|
||||
save_game_data.unlocked_collectibles_ids.append(StringName(str(collectible_id)))
|
||||
|
||||
if data.has("saved_photos"):
|
||||
for photo_path in data["saved_photos"]:
|
||||
save_game_data.saved_photos.append(str(photo_path))
|
||||
|
||||
if data.has("audio_bus_volumes") and data["audio_bus_volumes"] is Dictionary:
|
||||
for bus_name in data["audio_bus_volumes"]:
|
||||
save_game_data.audio_bus_volumes[str(bus_name)] = float(data["audio_bus_volumes"][bus_name])
|
||||
|
||||
return save_game_data
|
||||
1
core/game_state/save_game_data.gd.uid
Normal file
1
core/game_state/save_game_data.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bxmvs842r82vl
|
||||
4
core/photo_mode/data/collectible_library.gd
Normal file
4
core/photo_mode/data/collectible_library.gd
Normal file
@@ -0,0 +1,4 @@
|
||||
class_name CollectibleLibrary
|
||||
extends Resource
|
||||
|
||||
@export var collectibles: Array[CollectibleResource]
|
||||
1
core/photo_mode/data/collectible_library.gd.uid
Normal file
1
core/photo_mode/data/collectible_library.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://hhuufh87skq5
|
||||
31
core/photo_mode/data/collectible_library.tres
Normal file
31
core/photo_mode/data/collectible_library.tres
Normal file
@@ -0,0 +1,31 @@
|
||||
[gd_resource type="Resource" script_class="CollectibleLibrary" format=3 uid="uid://c6pkpvsvimafb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bj34o0org55ei" path="res://core/photo_mode/data/collectible_resource.gd" id="1_3cgvf"]
|
||||
[ext_resource type="Script" uid="uid://hhuufh87skq5" path="res://core/photo_mode/data/collectible_library.gd" id="2_ggu10"]
|
||||
[ext_resource type="Texture2D" uid="uid://cx8d233y32kmu" path="res://icon.svg" id="2_pxmdy"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_3cgvf"]
|
||||
script = ExtResource("1_3cgvf")
|
||||
id = &"cane"
|
||||
title = "Cane"
|
||||
image = ExtResource("2_pxmdy")
|
||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ggu10"]
|
||||
script = ExtResource("1_3cgvf")
|
||||
id = &"gatto"
|
||||
title = "Gatto"
|
||||
image = ExtResource("2_pxmdy")
|
||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pxmdy"]
|
||||
script = ExtResource("1_3cgvf")
|
||||
id = &"farfalla"
|
||||
title = "Farfalla"
|
||||
image = ExtResource("2_pxmdy")
|
||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||
|
||||
[resource]
|
||||
script = ExtResource("2_ggu10")
|
||||
collectibles = Array[ExtResource("1_3cgvf")]([SubResource("Resource_3cgvf"), SubResource("Resource_ggu10"), SubResource("Resource_pxmdy")])
|
||||
metadata/_custom_type_script = "uid://hhuufh87skq5"
|
||||
6
core/photo_mode/data/collectible_resource.gd
Normal file
6
core/photo_mode/data/collectible_resource.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
class_name CollectibleResource
|
||||
extends Resource
|
||||
|
||||
@export var id: StringName
|
||||
@export var title: String
|
||||
@export var image: Texture2D
|
||||
1
core/photo_mode/data/collectible_resource.gd.uid
Normal file
1
core/photo_mode/data/collectible_resource.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bj34o0org55ei
|
||||
60
core/photo_mode/managers/collection_manager.gd
Normal file
60
core/photo_mode/managers/collection_manager.gd
Normal file
@@ -0,0 +1,60 @@
|
||||
extends Node
|
||||
|
||||
signal on_collectible_unlocked(collectible_id: StringName)
|
||||
signal on_photo_saved(filePath: String)
|
||||
|
||||
var collectibles_library: CollectibleLibrary = preload("res://core/photo_mode/data/collectible_library.tres")
|
||||
|
||||
var unlocked_collectibles_ids: Array[StringName] = []
|
||||
var saved_photos: Array[String] = []
|
||||
|
||||
func _ready() -> void:
|
||||
load_save_data()
|
||||
|
||||
func unlock_collectible(collectible_id: StringName) -> void:
|
||||
if not collectible_id in unlocked_collectibles_ids:
|
||||
var new_collectible = get_collectible_by_id(collectible_id)
|
||||
if new_collectible:
|
||||
unlocked_collectibles_ids.append(collectible_id)
|
||||
sync_save_data()
|
||||
on_collectible_unlocked.emit(collectible_id)
|
||||
|
||||
func get_collectible_by_id(id: StringName) -> CollectibleResource:
|
||||
for collectible in collectibles_library.collectibles:
|
||||
if collectible.id == id:
|
||||
return collectible
|
||||
return null
|
||||
|
||||
func get_all_collectibles() -> Array[CollectibleResource]:
|
||||
return collectibles_library.collectibles
|
||||
|
||||
func get_unlocked_collectible_ids() -> Array[StringName]:
|
||||
return unlocked_collectibles_ids
|
||||
|
||||
func save_photo_to_disk_async() -> void:
|
||||
await RenderingServer.frame_post_draw
|
||||
var image = get_viewport().get_texture().get_image()
|
||||
|
||||
if not DirAccess.dir_exists_absolute("user://photos"):
|
||||
DirAccess.make_dir_absolute("user://photos")
|
||||
|
||||
var timestamp = str(Time.get_unix_time_from_system())
|
||||
var file_path = "user://photos/photo_" + timestamp + ".png"
|
||||
image.save_png(file_path)
|
||||
|
||||
saved_photos.append(file_path)
|
||||
sync_save_data()
|
||||
on_photo_saved.emit(file_path)
|
||||
|
||||
func sync_save_data() -> void:
|
||||
GameState.save_data.unlocked_collectibles_ids = unlocked_collectibles_ids.duplicate()
|
||||
GameState.save_data.saved_photos = saved_photos.duplicate()
|
||||
|
||||
func load_save_data() -> void:
|
||||
unlocked_collectibles_ids = GameState.save_data.unlocked_collectibles_ids.duplicate()
|
||||
saved_photos = GameState.save_data.saved_photos.duplicate()
|
||||
|
||||
if unlocked_collectibles_ids.is_empty() and saved_photos.is_empty():
|
||||
unlocked_collectibles_ids.append(&"cane")
|
||||
|
||||
sync_save_data()
|
||||
1
core/photo_mode/managers/collection_manager.gd.uid
Normal file
1
core/photo_mode/managers/collection_manager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c3kq1qddpm8tf
|
||||
6
core/photo_mode/runtime/collectible.gd
Normal file
6
core/photo_mode/runtime/collectible.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
extends Area3D
|
||||
|
||||
@export var collectible_data: CollectibleResource
|
||||
|
||||
func _ready() -> void:
|
||||
add_to_group("collectible")
|
||||
1
core/photo_mode/runtime/collectible.gd.uid
Normal file
1
core/photo_mode/runtime/collectible.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://62d14boivr3g
|
||||
11
core/photo_mode/runtime/collectible.tscn
Normal file
11
core/photo_mode/runtime/collectible.tscn
Normal file
@@ -0,0 +1,11 @@
|
||||
[gd_scene format=3 uid="uid://bmkxt6btcx8qr"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://62d14boivr3g" path="res://core/photo_mode/runtime/collectible.gd" id="1_xse8c"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_xse8c"]
|
||||
|
||||
[node name="Collectible" type="Area3D" unique_id=1229019813]
|
||||
script = ExtResource("1_xse8c")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1479480920]
|
||||
shape = SubResource("BoxShape3D_xse8c")
|
||||
94
core/photo_mode/runtime/photo_mode_controller.gd
Normal file
94
core/photo_mode/runtime/photo_mode_controller.gd
Normal file
@@ -0,0 +1,94 @@
|
||||
extends Node3D
|
||||
|
||||
@export_group("Speed")
|
||||
@export var pan_speed: float = 5.0
|
||||
@export var rotation_speed: float = 0.003
|
||||
|
||||
@export_group("Bounds")
|
||||
@export var movement_bounds: AABB
|
||||
|
||||
@export_group("Ref")
|
||||
@export var rotation_target: Node3D
|
||||
|
||||
@onready var camera: Camera3D = $%Camera3D
|
||||
|
||||
var total_yaw: float = 0.0
|
||||
var total_pitch: float = 0.0
|
||||
var orbit_distance: float = 0.0
|
||||
var current_pan: Vector2 = Vector2.ZERO
|
||||
var is_active: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
total_yaw = global_rotation.y
|
||||
total_pitch = global_rotation.x
|
||||
|
||||
if rotation_target:
|
||||
orbit_distance = global_position.distance_to(rotation_target.global_position)
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("toggle_photo_mode"):
|
||||
is_active = !is_active
|
||||
|
||||
get_tree().paused = is_active
|
||||
|
||||
if !is_active:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
|
||||
else:
|
||||
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||
|
||||
if event is InputEventMouseMotion and is_active:
|
||||
total_yaw -= event.relative.x * rotation_speed
|
||||
|
||||
if event.is_action_pressed("take_photo"):
|
||||
take_photo_async()
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not rotation_target:
|
||||
return
|
||||
|
||||
|
||||
var pan_input = Input.get_vector("photo_pan_left", "photo_pan_right", "photo_pan_up", "photo_pan_down")
|
||||
var rot_basis = Basis.from_euler(Vector3(total_pitch, total_yaw, 0))
|
||||
|
||||
if pan_input != Vector2.ZERO and is_active:
|
||||
current_pan.x += pan_input.x * pan_speed * delta
|
||||
current_pan.y += -pan_input.y * pan_speed * delta
|
||||
|
||||
if movement_bounds.size != Vector3.ZERO:
|
||||
current_pan.x = clampf(current_pan.x, movement_bounds.position.x, movement_bounds.position.x + movement_bounds.size.x)
|
||||
current_pan.y = clampf(current_pan.y, movement_bounds.position.y, movement_bounds.position.y + movement_bounds.size.y)
|
||||
|
||||
var right_dir = rot_basis.x.normalized()
|
||||
var up_dir = rot_basis.y.normalized()
|
||||
|
||||
var final_pan_offset = (right_dir * current_pan.x) + (up_dir * current_pan.y)
|
||||
|
||||
var orbit_pos = rotation_target.global_position + (rot_basis * Vector3(0, 0, orbit_distance))
|
||||
|
||||
global_position = orbit_pos + final_pan_offset
|
||||
global_basis = rot_basis
|
||||
|
||||
func take_photo_async() -> void:
|
||||
if !is_active:
|
||||
return
|
||||
|
||||
var targets = get_tree().get_nodes_in_group("collectible")
|
||||
var space_state = get_world_3d().direct_space_state
|
||||
|
||||
await CollectionManager.save_photo_to_disk_async()
|
||||
|
||||
for target in targets:
|
||||
if not target.collectible_data:
|
||||
continue
|
||||
|
||||
if camera.is_position_in_frustum(target.global_position):
|
||||
var query = PhysicsRayQueryParameters3D.create(camera.global_position, target.global_position)
|
||||
query.collide_with_areas = true
|
||||
query.collide_with_bodies = true
|
||||
|
||||
var result = space_state.intersect_ray(query)
|
||||
|
||||
if result and result.collider == target:
|
||||
CollectionManager.unlock_collectible(target.collectible_data.id)
|
||||
|
||||
GameState.save_game()
|
||||
1
core/photo_mode/runtime/photo_mode_controller.gd.uid
Normal file
1
core/photo_mode/runtime/photo_mode_controller.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d7ln6iru6mq6
|
||||
10
core/photo_mode/runtime/photo_mode_controller.tscn
Normal file
10
core/photo_mode/runtime/photo_mode_controller.tscn
Normal file
@@ -0,0 +1,10 @@
|
||||
[gd_scene format=3 uid="uid://vni5kjalum6d"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d7ln6iru6mq6" path="res://core/photo_mode/runtime/photo_mode_controller.gd" id="1_uhpya"]
|
||||
|
||||
[node name="PhotoModeController" type="Node3D" unique_id=695158870]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_uhpya")
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1369039645]
|
||||
unique_name_in_owner = true
|
||||
34
core/photo_mode/ui/collectible_gallery.gd
Normal file
34
core/photo_mode/ui/collectible_gallery.gd
Normal file
@@ -0,0 +1,34 @@
|
||||
extends Control
|
||||
|
||||
@export var collectible_ui_scene: PackedScene
|
||||
|
||||
@onready var grid_container: GridContainer = $%CollectibleGrid
|
||||
|
||||
func _ready() -> void:
|
||||
CollectionManager.on_collectible_unlocked.connect(_unlock_collectible)
|
||||
setup()
|
||||
|
||||
func setup() -> void:
|
||||
var unlocked_collectible_ids = CollectionManager.get_unlocked_collectible_ids()
|
||||
var collectibles = CollectionManager.get_all_collectibles()
|
||||
|
||||
for child in grid_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
for collectible in collectibles:
|
||||
_add_collectible(collectible)
|
||||
if unlocked_collectible_ids.has(collectible.id):
|
||||
_unlock_collectible(collectible.id)
|
||||
|
||||
func on_collectible_unlocked(collectible_id: StringName) -> void:
|
||||
_unlock_collectible(collectible_id)
|
||||
|
||||
func _add_collectible(collectible: CollectibleResource) -> void:
|
||||
var collectible_ui: CollectibleUI = collectible_ui_scene.instantiate()
|
||||
collectible_ui.setup(collectible)
|
||||
grid_container.add_child(collectible_ui)
|
||||
|
||||
func _unlock_collectible(collectible_id: StringName) -> void:
|
||||
for collectible_ui in grid_container.get_children():
|
||||
if collectible_ui.collectible_resource.id == collectible_id:
|
||||
collectible_ui.unlock()
|
||||
1
core/photo_mode/ui/collectible_gallery.gd.uid
Normal file
1
core/photo_mode/ui/collectible_gallery.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dq3qtcrdnikl7
|
||||
50
core/photo_mode/ui/collectible_gallery.tscn
Normal file
50
core/photo_mode/ui/collectible_gallery.tscn
Normal file
@@ -0,0 +1,50 @@
|
||||
[gd_scene format=3 uid="uid://bvw086glfpcba"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dq3qtcrdnikl7" path="res://core/photo_mode/ui/collectible_gallery.gd" id="1_67tug"]
|
||||
[ext_resource type="PackedScene" uid="uid://dp7dvfauh5rpx" path="res://core/photo_mode/ui/collectible_ui.tscn" id="2_or234"]
|
||||
|
||||
[node name="CollectibleGallery" type="Control" unique_id=354419843]
|
||||
layout_mode = 3
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_67tug")
|
||||
collectible_ui_scene = ExtResource("2_or234")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=640179265]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -350.0
|
||||
offset_top = -350.0
|
||||
offset_right = 350.0
|
||||
offset_bottom = 350.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer" unique_id=125147979]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer" unique_id=348576028]
|
||||
layout_mode = 2
|
||||
draw_focus_border = true
|
||||
|
||||
[node name="CollectibleGrid" type="GridContainer" parent="PanelContainer/MarginContainer/ScrollContainer" unique_id=1187865988]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 2
|
||||
theme_override_constants/h_separation = 12
|
||||
theme_override_constants/v_separation = 12
|
||||
columns = 3
|
||||
22
core/photo_mode/ui/collectible_ui.gd
Normal file
22
core/photo_mode/ui/collectible_ui.gd
Normal file
@@ -0,0 +1,22 @@
|
||||
extends Control
|
||||
|
||||
class_name CollectibleUI
|
||||
|
||||
@onready var label: Label = $%CollectibleName
|
||||
@onready var texture_rect: TextureRect = $%CollectibleTexture
|
||||
var collectible_resource: CollectibleResource
|
||||
|
||||
func setup(collectible: CollectibleResource) -> void:
|
||||
collectible_resource = collectible
|
||||
if !label:
|
||||
label = $%CollectibleName
|
||||
label.text = collectible_resource.title
|
||||
if collectible.image:
|
||||
if !texture_rect:
|
||||
texture_rect = $%CollectibleTexture
|
||||
texture_rect.texture = collectible_resource.image
|
||||
|
||||
func unlock() -> void:
|
||||
if !texture_rect:
|
||||
texture_rect = $%CollectibleTexture
|
||||
texture_rect.set_modulate(Color(1,1,1,1))
|
||||
1
core/photo_mode/ui/collectible_ui.gd.uid
Normal file
1
core/photo_mode/ui/collectible_ui.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dxh8e1n16qjpp
|
||||
49
core/photo_mode/ui/collectible_ui.tscn
Normal file
49
core/photo_mode/ui/collectible_ui.tscn
Normal file
@@ -0,0 +1,49 @@
|
||||
[gd_scene format=3 uid="uid://dp7dvfauh5rpx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dxh8e1n16qjpp" path="res://core/photo_mode/ui/collectible_ui.gd" id="1_tu5nx"]
|
||||
[ext_resource type="Texture2D" uid="uid://cx8d233y32kmu" path="res://icon.svg" id="1_x3wje"]
|
||||
|
||||
[node name="CollectibleUI" type="Control" unique_id=201865221]
|
||||
custom_minimum_size = Vector2(200, 200)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 200.0
|
||||
script = ExtResource("1_tu5nx")
|
||||
|
||||
[node name="Panel" type="PanelContainer" parent="." unique_id=1372516531]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="Panel" unique_id=1141643525]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel/MarginContainer" unique_id=1841409877]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="CollectibleName" type="Label" parent="Panel/MarginContainer/VBoxContainer" unique_id=117774359]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
text = "Collectible"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="Panel/MarginContainer/VBoxContainer" unique_id=1345822244]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CollectibleTexture" type="TextureRect" parent="Panel/MarginContainer/VBoxContainer" unique_id=506844785]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(0.16206557, 0.1620656, 0.16206557, 1)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
texture = ExtResource("1_x3wje")
|
||||
stretch_mode = 3
|
||||
11
core/photo_mode/ui/photo.gd
Normal file
11
core/photo_mode/ui/photo.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
extends Control
|
||||
|
||||
class_name Photo
|
||||
|
||||
@onready var texture_rect: TextureRect = $%PhotoTexture
|
||||
|
||||
func setup(texture: Texture) -> void:
|
||||
if texture:
|
||||
if !texture_rect:
|
||||
texture_rect = $%PhotoTexture
|
||||
texture_rect.texture = texture
|
||||
1
core/photo_mode/ui/photo.gd.uid
Normal file
1
core/photo_mode/ui/photo.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dsey5dvc11vpq
|
||||
38
core/photo_mode/ui/photo.tscn
Normal file
38
core/photo_mode/ui/photo.tscn
Normal file
@@ -0,0 +1,38 @@
|
||||
[gd_scene format=3 uid="uid://cvus62qkop3qi"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dsey5dvc11vpq" path="res://core/photo_mode/ui/photo.gd" id="1_u0arp"]
|
||||
|
||||
[node name="Photo" type="Control" unique_id=201865221]
|
||||
custom_minimum_size = Vector2(200, 200)
|
||||
layout_mode = 3
|
||||
anchors_preset = 0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 200.0
|
||||
script = ExtResource("1_u0arp")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="." unique_id=1208008621]
|
||||
layout_mode = 0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 200.0
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="ColorRect" unique_id=1141643525]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="Panel" type="PanelContainer" parent="ColorRect/MarginContainer" unique_id=1372516531]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="PhotoTexture" type="TextureRect" parent="ColorRect/MarginContainer/Panel" unique_id=506844785]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
expand_mode = 1
|
||||
stretch_mode = 6
|
||||
27
core/photo_mode/ui/photo_gallery.gd
Normal file
27
core/photo_mode/ui/photo_gallery.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
extends Control
|
||||
|
||||
@export var photo_scene: PackedScene
|
||||
|
||||
@onready var grid_container: GridContainer = $%PhotoGrid
|
||||
|
||||
func _ready() -> void:
|
||||
CollectionManager.on_photo_saved.connect(_create_photo_thumbnail)
|
||||
load_gallery()
|
||||
|
||||
func load_gallery() -> void:
|
||||
for child in grid_container.get_children():
|
||||
child.queue_free()
|
||||
|
||||
var saved_photos = CollectionManager.saved_photos
|
||||
|
||||
for file_path in saved_photos:
|
||||
if FileAccess.file_exists(file_path):
|
||||
_create_photo_thumbnail(file_path)
|
||||
|
||||
func _create_photo_thumbnail(file_path: String) -> void:
|
||||
var image = Image.load_from_file(file_path)
|
||||
if image:
|
||||
var photo: Photo = photo_scene.instantiate()
|
||||
var texture = ImageTexture.create_from_image(image)
|
||||
photo.setup(texture)
|
||||
grid_container.add_child(photo)
|
||||
1
core/photo_mode/ui/photo_gallery.gd.uid
Normal file
1
core/photo_mode/ui/photo_gallery.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://k4iqrlkbjppl
|
||||
50
core/photo_mode/ui/photo_gallery.tscn
Normal file
50
core/photo_mode/ui/photo_gallery.tscn
Normal file
@@ -0,0 +1,50 @@
|
||||
[gd_scene format=3 uid="uid://b6r787sik5yil"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://k4iqrlkbjppl" path="res://core/photo_mode/ui/photo_gallery.gd" id="1_bp5uf"]
|
||||
[ext_resource type="PackedScene" uid="uid://cvus62qkop3qi" path="res://core/photo_mode/ui/photo.tscn" id="2_45wok"]
|
||||
|
||||
[node name="PhotoGallery" type="Control" unique_id=354419843]
|
||||
layout_mode = 3
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_bp5uf")
|
||||
photo_scene = ExtResource("2_45wok")
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="." unique_id=640179265]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -350.0
|
||||
offset_top = -350.0
|
||||
offset_right = 350.0
|
||||
offset_bottom = 350.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="PanelContainer" unique_id=125147979]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 12
|
||||
theme_override_constants/margin_top = 12
|
||||
theme_override_constants/margin_right = 12
|
||||
theme_override_constants/margin_bottom = 12
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="PanelContainer/MarginContainer" unique_id=348576028]
|
||||
layout_mode = 2
|
||||
draw_focus_border = true
|
||||
|
||||
[node name="PhotoGrid" type="GridContainer" parent="PanelContainer/MarginContainer/ScrollContainer" unique_id=1187865988]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 2
|
||||
theme_override_constants/h_separation = 12
|
||||
theme_override_constants/v_separation = 12
|
||||
columns = 3
|
||||
31
core/radio/radio.gd
Normal file
31
core/radio/radio.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
extends AudioStreamPlayer
|
||||
|
||||
class_name Radio
|
||||
|
||||
@export var playlist: Array[AudioStream] = []
|
||||
var current_track_index: int = 0
|
||||
|
||||
func _ready():
|
||||
finished.connect(next_track)
|
||||
|
||||
func play_track(index: int = current_track_index):
|
||||
if playlist.is_empty():
|
||||
return
|
||||
|
||||
current_track_index = posmod(index, playlist.size())
|
||||
stream = playlist[current_track_index]
|
||||
play()
|
||||
stream_paused = false
|
||||
|
||||
func next_track():
|
||||
play_track(current_track_index + 1)
|
||||
|
||||
func prev_track():
|
||||
play_track(current_track_index - 1)
|
||||
|
||||
func toggle_pause():
|
||||
stream_paused = !stream_paused
|
||||
|
||||
func stop_radio():
|
||||
stop()
|
||||
stream_paused = false
|
||||
1
core/radio/radio.gd.uid
Normal file
1
core/radio/radio.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bwrgh6xlvhqch
|
||||
7
core/radio/radio.tscn
Normal file
7
core/radio/radio.tscn
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_scene format=3 uid="uid://cpeyt1dgrtglc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bwrgh6xlvhqch" path="res://core/radio/radio.gd" id="1_2akjj"]
|
||||
|
||||
[node name="Radio" type="AudioStreamPlayer" unique_id=1234112225]
|
||||
bus = &"Music"
|
||||
script = ExtResource("1_2akjj")
|
||||
@@ -30,6 +30,10 @@ signal toggle_shadows(value: bool)
|
||||
@warning_ignore("unused_signal")
|
||||
signal toggle_fog(value: bool)
|
||||
|
||||
#railway signals
|
||||
@warning_ignore("unused_signal")
|
||||
signal update_rail_chunks()
|
||||
|
||||
#day cycle signals
|
||||
@warning_ignore("unused_signal")
|
||||
signal toggle_pause_daytime(value: bool)
|
||||
|
||||
15
default_bus_layout.tres
Normal file
15
default_bus_layout.tres
Normal file
@@ -0,0 +1,15 @@
|
||||
[gd_resource type="AudioBusLayout" format=3 uid="uid://cqvx62pwvvboj"]
|
||||
|
||||
[resource]
|
||||
bus/1/name = &"Music"
|
||||
bus/1/solo = false
|
||||
bus/1/mute = false
|
||||
bus/1/bypass_fx = false
|
||||
bus/1/volume_db = 0.0
|
||||
bus/1/send = &"Master"
|
||||
bus/2/name = &"SFX"
|
||||
bus/2/solo = false
|
||||
bus/2/mute = false
|
||||
bus/2/bypass_fx = false
|
||||
bus/2/volume_db = 0.0
|
||||
bus/2/send = &"Master"
|
||||
92
docs/gyms/ai/gym_ai.tscn
Normal file
92
docs/gyms/ai/gym_ai.tscn
Normal file
@@ -0,0 +1,92 @@
|
||||
[gd_scene format=3 uid="uid://dqvrhiqgkd3w1"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_a2xtd"]
|
||||
|
||||
[sub_resource type="NavigationMesh" id="NavigationMesh_optuv"]
|
||||
vertices = PackedVector3Array(10.984741, 0.25012434, -1.0140381, 11.234741, 0.25012434, 0.23596191, 19.484741, 0.25012434, 0.23596191, 19.484741, 0.25012434, -19.514038, 9.234741, 0.25012434, -1.0140381, -19.515259, 0.25012434, -19.514038, -19.515259, 0.25012434, -0.014038086, 8.984741, 0.25012434, -0.014038086, 10.984741, 0.25012434, 1.2359619, 19.484741, 0.25012434, 19.235962, 9.234741, 0.25012434, 1.2359619, -19.515259, 0.25012434, 19.235962)
|
||||
polygons = [PackedInt32Array(1, 0, 2), PackedInt32Array(2, 0, 3), PackedInt32Array(6, 5, 4), PackedInt32Array(4, 5, 3), PackedInt32Array(3, 0, 4), PackedInt32Array(4, 7, 6), PackedInt32Array(1, 2, 8), PackedInt32Array(8, 2, 9), PackedInt32Array(6, 10, 11), PackedInt32Array(11, 10, 9), PackedInt32Array(10, 8, 9), PackedInt32Array(6, 7, 10)]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_optuv"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_xtjak"]
|
||||
size = Vector3(1.9942131, 0.09710693, 1.984024)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_lmjyn"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_lmjyn"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_lmjyn"]
|
||||
|
||||
[node name="GymAI" type="Node3D" unique_id=868339787]
|
||||
|
||||
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="." unique_id=774907858]
|
||||
navigation_mesh = SubResource("NavigationMesh_optuv")
|
||||
|
||||
[node name="Floor" type="MeshInstance3D" parent="NavigationRegion3D" unique_id=1976415311]
|
||||
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -0.83473957, 0)
|
||||
mesh = SubResource("PlaneMesh_optuv")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="NavigationRegion3D/Floor" unique_id=2007477719]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationRegion3D/Floor/StaticBody3D" unique_id=1446628130]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0036563873, -0.009703338, -0.00868988)
|
||||
shape = SubResource("BoxShape3D_xtjak")
|
||||
|
||||
[node name="Obstacle" type="MeshInstance3D" parent="NavigationRegion3D" unique_id=710701082]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 10.148018, 0.06508446, 0)
|
||||
mesh = SubResource("BoxMesh_lmjyn")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="NavigationRegion3D/Obstacle" unique_id=67152580]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="NavigationRegion3D/Obstacle/StaticBody3D" unique_id=1663742898]
|
||||
shape = SubResource("BoxShape3D_lmjyn")
|
||||
|
||||
[node name="AIBase" parent="." unique_id=1228675528 instance=ExtResource("1_a2xtd")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.48246834, 0.21202153, 0.11262059)
|
||||
|
||||
[node name="Camera3D" type="Camera3D" parent="." unique_id=1148396057]
|
||||
transform = Transform3D(-2.0613477e-08, 0.8818225, -0.47158146, 3.854569e-08, 0.47158146, 0.8818225, 1, -3.5527137e-15, -4.371139e-08, -18.21907, 28.71355, 0)
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1772424900]
|
||||
environment = SubResource("Environment_lmjyn")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=269230449]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.17952333, 0.98375374, 0, -0.98375374, 0.17952333, 0, 18.920979, 0)
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=1072240389]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=1647272132]
|
||||
layout_mode = 0
|
||||
offset_left = 50.0
|
||||
offset_top = 50.0
|
||||
offset_right = 400.0
|
||||
offset_bottom = 827.0
|
||||
|
||||
[node name="Label" type="Label" parent="Control/PanelContainer" unique_id=272421245]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 1
|
||||
text = "System Logic:
|
||||
- The NPC uses a finite state machine to switch between behaviors.
|
||||
- State logic runs during physics updates, while movement is handled by the agent through NavigationAgent3D.
|
||||
|
||||
AI States:
|
||||
- IdleState: The agent waits in place for the duration defined by wait_time.
|
||||
- PatrolState: The agent selects a valid random destination and moves toward it.
|
||||
|
||||
Core Components:
|
||||
- NavigationAgent3D: Calculates the path and reports when the destination has been reached.
|
||||
- PatrolRadiusShape: Defines the random movement area used when choosing the next patrol point.
|
||||
- StateMachine: Initializes the available states and handles transitions between them.
|
||||
|
||||
Parameters:
|
||||
- Speed: Movement speed of the agent.
|
||||
- Wait Time: Delay in seconds on the IdleState node.
|
||||
- Area Radius: Radius of the SphereShape3D used by PatrolRadiusShape."
|
||||
autowrap_mode = 2
|
||||
7
docs/gyms/photo_mode/gym_photo_mode.gd
Normal file
7
docs/gyms/photo_mode/gym_photo_mode.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var gallery: Control = $%Gallery
|
||||
|
||||
|
||||
func _on_button_gallery_pressed() -> void:
|
||||
gallery.visible = !gallery.visible
|
||||
1
docs/gyms/photo_mode/gym_photo_mode.gd.uid
Normal file
1
docs/gyms/photo_mode/gym_photo_mode.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://7oglx4br38d5
|
||||
138
docs/gyms/photo_mode/gym_photo_mode.tscn
Normal file
138
docs/gyms/photo_mode/gym_photo_mode.tscn
Normal file
@@ -0,0 +1,138 @@
|
||||
[gd_scene format=3 uid="uid://bwc8slnbu7dmn"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://7oglx4br38d5" path="res://docs/gyms/photo_mode/gym_photo_mode.gd" id="1_cl1h5"]
|
||||
[ext_resource type="PackedScene" uid="uid://vni5kjalum6d" path="res://core/photo_mode/runtime/photo_mode_controller.tscn" id="2_q5kgc"]
|
||||
[ext_resource type="PackedScene" uid="uid://bmkxt6btcx8qr" path="res://core/photo_mode/runtime/collectible.tscn" id="3_734hf"]
|
||||
[ext_resource type="Texture2D" uid="uid://c3grftlmap4q5" path="res://tgcc/chunk/prop/tree/leaf1_alpha.png" id="4_00joj"]
|
||||
[ext_resource type="Script" uid="uid://bj34o0org55ei" path="res://core/photo_mode/data/collectible_resource.gd" id="5_crfij"]
|
||||
[ext_resource type="PackedScene" uid="uid://bvw086glfpcba" path="res://core/photo_mode/ui/collectible_gallery.tscn" id="6_6aab5"]
|
||||
[ext_resource type="PackedScene" uid="uid://b6r787sik5yil" path="res://core/photo_mode/ui/photo_gallery.tscn" id="7_tb1ii"]
|
||||
|
||||
[sub_resource type="Environment" id="Environment_48mla"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_hh1ka"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_ynvi2"]
|
||||
size = Vector3(1.9942131, 0.09710693, 1.984024)
|
||||
|
||||
[sub_resource type="Resource" id="Resource_ynvi2"]
|
||||
script = ExtResource("5_crfij")
|
||||
id = &"gatto"
|
||||
title = "Gatto"
|
||||
image = ExtResource("4_00joj")
|
||||
metadata/_custom_type_script = "uid://bj34o0org55ei"
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_hh1ka"]
|
||||
|
||||
[node name="GymPhotoMode" type="Node3D" unique_id=1314600330]
|
||||
script = ExtResource("1_cl1h5")
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=213183287]
|
||||
environment = SubResource("Environment_48mla")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1274975837]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.17952333, 0.98375374, 0, -0.98375374, 0.17952333, 0, 18.920979, 0)
|
||||
|
||||
[node name="Floor" type="MeshInstance3D" parent="." unique_id=958865480]
|
||||
transform = Transform3D(20, 0, 0, 0, 20, 0, 0, 0, 20, 0, -0.83473957, 0)
|
||||
mesh = SubResource("PlaneMesh_hh1ka")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="Floor" unique_id=2096983240]
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor/StaticBody3D" unique_id=188185045]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0036563873, -0.009703338, -0.00868988)
|
||||
shape = SubResource("BoxShape3D_ynvi2")
|
||||
|
||||
[node name="PhotoModeController" parent="." unique_id=695158870 node_paths=PackedStringArray("rotation_target") instance=ExtResource("2_q5kgc")]
|
||||
transform = Transform3D(1, 0, 0, 0, 0.49999994, 0.8660254, 0, -0.8660254, 0.49999994, 0, 30, 20)
|
||||
movement_bounds = AABB(-5, -5, -5, 10, 10, 10)
|
||||
rotation_target = NodePath("../Node3D")
|
||||
|
||||
[node name="Node3D" type="Node3D" parent="." unique_id=570786250]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 10, 0)
|
||||
|
||||
[node name="Node3D2" type="Node3D" parent="." unique_id=15037296]
|
||||
|
||||
[node name="Collectible" parent="Node3D2" unique_id=1229019813 instance=ExtResource("3_734hf")]
|
||||
collectible_data = SubResource("Resource_ynvi2")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="Node3D2" unique_id=553040412]
|
||||
mesh = SubResource("BoxMesh_hh1ka")
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=1802496396]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="ButtonGallery" type="Button" parent="Control" unique_id=539195532]
|
||||
layout_mode = 0
|
||||
offset_left = 50.0
|
||||
offset_top = 50.0
|
||||
offset_right = 163.0
|
||||
offset_bottom = 81.0
|
||||
text = "Menu"
|
||||
|
||||
[node name="Gallery" type="HSplitContainer" parent="Control" unique_id=1388833682]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_left = 420.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="CollectibleGallery" parent="Control/Gallery" unique_id=354419843 instance=ExtResource("6_6aab5")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="PhotoGallery" parent="Control/Gallery" unique_id=263414560 instance=ExtResource("7_tb1ii")]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control" unique_id=2015953740]
|
||||
layout_mode = 0
|
||||
offset_left = 50.0
|
||||
offset_top = 150.0
|
||||
offset_right = 400.0
|
||||
offset_bottom = 927.0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Control/PanelContainer" unique_id=1474258594]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Control/PanelContainer/ScrollContainer" unique_id=1982569320]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
text = "System Logic:
|
||||
- The system allows players to toggle a free camera mode to photograph and collect museum items.
|
||||
- Game Pause: Activating the mode pauses the SceneTree, freezing the world while allowing the camera to remain functional.
|
||||
- Taking a photo saves the captured image to disk and checks which collectibles are visible and unobstructed before unlocking them.
|
||||
- CollectionManager acts as a global singleton that tracks unlocked collectibles, saved photos, and the data used by the UI.
|
||||
|
||||
Photo Mode Actions:
|
||||
- Toggle Mode(P): Switches between normal gameplay and the photo camera, capturing or releasing the mouse, and toggles the global pause state.
|
||||
- Rotate(Mouse): The camera orbits around the configured target while photo mode is active.
|
||||
- Pan(Input Actions): The camera can be moved horizontally and vertically within the configured bounds.
|
||||
- Capture(F): Saves the current frame and performs frustum and raycast checks against collectibles in view.
|
||||
|
||||
Core Components:
|
||||
- PhotoModeController: Manages camera inputs, movement logic, and the photo-taking process.
|
||||
- Collectible: An Area3D node placed on objects to make them identifiable by the camera.
|
||||
- CollectionManager: Handles the logic for unlocking items and provides data to the UI.
|
||||
- CollectibleGallery: Displays all collectibles and visually highlights the unlocked ones.
|
||||
- PhotoGallery: Displays the photos saved by the player during the session.
|
||||
|
||||
Parameters:
|
||||
- Pan & Rotation Speed: Defines how fast the camera moves and rotates.
|
||||
- Movement Bounds: An AABB that restricts the camera's panning area.
|
||||
- Collectible Data: Resource files containing the ID, title, and image for each item.
|
||||
- Library: A central list of all CollectibleResources registered in the game."
|
||||
autowrap_mode = 2
|
||||
|
||||
[connection signal="pressed" from="Control/ButtonGallery" to="." method="_on_button_gallery_pressed"]
|
||||
35
docs/gyms/radio/gym_radio.gd
Normal file
35
docs/gyms/radio/gym_radio.gd
Normal file
@@ -0,0 +1,35 @@
|
||||
extends Node3D
|
||||
|
||||
@onready var radio: Radio = $%Radio
|
||||
@onready var button_pause_resume: Button = $%Button_Pause_Resume
|
||||
@onready var settings_menu: SettingsMenu = $%SettingsMenu
|
||||
|
||||
func _on_button_play_pressed() -> void:
|
||||
if !radio.playing:
|
||||
radio.play_track()
|
||||
|
||||
|
||||
func _on_button_pause_pressed() -> void:
|
||||
radio.toggle_pause()
|
||||
if !button_pause_resume:
|
||||
button_pause_resume = $%Button_Pause_Resume
|
||||
if radio.stream_paused:
|
||||
button_pause_resume.text = "Resume"
|
||||
else:
|
||||
button_pause_resume.text = "Pause"
|
||||
|
||||
|
||||
func _on_button_stop_pressed() -> void:
|
||||
radio.stop_radio()
|
||||
|
||||
|
||||
func _on_button_next_pressed() -> void:
|
||||
radio.next_track()
|
||||
|
||||
|
||||
func _on_button_previous_pressed() -> void:
|
||||
radio.prev_track()
|
||||
|
||||
|
||||
func _on_button_settings_menu_pressed() -> void:
|
||||
settings_menu.visible = !settings_menu.visible
|
||||
1
docs/gyms/radio/gym_radio.gd.uid
Normal file
1
docs/gyms/radio/gym_radio.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ew4b78u5tkiu
|
||||
104
docs/gyms/radio/gym_radio.tscn
Normal file
104
docs/gyms/radio/gym_radio.tscn
Normal file
@@ -0,0 +1,104 @@
|
||||
[gd_scene format=3 uid="uid://bdkdhn1oallke"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cpeyt1dgrtglc" path="res://core/radio/radio.tscn" id="1_8yomj"]
|
||||
[ext_resource type="Script" uid="uid://ew4b78u5tkiu" path="res://docs/gyms/radio/gym_radio.gd" id="1_h5r8c"]
|
||||
[ext_resource type="AudioStream" uid="uid://70cc8she43re" path="res://docs/gyms/radio/lofi_01.ogg" id="3_ltpvc"]
|
||||
[ext_resource type="PackedScene" uid="uid://caqf471x0kttc" path="res://core/audio/settings/settings_menu.tscn" id="4_8pw2j"]
|
||||
|
||||
[node name="GymRadio" type="Node3D" unique_id=204859062]
|
||||
script = ExtResource("1_h5r8c")
|
||||
|
||||
[node name="Radio" parent="." unique_id=1234112225 instance=ExtResource("1_8yomj")]
|
||||
unique_name_in_owner = true
|
||||
playlist = Array[AudioStream]([ExtResource("3_ltpvc")])
|
||||
|
||||
[node name="Control" type="Control" parent="." unique_id=1232082176]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="SettingsMenu" parent="Control" unique_id=1639777294 instance=ExtResource("4_8pw2j")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
|
||||
[node name="VBoxContainer2" type="VBoxContainer" parent="Control" unique_id=2092627240]
|
||||
layout_mode = 1
|
||||
anchors_preset = 9
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 229.0
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Control/VBoxContainer2" unique_id=2097365775]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Button_Play" type="Button" parent="Control/VBoxContainer2/VBoxContainer" unique_id=1422696340]
|
||||
layout_mode = 2
|
||||
text = "Play"
|
||||
|
||||
[node name="Button_Pause_Resume" type="Button" parent="Control/VBoxContainer2/VBoxContainer" unique_id=2016690081]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Pause"
|
||||
|
||||
[node name="Button_Stop" type="Button" parent="Control/VBoxContainer2/VBoxContainer" unique_id=61861870]
|
||||
layout_mode = 2
|
||||
text = "Stop"
|
||||
|
||||
[node name="Button_Next" type="Button" parent="Control/VBoxContainer2/VBoxContainer" unique_id=957606385]
|
||||
layout_mode = 2
|
||||
text = "Next"
|
||||
|
||||
[node name="Button_Previous" type="Button" parent="Control/VBoxContainer2/VBoxContainer" unique_id=929072518]
|
||||
layout_mode = 2
|
||||
text = "Previous"
|
||||
|
||||
[node name="Button_SettingsMenu" type="Button" parent="Control/VBoxContainer2/VBoxContainer" unique_id=431867154]
|
||||
layout_mode = 2
|
||||
text = "SettingsMenu"
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="Control/VBoxContainer2" unique_id=1558442050]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Control/VBoxContainer2/PanelContainer" unique_id=7789304]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Control/VBoxContainer2/PanelContainer/ScrollContainer" unique_id=2043293564]
|
||||
custom_minimum_size = Vector2(1, 1)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
text = "System Logic:
|
||||
- The system is an extension of AudioStreamPlayer designed to manage sequential audio playback.
|
||||
- It automatically triggers the next track in the sequence when the current one finishes via the finished signal.
|
||||
|
||||
Core Functionality:
|
||||
- Playlist Management: Stores a list of AudioStream resources and tracks the current song index.
|
||||
- Track Navigation: Allows cycling forward and backward through the playlist with index wrapping (loops back to start/end).
|
||||
- Playback Control: Supports jumping to specific tracks, toggling the pause state, and stopping the stream.
|
||||
- Audio Settings: If the Music bus exists, the Settings menu can be used to test and adjust playback volume.
|
||||
|
||||
Key Methods:
|
||||
- play_track: Loads a specific stream from the playlist and begins playback.
|
||||
- next_track / prev_track: Increments or decrements the index to navigate the playlist.
|
||||
- toggle_pause: Resumes or pauses the current stream without resetting its position.
|
||||
|
||||
Adjustable Parameters:
|
||||
- Playlist: An Array in the inspector where you can assign one or more AudioStream resources."
|
||||
autowrap_mode = 2
|
||||
|
||||
[connection signal="pressed" from="Control/VBoxContainer2/VBoxContainer/Button_Play" to="." method="_on_button_play_pressed"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer2/VBoxContainer/Button_Pause_Resume" to="." method="_on_button_pause_pressed"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer2/VBoxContainer/Button_Stop" to="." method="_on_button_stop_pressed"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer2/VBoxContainer/Button_Next" to="." method="_on_button_next_pressed"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer2/VBoxContainer/Button_Previous" to="." method="_on_button_previous_pressed"]
|
||||
[connection signal="pressed" from="Control/VBoxContainer2/VBoxContainer/Button_SettingsMenu" to="." method="_on_button_settings_menu_pressed"]
|
||||
BIN
docs/gyms/radio/lofi_01.ogg
Normal file
BIN
docs/gyms/radio/lofi_01.ogg
Normal file
Binary file not shown.
19
docs/gyms/radio/lofi_01.ogg.import
Normal file
19
docs/gyms/radio/lofi_01.ogg.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="oggvorbisstr"
|
||||
type="AudioStreamOggVorbis"
|
||||
uid="uid://70cc8she43re"
|
||||
path="res://.godot/imported/lofi_01.ogg-0aacd597266806080412021811923091.oggvorbisstr"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://docs/gyms/radio/lofi_01.ogg"
|
||||
dest_files=["res://.godot/imported/lofi_01.ogg-0aacd597266806080412021811923091.oggvorbisstr"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -12,7 +12,7 @@
|
||||
[ext_resource type="PackedScene" uid="uid://cjv1e8pc6gde1" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_01.tscn" id="8_nurqm"]
|
||||
[ext_resource type="PackedScene" uid="uid://cu2chsjh8wuvp" path="res://tgcc/chunk/countryside/scene/chunk_country_straight_02.tscn" id="9_51cxd"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqoai3665vb0a" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_02.tscn" id="9_q6kbb"]
|
||||
[ext_resource type="PackedScene" uid="uid://c73yk6858dmwn" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_4_01.tscn" id="10_ufarv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cjv1e8pc6gde1" path="res://tgcc/chunk/countryside/scene/chunk_country_corner_01.tscn" id="10_ufarv"]
|
||||
[ext_resource type="PackedScene" uid="uid://cv5xmnow451kl" path="res://core/camera.tscn" id="11_o1bk6"]
|
||||
[ext_resource type="Script" uid="uid://dboerd4a6dwj7" path="res://core/biome_generator/rails.gd" id="12_4is5r"]
|
||||
[ext_resource type="PackedScene" uid="uid://qmt8bkiksgj3" path="res://tgcc/chunk/countryside/scene/chunk_country_cross_3_02.tscn" id="12_81wux"]
|
||||
@@ -28,8 +28,10 @@
|
||||
[ext_resource type="AudioStream" uid="uid://creenugno7hm" path="res://core/daynight/sounds/thunder_4.mp3" id="18_lfsx4"]
|
||||
[ext_resource type="PackedScene" uid="uid://pxmcy0lhne5d" path="res://tgcc/chunk/countryside/scene/chunk_country_straight_03.tscn" id="19_ne4de"]
|
||||
[ext_resource type="AudioStream" uid="uid://bm6dq4jwsbxf6" path="res://core/daynight/sounds/thunder_5.mp3" id="19_niwdr"]
|
||||
[ext_resource type="PackedScene" uid="uid://bs3dkwcc8w2uk" path="res://tgcc/chunk/river/scene/chunk_r_l_1.tscn" id="20_q6kbb"]
|
||||
[ext_resource type="AudioStream" uid="uid://byuxpukhy72n8" path="res://core/daynight/sounds/rain_1.mp3" id="20_quqod"]
|
||||
[ext_resource type="PackedScene" uid="uid://1c1ion0qnho4" path="res://tgcc/map/map_1/map_1.tscn" id="20_xkcqp"]
|
||||
[ext_resource type="PackedScene" uid="uid://btipd6wev016d" path="res://tgcc/chunk/river/scene/chunk_r_r_1.tscn" id="21_81wux"]
|
||||
[ext_resource type="AudioStream" uid="uid://h5yhjn1x3f4j" path="res://core/daynight/sounds/rain_2.mp3" id="21_appab"]
|
||||
[ext_resource type="AudioStream" uid="uid://elrjw0smm0cj" path="res://core/daynight/sounds/rain_3.mp3" id="22_yime3"]
|
||||
[ext_resource type="Script" uid="uid://cx2tlvxhvatj5" path="res://docs/museums/daynight/control.gd" id="23_ou3jn"]
|
||||
@@ -112,7 +114,7 @@ compositor_effects = Array[CompositorEffect]([SubResource("CompositorEffect_q52t
|
||||
[sub_resource type="Resource" id="Resource_3qrd0"]
|
||||
script = ExtResource("6_s3jnv")
|
||||
name = "countryside"
|
||||
available_chunks = Array[PackedScene]([ExtResource("7_xgfli"), ExtResource("8_nurqm"), ExtResource("9_q6kbb"), ExtResource("7_4elh6"), ExtResource("8_hvd8d"), ExtResource("12_81wux"), ExtResource("13_1ugwu"), ExtResource("10_ufarv"), ExtResource("15_ky1rt"), ExtResource("16_5g563"), ExtResource("17_tbmwr"), ExtResource("9_51cxd"), ExtResource("19_ne4de")])
|
||||
available_chunks = Array[PackedScene]([ExtResource("7_xgfli"), ExtResource("8_nurqm"), ExtResource("9_q6kbb"), ExtResource("7_4elh6"), ExtResource("8_hvd8d"), ExtResource("12_81wux"), ExtResource("13_1ugwu"), ExtResource("10_ufarv"), ExtResource("15_ky1rt"), ExtResource("16_5g563"), ExtResource("17_tbmwr"), ExtResource("9_51cxd"), ExtResource("19_ne4de"), ExtResource("20_q6kbb"), ExtResource("21_81wux")])
|
||||
metadata/_custom_type_script = "uid://wv6kcqkibium"
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pypsn"]
|
||||
@@ -386,7 +388,7 @@ theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_hover_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
|
||||
text = "Random Weather (10\")"
|
||||
text = "Random Weather"
|
||||
|
||||
[node name="WeatherEventLabel" type="Label" parent="Control" unique_id=641424797]
|
||||
layout_mode = 0
|
||||
@@ -412,6 +414,20 @@ theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
|
||||
text = "Fog"
|
||||
|
||||
[node name="UpdateRails" type="Button" parent="Control" unique_id=267134156]
|
||||
layout_mode = 0
|
||||
offset_left = 12.0
|
||||
offset_top = 351.0
|
||||
offset_right = 195.0
|
||||
offset_bottom = 382.0
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_focus_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_pressed_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_hover_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_hover_pressed_color = Color(1, 1, 1, 1)
|
||||
theme_override_colors/font_outline_color = Color(1, 1, 1, 1)
|
||||
text = "Update Rails"
|
||||
|
||||
[connection signal="toggled" from="Control/Snow" to="Control" method="_on_snow_toggled"]
|
||||
[connection signal="toggled" from="Control/Rain" to="Control" method="_on_rain_toggled"]
|
||||
[connection signal="toggled" from="Control/Wind" to="Control" method="_on_wind_toggled"]
|
||||
@@ -426,3 +442,4 @@ text = "Fog"
|
||||
[connection signal="toggled" from="Control/Shadows" to="Control" method="_on_shadows_toggled"]
|
||||
[connection signal="pressed" from="Control/RandomWeather" to="Control" method="_on_random_weather_pressed"]
|
||||
[connection signal="toggled" from="Control/Fog" to="Control" method="_on_fog_toggled"]
|
||||
[connection signal="pressed" from="Control/UpdateRails" to="Control" method="_on_update_rails_pressed"]
|
||||
|
||||
@@ -7,6 +7,8 @@ extends Control
|
||||
@onready var wind_slider: HSlider = $WindSlider
|
||||
@onready var day_time_option: OptionButton = $DayTimeOptions
|
||||
|
||||
var default_random_event_duration: float = 10.0
|
||||
|
||||
func _ready() -> void:
|
||||
UIEvents.day_time_changed.connect(_on_day_time_changed)
|
||||
UIEvents.day_time_option_changed.connect(_on_day_time_option_changed)
|
||||
@@ -29,7 +31,10 @@ func _on_wind_slider_value_changed(value: float) -> void:
|
||||
UIEvents.wind_change.emit(value)
|
||||
|
||||
func _on_random_weather_pressed() -> void:
|
||||
UIEvents.trigger_random_weather.emit(10.0)
|
||||
var duration: float = default_random_event_duration
|
||||
if day_night != null and day_night.environment_config != null:
|
||||
duration = day_night.environment_config.random_event_duration
|
||||
UIEvents.trigger_random_weather.emit(duration)
|
||||
|
||||
func _on_fireflies_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_fireflies.emit(toggled_on)
|
||||
@@ -99,3 +104,6 @@ func _on_option_button_item_selected(index: int) -> void:
|
||||
|
||||
func _on_fog_toggled(toggled_on: bool) -> void:
|
||||
UIEvents.toggle_fog.emit(toggled_on)
|
||||
|
||||
func _on_update_rails_pressed() -> void:
|
||||
UIEvents.update_rail_chunks.emit()
|
||||
|
||||
@@ -19,6 +19,9 @@ config/icon="uid://bfar1kk3pgq8f"
|
||||
[autoload]
|
||||
|
||||
UIEvents="*uid://dehu28iq27mbn"
|
||||
GameState="*uid://b17g2w2g101o6"
|
||||
CollectionManager="*uid://c3kq1qddpm8tf"
|
||||
AudioManager="*uid://dcttbbavtwtsg"
|
||||
|
||||
[display]
|
||||
|
||||
@@ -34,6 +37,39 @@ weather_vegetables_node=""
|
||||
wind_node="Materials to apply wind"
|
||||
weather_node=""
|
||||
|
||||
[input]
|
||||
|
||||
photo_pan_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":65,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
photo_pan_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
photo_pan_up={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
photo_pan_down={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
take_photo={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":70,"key_label":0,"unicode":102,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
toggle_photo_mode={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":112,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[physics]
|
||||
|
||||
3d/physics_engine="Jolt Physics"
|
||||
|
||||
@@ -70,54 +70,54 @@ est = true
|
||||
south = true
|
||||
west = true
|
||||
|
||||
[node name="Cavi_003" parent="." index="0" unique_id=1683040552]
|
||||
[node name="Cavi_003" parent="." index="0" unique_id=1536880121]
|
||||
surface_material_override/0 = ExtResource("2_k6fna")
|
||||
surface_material_override/1 = ExtResource("2_k6fna")
|
||||
|
||||
[node name="Chunk_008" parent="." index="1" unique_id=978229734]
|
||||
[node name="Chunk_008" parent="." index="1" unique_id=2026223215]
|
||||
surface_material_override/0 = ExtResource("3_0aavg")
|
||||
|
||||
[node name="Chunk_015" parent="." index="2" unique_id=916064359 groups=["weather_node"]]
|
||||
[node name="Chunk_015" parent="." index="2" unique_id=983339955 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("4_642yp")
|
||||
|
||||
[node name="Flower_016" parent="." index="3" unique_id=1070776780]
|
||||
[node name="Flower_016" parent="." index="3" unique_id=2061052125]
|
||||
visible = false
|
||||
|
||||
[node name="FlowerG_015" parent="." index="4" unique_id=824525481]
|
||||
[node name="FlowerG_015" parent="." index="4" unique_id=1164829892]
|
||||
visible = false
|
||||
|
||||
[node name="House_C_1_004" parent="." index="5" unique_id=518805396 groups=["weather_node"]]
|
||||
[node name="House_C_1_004" parent="." index="5" unique_id=1513162211 groups=["weather_node"]]
|
||||
|
||||
[node name="House_C_1_004|Cube_023|Dupli|" parent="House_C_1_004" index="0" unique_id=2033854223]
|
||||
[node name="House_C_1_004|Cube_023|Dupli|" parent="House_C_1_004" index="0" unique_id=2055325984]
|
||||
surface_material_override/0 = ExtResource("5_wbwk3")
|
||||
surface_material_override/1 = ExtResource("6_b82gs")
|
||||
|
||||
[node name="House_C_1_005" parent="." index="6" unique_id=68402630 groups=["weather_node"]]
|
||||
[node name="House_C_1_005" parent="." index="6" unique_id=1325920285 groups=["weather_node"]]
|
||||
|
||||
[node name="House_C_1_005|Cube_023|Dupli|" parent="House_C_1_005" index="0" unique_id=1370013707]
|
||||
[node name="House_C_1_005|Cube_023|Dupli|" parent="House_C_1_005" index="0" unique_id=803929754]
|
||||
surface_material_override/0 = ExtResource("5_wbwk3")
|
||||
surface_material_override/1 = ExtResource("6_b82gs")
|
||||
|
||||
[node name="House_C_1_006" parent="." index="7" unique_id=1206949995 groups=["weather_node"]]
|
||||
[node name="House_C_1_006" parent="." index="7" unique_id=2001122787 groups=["weather_node"]]
|
||||
|
||||
[node name="House_C_1_006|Cube_023|Dupli|" parent="House_C_1_006" index="0" unique_id=2100645541]
|
||||
[node name="House_C_1_006|Cube_023|Dupli|" parent="House_C_1_006" index="0" unique_id=1405616088]
|
||||
surface_material_override/0 = ExtResource("5_wbwk3")
|
||||
surface_material_override/1 = ExtResource("6_b82gs")
|
||||
|
||||
[node name="House_C_1_007" parent="." index="8" unique_id=746675923 groups=["weather_node"]]
|
||||
[node name="House_C_1_007" parent="." index="8" unique_id=464621197 groups=["weather_node"]]
|
||||
|
||||
[node name="House_C_1_007|Cube_023|Dupli|" parent="House_C_1_007" index="0" unique_id=869496471]
|
||||
[node name="House_C_1_007|Cube_023|Dupli|" parent="House_C_1_007" index="0" unique_id=1780113381]
|
||||
surface_material_override/0 = ExtResource("5_wbwk3")
|
||||
surface_material_override/1 = ExtResource("6_b82gs")
|
||||
|
||||
[node name="Lanterne_004" parent="." index="9" unique_id=1013830129]
|
||||
[node name="Lanterne_004" parent="." index="9" unique_id=993819881]
|
||||
surface_material_override/0 = ExtResource("6_b82gs")
|
||||
surface_material_override/1 = ExtResource("5_wbwk3")
|
||||
|
||||
[node name="MSH_Staccioanta_1_017" parent="." index="10" unique_id=1757093874]
|
||||
[node name="MSH_Staccioanta_1_017" parent="." index="10" unique_id=845283196 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("7_be1u8")
|
||||
|
||||
[node name="PaliLuci_001" parent="." index="11" unique_id=239883314]
|
||||
[node name="PaliLuci_001" parent="." index="11" unique_id=1390758113]
|
||||
surface_material_override/0 = ExtResource("8_vvemo")
|
||||
surface_material_override/1 = ExtResource("8_vvemo")
|
||||
|
||||
|
||||
@@ -165,54 +165,54 @@ have_lamppost = true
|
||||
connection_left = [NodePath("PaloLuce/sx")]
|
||||
connection_right = [NodePath("PaloLuce/dx")]
|
||||
|
||||
[node name="Argini_005" parent="." index="0" unique_id=1699913806]
|
||||
[node name="Argini_005" parent="." index="0" unique_id=255857931]
|
||||
surface_material_override/0 = ExtResource("2_t65ww")
|
||||
|
||||
[node name="Bags" parent="." index="1" unique_id=885374680]
|
||||
[node name="Bags" parent="." index="1" unique_id=2117673123]
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_q2s76")
|
||||
|
||||
[node name="Cart" parent="." index="2" unique_id=1431553734]
|
||||
[node name="Cart" parent="." index="2" unique_id=884973125 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("11_iulsg")
|
||||
surface_material_override/1 = SubResource("ShaderMaterial_mqw0y")
|
||||
surface_material_override/2 = SubResource("ShaderMaterial_dxwao")
|
||||
|
||||
[node name="Chunk_045" parent="." index="3" unique_id=905054485 groups=["weather_node"]]
|
||||
[node name="Chunk_045" parent="." index="3" unique_id=121750865 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("4_eev23")
|
||||
|
||||
[node name="Cortile" parent="." index="4" unique_id=1916980077 groups=["weather_node"]]
|
||||
[node name="Cortile" parent="." index="4" unique_id=91819151 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("4_eev23")
|
||||
|
||||
[node name="Flower_002" parent="." index="5" unique_id=879662150 groups=["weather_vegetables_node", "wind_node"]]
|
||||
[node name="Flower_002" parent="." index="5" unique_id=833640333 groups=["weather_vegetables_node", "wind_node"]]
|
||||
visible = false
|
||||
|
||||
[node name="FlowerG_001" parent="." index="6" unique_id=506605481 groups=["weather_vegetables_node", "wind_node"]]
|
||||
[node name="FlowerG_001" parent="." index="6" unique_id=1651138709 groups=["weather_vegetables_node", "wind_node"]]
|
||||
visible = false
|
||||
|
||||
[node name="Grass_006" parent="." index="7" unique_id=921275290 groups=["weather_vegetables_node", "wind_node"]]
|
||||
[node name="Grass_006" parent="." index="7" unique_id=2081004392 groups=["weather_vegetables_node", "wind_node"]]
|
||||
surface_material_override/0 = ExtResource("2_t65ww")
|
||||
|
||||
[node name="House_L_2" parent="." index="8" unique_id=1330804574 groups=["weather_node"]]
|
||||
[node name="House_L_2" parent="." index="8" unique_id=1993375668 groups=["weather_node"]]
|
||||
|
||||
[node name="House_L_2|Cube_349|Dupli|" parent="House_L_2" index="0" unique_id=1823344237]
|
||||
[node name="House_L_2|Cube_349|Dupli|" parent="House_L_2" index="0" unique_id=18124515]
|
||||
surface_material_override/0 = ExtResource("5_0oa1i")
|
||||
surface_material_override/1 = ExtResource("7_q2s76")
|
||||
|
||||
[node name="MSH_Staccioanta_1_003" parent="." index="9" unique_id=1980961732]
|
||||
[node name="MSH_Staccioanta_1_003" parent="." index="9" unique_id=568627289]
|
||||
surface_material_override/0 = ExtResource("7_apgpv")
|
||||
|
||||
[node name="Rocks_001" parent="." index="10" unique_id=375547626 groups=["weather_node"]]
|
||||
[node name="Rocks_001" parent="." index="10" unique_id=2004921299 groups=["weather_node"]]
|
||||
surface_material_override/0 = ExtResource("5_sy58u")
|
||||
surface_material_override/1 = ExtResource("5_sy58u")
|
||||
surface_material_override/2 = ExtResource("6_eev23")
|
||||
|
||||
[node name="Statue" parent="." index="11" unique_id=1169373891]
|
||||
[node name="Statue" parent="." index="11" unique_id=1814801509]
|
||||
surface_material_override/0 = ExtResource("5_sy58u")
|
||||
surface_material_override/1 = ExtResource("7_q2s76")
|
||||
|
||||
[node name="Water_006" parent="." index="12" unique_id=2064105008]
|
||||
[node name="Water_006" parent="." index="12" unique_id=1352334701]
|
||||
surface_material_override/0 = ExtResource("10_r4bww")
|
||||
|
||||
[node name="WoodPile" parent="." index="13" unique_id=1512653267]
|
||||
[node name="WoodPile" parent="." index="13" unique_id=1088104699]
|
||||
surface_material_override/0 = ExtResource("11_iulsg")
|
||||
surface_material_override/1 = ExtResource("12_ytk0o")
|
||||
surface_material_override/2 = SubResource("ShaderMaterial_ytk0o")
|
||||
|
||||
712
tgcc/chunk/countryside/scene/chunk_test_river_02.tscn
Normal file
712
tgcc/chunk/countryside/scene/chunk_test_river_02.tscn
Normal file
File diff suppressed because one or more lines are too long
@@ -123,6 +123,7 @@ buffer = PackedFloat32Array(0.09478149, -0.4699982, -0.8787032, -19.27537, -0.99
|
||||
|
||||
[node name="chunk_railway_station_hero" unique_id=1050909298 node_paths=PackedStringArray("connection_left", "connection_right") instance=ExtResource("1_c8ljj")]
|
||||
script = ExtResource("9_5ow1i")
|
||||
chunk_type = 1
|
||||
have_lamppost = true
|
||||
connection_left = [NodePath("PaloLuce3/sx"), NodePath("PaloLuce2/sx"), NodePath("PaloLuce/sx")]
|
||||
connection_right = [NodePath("PaloLuce/dx"), NodePath("PaloLuce2/dx"), NodePath("PaloLuce3/dx")]
|
||||
|
||||
@@ -39,6 +39,7 @@ size = Vector3(20, 10, 20)
|
||||
|
||||
[node name="chunk_railway_straight_2" unique_id=476549215 instance=ExtResource("1_g8fwq")]
|
||||
script = ExtResource("2_5gtba")
|
||||
chunk_type = 1
|
||||
est = true
|
||||
|
||||
[node name="Chunk_014" parent="." index="0" unique_id=1534185754]
|
||||
|
||||
@@ -66,6 +66,7 @@ size = Vector3(20, 10, 20)
|
||||
|
||||
[node name="chunk_railway_straight_bridge" unique_id=1049036234 node_paths=PackedStringArray("connection_left", "connection_right") instance=ExtResource("1_bwiif")]
|
||||
script = ExtResource("1_uoylj")
|
||||
chunk_type = 1
|
||||
est = true
|
||||
west = true
|
||||
have_lamppost = true
|
||||
|
||||
BIN
tgcc/chunk/river/mesh/Chunk_R_L_1.fbx
Normal file
BIN
tgcc/chunk/river/mesh/Chunk_R_L_1.fbx
Normal file
Binary file not shown.
44
tgcc/chunk/river/mesh/Chunk_R_L_1.fbx.import
Normal file
44
tgcc/chunk/river/mesh/Chunk_R_L_1.fbx.import
Normal file
@@ -0,0 +1,44 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://d0rca3oo1k30n"
|
||||
path="res://.godot/imported/Chunk_R_L_1.fbx-f315be000da513deddf8c1537ffe1a0f.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://tgcc/chunk/river/mesh/Chunk_R_L_1.fbx"
|
||||
dest_files=["res://.godot/imported/Chunk_R_L_1.fbx-f315be000da513deddf8c1537ffe1a0f.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/root_script=null
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_name_suffixes=true
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=true
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
materials/extract=0
|
||||
materials/extract_format=0
|
||||
materials/extract_path=""
|
||||
_subresources={}
|
||||
fbx/importer=0
|
||||
fbx/allow_geometry_helper_nodes=false
|
||||
fbx/embedded_image_handling=1
|
||||
fbx/naming_version=2
|
||||
BIN
tgcc/chunk/river/mesh/Chunk_R_R_1.fbx
Normal file
BIN
tgcc/chunk/river/mesh/Chunk_R_R_1.fbx
Normal file
Binary file not shown.
44
tgcc/chunk/river/mesh/Chunk_R_R_1.fbx.import
Normal file
44
tgcc/chunk/river/mesh/Chunk_R_R_1.fbx.import
Normal file
@@ -0,0 +1,44 @@
|
||||
[remap]
|
||||
|
||||
importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://bryeoru3tfbcq"
|
||||
path="res://.godot/imported/Chunk_R_R_1.fbx-3c3c617da890fc412ffcc0f1d56c3abe.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://tgcc/chunk/river/mesh/Chunk_R_R_1.fbx"
|
||||
dest_files=["res://.godot/imported/Chunk_R_R_1.fbx-3c3c617da890fc412ffcc0f1d56c3abe.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
nodes/root_type=""
|
||||
nodes/root_name=""
|
||||
nodes/root_script=null
|
||||
nodes/apply_root_scale=true
|
||||
nodes/root_scale=1.0
|
||||
nodes/import_as_skeleton_bones=false
|
||||
nodes/use_name_suffixes=true
|
||||
nodes/use_node_type_suffixes=true
|
||||
meshes/ensure_tangents=true
|
||||
meshes/generate_lods=true
|
||||
meshes/create_shadow_meshes=true
|
||||
meshes/light_baking=1
|
||||
meshes/lightmap_texel_size=0.2
|
||||
meshes/force_disable_compression=false
|
||||
skins/use_named_skins=true
|
||||
animation/import=true
|
||||
animation/fps=30
|
||||
animation/trimming=true
|
||||
animation/remove_immutable_tracks=true
|
||||
animation/import_rest_as_RESET=false
|
||||
import_script/path=""
|
||||
materials/extract=0
|
||||
materials/extract_format=0
|
||||
materials/extract_path=""
|
||||
_subresources={}
|
||||
fbx/importer=0
|
||||
fbx/allow_geometry_helper_nodes=false
|
||||
fbx/embedded_image_handling=1
|
||||
fbx/naming_version=2
|
||||
730
tgcc/chunk/river/scene/chunk_r_l_1.tscn
Normal file
730
tgcc/chunk/river/scene/chunk_r_l_1.tscn
Normal file
File diff suppressed because one or more lines are too long
829
tgcc/chunk/river/scene/chunk_r_r_1.tscn
Normal file
829
tgcc/chunk/river/scene/chunk_r_r_1.tscn
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user