76 Commits

Author SHA1 Message Date
c2d6429cbc clean up 2026-06-21 11:22:08 +02:00
d71b6a5be7 add blend time 2026-06-21 11:12:57 +02:00
ee6fe2ab89 update human models and animations 2026-06-21 11:11:01 +02:00
196a238f5c add new models and rig and handle multiple navigation region 2026-06-19 23:05:14 +02:00
5dd8f8092c update ui 2026-06-18 19:59:07 +00:00
5c807d7b69 add snow coverage to tea material 2026-06-07 18:01:47 +02:00
b602e3b521 remove test jpg 2026-06-06 18:36:12 +02:00
9579f26a63 improve snow 2026-06-06 18:35:50 +02:00
326d32c946 fix spawn! 2026-06-06 16:36:19 +02:00
d80aa93bb9 improve ui and bug fix 2026-06-06 14:19:27 +00:00
f049c538bd fix double spawn 2026-06-06 12:51:46 +02:00
2fa562d5d2 set entity properties for ai 2026-06-06 09:50:05 +02:00
f962bcef42 add entity spawn to hero for test 2026-06-06 09:36:14 +02:00
83fd257484 add groups 2026-06-06 09:06:43 +02:00
cd3a40287c Bug fixes and polishing
Co-authored-by: m.sonaglioni <m.sonaglioni@jmpgames.it>
Co-committed-by: m.sonaglioni <m.sonaglioni@jmpgames.it>
2026-06-05 13:46:28 +00:00
f97af73de6 add group to streets 2026-06-04 12:30:51 +02:00
0e02f31d6e add groups to chunks 2026-06-04 11:47:19 +02:00
ed82078628 fix lamppost wires 2026-06-04 11:01:24 +02:00
584579afb8 fix entity spawn for special scene + fix wagon movement 2026-06-03 19:26:12 +02:00
243f89d9d2 fix wind and make compatible wind_decoration 2026-06-03 10:59:46 +02:00
afbda265b6 fix railways 2026-06-02 15:52:02 +02:00
97a8ce3f9c fix debug errors and warnings 2026-06-02 10:33:18 +02:00
47a2bf5a2e Merge pull request 'manage color and exposure during rain e storm; remove wind from rice; disable fireflies on rain, snow or storm; remove key for fireworks test; add hero to railway_pool; manage train windows' (#28) from matt_req_fix into main
Reviewed-on: #28
2026-06-02 06:41:14 +00:00
fdfe2336f8 manage color and exposure during rain e storm; remove wind from rice; disable fireflies on rain, snow or storm; remove key for fireworks test; add hero to railway_pool; manage train windows 2026-06-02 08:39:46 +02:00
0c44b420d1 train selector lighting hotfix 2026-06-01 19:52:47 +02:00
dcf5d28248 refactoring UI 2026-06-01 09:03:31 +00:00
50ea1d8bbd update generator chunk
Co-authored-by: m.sonaglioni <m.sonaglioni@jmpgames.it>
Co-committed-by: m.sonaglioni <m.sonaglioni@jmpgames.it>
2026-06-01 08:59:09 +00:00
c08007c446 upd rails and add new train and wagon 2026-06-01 09:59:46 +02:00
eedd303faa Improve chunks, optimization, replace placeholder and more
Co-authored-by: f.fabbrizi <f.fabbrizi@jmpgames.it>
Co-committed-by: f.fabbrizi <f.fabbrizi@jmpgames.it>
2026-05-30 15:25:53 +00:00
55aea7bdc4 ai and game menu 2026-05-30 14:56:28 +00:00
6cb5104729 Merge pull request 'add wagons' (#24) from vagon into main
Reviewed-on: #24
2026-05-29 16:17:52 +00:00
7f7f9d6ae3 add wagons 2026-05-29 18:16:16 +02:00
05b01f70cc create main_scene 2026-05-26 09:34:08 +02:00
b059a2ef1d put constant for generation as parameters 2026-05-25 23:12:57 +02:00
d823cf4554 fix asset errors 2026-05-24 17:19:37 +02:00
Matteo Sonaglioni
e061eb7275 prop 2026-05-21 22:58:38 +02:00
64a9efcbc3 Merge pull request 'generate entities on biome' (#21) from spawn_entity into main
Reviewed-on: #21
2026-05-19 07:48:40 +00:00
ee8d6458ed generate entities on biome 2026-05-19 09:47:42 +02:00
fcab02469a add main menu and scene manager 2026-05-18 19:17:21 +00:00
0e56a84a95 add game menu 2026-05-15 20:33:21 +00:00
22877bffbe Merge pull request 'biome generation optimization' (#18) from generation_optimization into main
Reviewed-on: #18
2026-05-14 10:30:22 +00:00
b4a2bb6144 biome generation optimization 2026-05-14 12:29:41 +02:00
90b9739ee0 Merge branch 'main' of https://gitea.jmpgames.it/jmp-games/tgcc 2026-05-13 18:15:58 +02:00
43556ac110 add uniqueness par for props 2026-05-13 18:15:37 +02:00
7ea515c824 Merge branch 'polish3' into main 2026-05-13 15:50:14 +00:00
4658250206 fix 2026-05-13 17:05:29 +02:00
c25e3bb4f6 add uniqueness property to chunk and manage it on biome generator 2026-05-13 12:25:16 +02:00
Matteo Sonaglioni
c796ea289d well 2026-05-12 16:54:20 +02:00
Matteo Sonaglioni
a18dc64a4f prop1 2026-05-12 16:44:21 +02:00
c52b11388a add chunks
chunk river
hero chunk
2026-05-11 13:32:31 +00:00
ce8a977541 Merge pull request 'fix river water direction2' (#15) from river_direction into main
Reviewed-on: #15
2026-05-10 16:45:11 +00:00
8ceb6cb16b fix river water direction2 2026-05-10 18:44:43 +02:00
bcf854fd74 Merge branch 'main' of https://gitea.jmpgames.it/jmp-games/tgcc 2026-05-10 11:09:41 +02:00
10b437d236 add fog update based on day 2026-05-10 11:09:27 +02:00
9c41da14a6 Merge pull request 'fix_snow_rain_fog' (#14) from fix_snow_rain_fog into main
Reviewed-on: #14
2026-05-10 09:02:01 +00:00
2aa7d1f7d4 fix snow 2026-05-10 11:01:22 +02:00
040ded5f0b fix rain 2026-05-09 14:57:07 +02:00
ddec91d515 update cloud density when is rainy or snowy 2026-05-06 23:14:51 +02:00
d8efa735dd Merge pull request 'polish2' (#12) from polish2 into main
Reviewed-on: #12
2026-05-06 20:29:12 +00:00
Matteo Sonaglioni
9bc7f38d07 add river curve 2026-05-06 22:27:54 +02:00
Matteo Sonaglioni
f4c8775a45 add river chunk 2026-05-06 21:43:34 +02:00
70d3dfe15c add ai, photo_mode and radio 2026-05-05 20:33:00 +00:00
Matteo Sonaglioni
9827b98b3e river water shader 2026-05-05 18:45:16 +02:00
Matteo Sonaglioni
977e8012aa river chunk 2026-05-05 17:03:24 +02:00
72d06560b1 add groups to scenes 2026-05-05 00:04:02 +02:00
9d62d97422 Merge pull request 'biome_gen_river' (#10) from biome_gen_river into main
Reviewed-on: #10
2026-05-04 22:00:08 +00:00
c1e99a3b8e fix merge scenes 2026-05-04 23:59:27 +02:00
8e1ba915a2 add scenes 2026-05-04 23:43:22 +02:00
Matteo Sonaglioni
577b4570da add river chunk 2026-05-04 23:35:29 +02:00
36dff9c070 remove train radar 2026-05-04 10:09:20 +02:00
56591bb907 fix snow cap 2026-05-02 18:10:51 +02:00
9f254d9725 Merge pull request 'polish1' (#6) from polish1 into main
Reviewed-on: #6
2026-05-02 16:09:44 +00:00
abae8434fc add river bioma gen + label weather random 2026-04-30 23:23:49 +02:00
3c7cbdc662 Merge pull request 'biome_gen_overload' (#5) from biome_gen_overload into main
Reviewed-on: #5
2026-04-30 14:42:30 +00:00
8c7f1c3c82 fix stutter 2026-04-30 16:21:08 +02:00
b7308c5d66 fix fog 2026-04-30 12:20:12 +02:00
883 changed files with 79269 additions and 8626 deletions

13
.idea/.gitignore generated vendored Normal file
View 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
View 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
View 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
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

1097
addons/TweenFX/TweenFX.gd Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
uid://d2n10rw2dnx8o

View File

@@ -0,0 +1,43 @@
## Internal tracking system for TweenFX.
## [br][br]
## Manages active tweens per node, handles cleanup when nodes are freed,
## and provides stop/query methods. Not intended for direct use —
## access through [TweenFX] instead.
static var _active: Dictionary = {} # { node: { TweenFX.Animations.X: tween } }
static func track(node: CanvasItem, anim: TweenFX.Animations, tween: Tween) -> void:
if not _active.has(node):
_active[node] = {}
if not node.tree_exiting.is_connected(_on_node_exiting):
node.tree_exiting.connect(_on_node_exiting.bind(node), CONNECT_ONE_SHOT)
_active[node][anim] = tween
tween.finished.connect(_on_tween_finished.bind(node, anim), CONNECT_ONE_SHOT)
static func stop(node: CanvasItem, anim: TweenFX.Animations) -> void:
if not _active.has(node) or not _active[node].has(anim):
return
_active[node][anim].kill()
_active[node].erase(anim)
if _active[node].is_empty():
_active.erase(node)
static func stop_all(node: CanvasItem) -> void:
if not _active.has(node):
return
for tween in _active[node].values():
tween.kill()
_active.erase(node)
static func is_playing(node: CanvasItem, anim: TweenFX.Animations) -> bool:
return _active.has(node) and _active[node].has(anim)
static func _on_tween_finished(node: CanvasItem, anim: TweenFX.Animations) -> void:
if not _active.has(node):
return
_active[node].erase(anim)
if _active[node].is_empty():
_active.erase(node)
static func _on_node_exiting(node: CanvasItem) -> void:
_active.erase(node)

View File

@@ -0,0 +1 @@
uid://bc8i1qm1d8hrv

BIN
addons/TweenFX/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

View File

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://chf2ss61jydw3"
path="res://.godot/imported/icon.png-1df28cd6ae5654ad60ac96bf24b7c782.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/TweenFX/icon.png"
dest_files=["res://.godot/imported/icon.png-1df28cd6ae5654ad60ac96bf24b7c782.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -0,0 +1,7 @@
[plugin]
name="TweenFX"+
icon="res://addons/TweenFX/icon.png"
description= "A simple, juicy tween animation library for Godot"
author="EvilBunnyMan"
version="1.2"
script="plugin.gd"

10
addons/TweenFX/plugin.gd Normal file
View File

@@ -0,0 +1,10 @@
@tool
extends EditorPlugin
func _enable_plugin():
add_autoload_singleton("TweenFX", "res://addons/TweenFX/TweenFX.gd")
print("[TweenFX] Enabled")
func _disable_plugin():
remove_autoload_singleton("TweenFX")
print("[TweenFX] Disabled")

View File

@@ -0,0 +1 @@
uid://wu3r36bvv8u

View File

@@ -0,0 +1,75 @@
extends CharacterBody3D
class_name AIBase
@export_group("Settings")
@export var speed: float = 4.0
@export_flags_3d_navigation var navigation_layers: int = 1
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
@export var anim_player: AnimationPlayer
@export_group("Entities")
enum EntityType { HUMANOID, ANIMAL }
@export var entity_type: EntityType = EntityType.HUMANOID
@export var entity_name: String = ""
@export var allowed_biomes: Array[String] = []
@export_range(0.0, 100.0, 0.1) var spawn_uniqueness: float = 1.0
@onready var patrol_radius_shape: CollisionShape3D = $%PatrolRadiusShape
@onready var nav_agent: NavigationAgent3D = $%NavigationAgent3D
@onready var state_machine: StateMachine = $%StateMachine
func _ready() -> void:
randomize()
if nav_agent:
nav_agent.navigation_layers = navigation_layers
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
if velocity.length_squared() > 0.1:
var look_dir = Vector3(velocity.x, 0, velocity.z)
var target_transform = global_transform.looking_at(global_position - look_dir, Vector3.UP)
global_transform = global_transform.interpolate_with(target_transform, delta * 10.0)
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
for i in range(10):
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
if nav_agent.is_target_reachable():
return
# Fallback: if we can't find a reachable point (e.g. we drifted slightly off navmesh),
# try to navigate to the closest navmesh point to our CURRENT position to get unstuck.
nav_agent.target_position = NavigationServer3D.map_get_closest_point(nav_map_rid, global_position)

View File

@@ -0,0 +1 @@
uid://b30p1yqojbbbk

View File

@@ -0,0 +1,24 @@
[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"]
[sub_resource type="SphereShape3D" id="SphereShape3D_lim44"]
radius = 20.0
[node name="AiBase" type="CharacterBody3D" unique_id=1228675528]
script = ExtResource("1_4d1nn")
entity_name = "Humanoid"
[node name="NavigationAgent3D" type="NavigationAgent3D" parent="." unique_id=1370024449]
unique_name_in_owner = true
[node name="StateMachine" type="Node" parent="." unique_id=1286404264]
unique_name_in_owner = true
script = ExtResource("2_q1hg3")
[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)

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
[gd_scene format=3 uid="uid://duppccreftg3v"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_85o24"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_6mu8r"]
[ext_resource type="PackedScene" uid="uid://c5rccx22gs6jt" path="res://core/ai/agents/cat/Cat_rig.fbx" id="2_rohxe"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_0jm3k"]
[node name="AiCat" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_85o24")]
anim_player = NodePath("Cat_rig/AnimationPlayer")
entity_type = 1
entity_name = "Cat"
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=1884542620]
script = ExtResource("2_6mu8r")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "Cat_Idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1861645340]
script = ExtResource("3_0jm3k")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "Cat_Walk"
exit_on_action_finished = true
[node name="Cat_rig" parent="." index="3" unique_id=1332997618 instance=ExtResource("2_rohxe")]
[node name="Skeleton3D" parent="Cat_rig/Rig_Cat" parent_id_path=PackedInt32Array(1332997618, 1292226211) index="0" unique_id=807490174]
bones/1/position = Vector3(1.6719584e-08, 0.23547882, 0.34218493)
bones/1/rotation = Quaternion(0.12769094, -0.6954821, -0.12769029, 0.69548184)
bones/2/rotation = Quaternion(-1.5819447e-07, -1.9079575e-07, -0.5904159, 0.8070992)
bones/3/position = Vector3(0.21655759, -1.1490099e-06, 4.6904738e-08)
bones/3/rotation = Quaternion(4.4475364e-08, -1.16689236e-07, 0.042394996, 0.999101)
bones/4/rotation = Quaternion(4.694551e-09, 1.2888964e-07, 0.30337927, 0.9528699)
bones/7/rotation = Quaternion(9.573777e-09, -1.3302474e-07, -0.40028554, 0.9163905)
bones/9/rotation = Quaternion(0.0005057682, -0.00040186392, -0.7732871, 0.63405573)
bones/10/rotation = Quaternion(7.318899e-08, 1.07771655e-07, 0.23513123, 0.97196364)
bones/11/rotation = Quaternion(-0.013215952, -0.0063107302, 0.33804607, 0.9410156)
bones/13/rotation = Quaternion(-0.00018823319, 2.7849663e-05, -0.77314246, 0.6342325)
bones/14/rotation = Quaternion(7.324482e-08, 1.0779509e-07, 0.23506226, 0.9719804)
bones/15/rotation = Quaternion(0.01474526, 0.007664346, 0.33750835, 0.94117594)
bones/17/rotation = Quaternion(0.06574773, -0.012684476, 0.9796892, 0.18901183)
bones/18/rotation = Quaternion(-0.046865243, -0.04779876, -0.69851494, 0.7124576)
bones/19/position = Vector3(0.18072681, -0.041122876, -4.2319297e-08)
bones/19/rotation = Quaternion(-0.0051541063, -0.0666377, -0.080000654, 0.9945516)
bones/21/rotation = Quaternion(1.2657155e-07, 4.030732e-07, 0.96184576, -0.27359232)
bones/22/position = Vector3(0.0749221, -0.0072982265, -0.03856178)
bones/22/rotation = Quaternion(-8.139895e-08, 1.15607975e-07, -0.47071916, 0.88228315)
bones/23/position = Vector3(0.18089643, -0.000116025236, -0.011642921)
bones/23/rotation = Quaternion(2.998039e-07, -1.6746765e-07, 0.5290288, 0.84860384)
bones/26/position = Vector3(-0.03817617, 0.03956073, 0.04669925)
bones/26/rotation = Quaternion(-3.380398e-05, -0.00016875651, 0.9618461, -0.27359122)
bones/27/rotation = Quaternion(-8.140452e-08, 1.1560887e-07, -0.47071794, 0.8822838)
bones/28/position = Vector3(0.18089616, -0.000116375166, 0.011642809)
bones/28/rotation = Quaternion(4.5638826e-05, -8.8217595e-05, 0.5290293, 0.84860367)
[editable path="Cat_rig"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,25 @@
[gd_scene format=3 uid="uid://cxi6phs4fieli"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_tx3nx"]
[ext_resource type="PackedScene" uid="uid://dfdeepw5p5nb8" path="res://core/ai/agents/crow/Crow_rig.fbx" id="2_1pxwy"]
[ext_resource type="Script" uid="uid://da5vhmxbxkdbc" path="res://core/ai/framework/wait_train_state.gd" id="3_wait"]
[ext_resource type="Script" uid="uid://tys4fmqvneom" path="res://core/ai/framework/fly_away_state.gd" id="4_fly"]
[node name="AiCrow" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_tx3nx")]
anim_player = NodePath("Crow_rig/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("WaitTrainState")
[node name="WaitTrainState" type="Node" parent="StateMachine" index="0" unique_id=1000000000]
script = ExtResource("3_wait")
state_id = &"wait"
next_state_id = &"fly"
animation_name = "Idle_Crow"
[node name="FlyAwayState" type="Node" parent="StateMachine" index="1" unique_id=1000000001]
script = ExtResource("4_fly")
state_id = &"fly"
animation_name = "Fly_Crow"
[node name="Crow_rig" parent="." index="3" unique_id=2141026440 instance=ExtResource("2_1pxwy")]

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
[gd_scene format=3 uid="uid://bk45etvtdd6m5"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_m3efo"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_58gnd"]
[ext_resource type="PackedScene" uid="uid://4y4tffc723lg" path="res://core/ai/agents/fox/Fox_rig.fbx" id="2_xaafp"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_d1sp2"]
[ext_resource type="Script" uid="uid://b5y4u0itec8g1" path="res://core/ai/framework/run_state.gd" id="4_d1sp2"]
[node name="AiFox" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_m3efo")]
anim_player = NodePath("Fox_rig/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=933090954]
script = ExtResource("2_58gnd")
state_id = &"idle"
next_state_id = &"patrol"
random_next_state_ids = Array[StringName]([&"patrol", &"run"])
animation_name = "Idle_Fox"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=48187684]
script = ExtResource("3_d1sp2")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "Walk_Fox"
exit_on_action_finished = true
[node name="RunState" type="Node" parent="StateMachine" index="2" unique_id=30664919]
script = ExtResource("4_d1sp2")
state_id = &"run"
next_state_id = &"idle"
animation_name = "Run_Fox"
exit_on_action_finished = true
[node name="Fox_rig" parent="." index="3" unique_id=2044859181 instance=ExtResource("2_xaafp")]
[node name="Skeleton3D" parent="Fox_rig/Rig_Fox" parent_id_path=PackedInt32Array(2044859181, 1371677834) index="0" unique_id=625291101]
bones/1/position = Vector3(1.2443564e-08, 0.24551632, 0.408434)
bones/1/rotation = Quaternion(0.12769088, -0.6954821, -0.12769023, 0.69548184)
bones/2/rotation = Quaternion(-1.492881e-07, -1.7862074e-07, -0.5904159, 0.8070992)
bones/3/rotation = Quaternion(4.4853135e-08, 2.4038487e-09, 0.042394996, 0.999101)
bones/4/rotation = Quaternion(-3.9116873e-08, 1.0805254e-08, 0.30337915, 0.95286995)
bones/7/rotation = Quaternion(6.614782e-08, -2.2280902e-08, -0.4002855, 0.9163905)
bones/9/rotation = Quaternion(0.00050595123, -0.00040185585, -0.7732871, 0.63405573)
bones/10/rotation = Quaternion(4.4809266e-08, -6.81585e-09, 0.23513126, 0.97196364)
bones/11/rotation = Quaternion(-0.013216025, -0.0063106352, 0.33804604, 0.94101566)
bones/13/rotation = Quaternion(-0.00018805025, 2.7857828e-05, -0.77314246, 0.6342325)
bones/14/rotation = Quaternion(4.4874945e-08, -6.797017e-09, 0.23506236, 0.9719803)
bones/15/rotation = Quaternion(0.014745249, 0.00766435, 0.33750823, 0.9411759)
bones/17/rotation = Quaternion(0.06574762, -0.012684453, 0.9796892, 0.18901181)
bones/18/rotation = Quaternion(-0.0045532905, -0.06678549, -0.06784821, 0.99544746)
bones/19/rotation = Quaternion(-0.00312141, -0.06676418, -0.049661905, 0.99652725)
bones/21/rotation = Quaternion(-5.0142333e-08, 4.1612444e-07, 0.9618458, -0.27359205)
bones/22/rotation = Quaternion(-1.9314905e-08, 4.503425e-08, -0.47071874, 0.88228333)
bones/23/rotation = Quaternion(1.5250623e-07, -2.2114624e-07, 0.5290283, 0.84860426)
bones/26/rotation = Quaternion(-3.3980676e-05, -0.00016874354, 0.9618461, -0.27359122)
bones/27/rotation = Quaternion(-1.9324155e-08, 4.5031282e-08, -0.47071794, 0.8822838)
bones/28/rotation = Quaternion(4.549153e-05, -8.8271285e-05, 0.5290293, 0.84860367)
[editable path="Fox_rig"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,52 @@
[gd_scene format=3 uid="uid://c8e8vy2yx0vuj"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_f7hhh"]
[ext_resource type="PackedScene" uid="uid://cumnmnbdjbgas" path="res://core/ai/agents/goat/Goat_rig.fbx" id="2_oxwbf"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_ucoix"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_lqqd8"]
[node name="AiGoat" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_f7hhh")]
anim_player = NodePath("Goat_rig/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=874855696]
script = ExtResource("2_ucoix")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "Goat_Idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=450542027]
script = ExtResource("3_lqqd8")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "Goat_Walk"
exit_on_action_finished = true
[node name="Goat_rig" parent="." index="3" unique_id=1336829719 instance=ExtResource("2_oxwbf")]
[node name="Skeleton3D" parent="Goat_rig/Rig_Goat" parent_id_path=PackedInt32Array(1336829719, 1896192446) index="0" unique_id=1573667924]
bones/1/position = Vector3(-8.352713e-09, 0.36986786, 0.8951362)
bones/1/rotation = Quaternion(0.1276911, -0.695482, -0.12769035, 0.69548184)
bones/2/rotation = Quaternion(-8.7811394e-08, -9.458198e-08, -0.5904155, 0.80709946)
bones/3/rotation = Quaternion(4.747651e-08, -1.1784627e-07, 0.017411958, 0.9998484)
bones/4/rotation = Quaternion(6.0150165e-09, 1.2466938e-07, 0.30337915, 0.95287)
bones/7/rotation = Quaternion(5.4816347e-08, -2.1401915e-08, -0.40028566, 0.9163904)
bones/9/rotation = Quaternion(0.00046716904, -0.0004462793, -0.7121794, 0.7019972)
bones/10/rotation = Quaternion(1.4472131e-07, 8.2933745e-08, 0.037125967, 0.9993106)
bones/11/rotation = Quaternion(-0.012037385, -0.007822092, 0.4605625, 0.8875113)
bones/13/rotation = Quaternion(0.0004971335, -0.00088232313, -0.7120875, 0.70209)
bones/14/rotation = Quaternion(1.2098344e-07, 6.220867e-08, 0.03712596, 0.9993106)
bones/15/rotation = Quaternion(0.016517974, 0.014013905, 0.46007547, 0.8876156)
bones/17/rotation = Quaternion(5.284289e-08, 2.4923622e-07, 0.98189294, 0.1894366)
bones/18/rotation = Quaternion(-1.4809112e-07, -6.559211e-08, -0.4198785, 0.9075803)
bones/19/rotation = Quaternion(-2.2811262e-09, 1.0970184e-07, 0.011576452, 0.999933)
bones/21/rotation = Quaternion(3.0247494e-07, 7.4317376e-07, 0.9653871, -0.26082122)
bones/22/rotation = Quaternion(-3.8364158e-07, 5.6172302e-09, -0.3680436, 0.92980856)
bones/23/rotation = Quaternion(0.0002487348, 5.1511866e-05, 0.45848387, 0.8887027)
bones/26/rotation = Quaternion(2.713829e-07, 8.5825764e-07, 0.9653876, -0.26081985)
bones/27/rotation = Quaternion(-3.8362674e-07, 5.6200027e-09, -0.3680436, 0.92980856)
bones/28/rotation = Quaternion(-0.00015313082, -7.842175e-05, 0.45790914, 0.888999)
[editable path="Goat_rig"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,54 @@
[gd_scene format=3 uid="uid://bbseno7clbepx"]
[ext_resource type="PackedScene" uid="uid://bdqeshcwwnyc4" path="res://core/ai/agents/human/ai_citizen.tscn" id="1_cduuu"]
[node name="AiCitizenSitter" unique_id=1228675528 instance=ExtResource("1_cduuu")]
entity_name = "CitizenSitter"
[node name="Skeleton3D" parent="BaseMesh/BaseMesh" parent_id_path=PackedInt32Array(1846171523, 1142246531) index="0" unique_id=928995817]
bones/0/position = Vector3(4.6274214e-05, 0.53962195, 0.01442101)
bones/0/rotation = Quaternion(-0.08261974, -0.011491157, 0.01847047, 0.99634373)
bones/1/rotation = Quaternion(0.14039387, -0.0048084054, -0.034078293, 0.9894974)
bones/2/rotation = Quaternion(0.019730499, -0.0005302894, -0.003380251, 0.9997995)
bones/3/rotation = Quaternion(0.019732494, -0.00056420703, -0.0034286412, 0.99979925)
bones/4/rotation = Quaternion(0.047632027, 0.0044146716, 5.5285243e-05, 0.99885523)
bones/5/rotation = Quaternion(-0.1481004, 0.030818012, 0.027112251, 0.98812014)
bones/8/rotation = Quaternion(-0.64003974, -0.37008905, 0.49884537, -0.45225725)
bones/9/rotation = Quaternion(0.26399517, -0.016558504, 0.18318768, 0.9468234)
bones/10/rotation = Quaternion(-0.024250507, -0.09629851, 0.46758032, 0.8783548)
bones/11/rotation = Quaternion(-0.12018964, 0.24466898, 0.1851929, 0.9441373)
bones/12/rotation = Quaternion(0.23282185, 0.045711264, 0.11371554, 0.9647659)
bones/13/rotation = Quaternion(0.11161193, 0.015611293, -0.07621057, 0.9907024)
bones/14/rotation = Quaternion(-0.0120385215, 0.035021365, -0.027293455, 0.99894124)
bones/17/rotation = Quaternion(0.47229832, -0.07009207, -0.07346811, 0.87557054)
bones/18/rotation = Quaternion(0.28523657, -0.0033537035, -0.016236508, 0.9583138)
bones/19/rotation = Quaternion(0.114431076, 0.0009974723, -0.016153814, 0.99329937)
bones/22/rotation = Quaternion(0.38703713, -0.07161111, -0.055929746, 0.9175762)
bones/23/rotation = Quaternion(0.27320057, -0.0025043646, -0.0333917, 0.96137416)
bones/24/rotation = Quaternion(0.18236126, 0.0039793584, -0.014504941, 0.9831166)
bones/27/rotation = Quaternion(0.67000026, -0.3385617, 0.49965796, 0.432224)
bones/28/rotation = Quaternion(0.2097779, 0.0323844, -0.30925584, 0.92698723)
bones/29/rotation = Quaternion(-0.013720488, 0.064641, -0.3156722, 0.94656456)
bones/30/rotation = Quaternion(0.023524001, -0.2031076, -0.21903762, 0.95405275)
bones/31/rotation = Quaternion(0.10362807, -0.060477145, -0.0822956, 0.989359)
bones/32/rotation = Quaternion(0.2005617, -0.080317385, 0.08554337, 0.9726287)
bones/33/rotation = Quaternion(0.09055836, 0.16444178, -0.016598457, 0.9820808)
bones/36/rotation = Quaternion(0.41982892, 0.05875236, 0.110271834, 0.89896166)
bones/37/rotation = Quaternion(0.3084902, -5.0797826e-06, 0.016977265, 0.9510761)
bones/38/rotation = Quaternion(0.15843387, -0.0010695796, -0.0025179624, 0.9873659)
bones/41/rotation = Quaternion(0.39090672, 0.07217823, 0.08132209, 0.9139852)
bones/42/rotation = Quaternion(0.23195146, -0.00022551513, 0.057113327, 0.97104925)
bones/43/rotation = Quaternion(0.04765674, -0.005312021, -0.037802245, 0.9981341)
bones/46/rotation = Quaternion(0.07913973, 0.67941314, 0.72431135, -0.08664747)
bones/47/rotation = Quaternion(-0.7301858, 0.021535583, -0.08527201, 0.6775645)
bones/48/rotation = Quaternion(0.42302147, 0.034331664, 0.030263728, 0.9049632)
bones/49/rotation = Quaternion(0.3195373, 0.059513275, -0.020113025, 0.94548905)
bones/52/rotation = Quaternion(-0.048473507, 0.6923688, 0.7180678, 0.05152073)
bones/53/rotation = Quaternion(-0.75171393, 0.06818038, -0.046880867, 0.6542782)
bones/54/rotation = Quaternion(0.44898874, -0.026657255, -0.051447295, 0.8916567)
bones/55/rotation = Quaternion(0.32369038, -0.05870039, 0.019949934, 0.9441297)
[node name="AnimationPlayer" parent="BaseMesh" parent_id_path=PackedInt32Array(1846171523) index="1" unique_id=2096005878]
autoplay = &"custom/sitting"
[editable path="BaseMesh"]

View File

@@ -0,0 +1,30 @@
[gd_scene format=3 uid="uid://bnnuke5e7e1yr"]
[ext_resource type="PackedScene" uid="uid://bdqeshcwwnyc4" path="res://core/ai/agents/human/ai_citizen.tscn" id="1_dms8s"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_awhwq"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_8d0tj"]
[node name="AiCitizenWalker" unique_id=1228675528 instance=ExtResource("1_dms8s")]
entity_name = "CitizenWalker"
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=42226979]
script = ExtResource("2_awhwq")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1357892786]
script = ExtResource("3_8d0tj")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="Skeleton3D" parent="BaseMesh/BaseMesh" parent_id_path=PackedInt32Array(1846171523, 1142246531) index="0" unique_id=928995817]
bones/8/rotation = Quaternion(-0.6173422, -0.37346625, 0.5666242, -0.3979305)
bones/46/rotation = Quaternion(0.059241787, 0.12928401, 0.9836761, -0.110261135)
[editable path="BaseMesh"]

View File

@@ -0,0 +1,40 @@
[gd_scene format=3 uid="uid://ceqxsqfiotm5j"]
[ext_resource type="PackedScene" uid="uid://mvh2v6v72stt" path="res://core/ai/agents/human/ai_human.tscn" id="1_l2y7m"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_2oda6"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="4_2oda6"]
[node name="AiFarmer" unique_id=1228675528 instance=ExtResource("1_l2y7m")]
entity_name = "Farmer"
allowed_biomes = Array[String](["countryside"])
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("GatherState")
[node name="PatrolState" type="Node" parent="StateMachine" index="0" unique_id=930272128]
script = ExtResource("3_2oda6")
state_id = &"patrol"
next_state_id = &"gather"
animation_name = "custom/walking"
exit_on_action_finished = true
[node name="GatherState" type="Node" parent="StateMachine" index="1" unique_id=48091671]
script = ExtResource("4_2oda6")
state_id = &"gather"
next_state_id = &"idle"
animation_name = "custom/gathering"
exit_on_animation_finished = true
min_wait_time = 0.0
max_wait_time = 0.0
[node name="IdleState" type="Node" parent="StateMachine" index="2" unique_id=402985597]
script = ExtResource("4_2oda6")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "custom/idle"
[node name="Skeleton3D" parent="BaseMesh/BaseMesh" parent_id_path=PackedInt32Array(1846171523, 1142246531) index="0" unique_id=928995817]
bones/8/rotation = Quaternion(-0.6173422, -0.37346625, 0.5666242, -0.3979305)
bones/46/rotation = Quaternion(0.059241787, 0.12928401, 0.9836761, -0.110261135)
[editable path="BaseMesh"]

View File

@@ -0,0 +1,70 @@
[gd_scene format=3 uid="uid://mvh2v6v72stt"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_hko2w"]
[ext_resource type="Animation" uid="uid://qhkny5iyd4mi" path="res://core/ai/agents/human/gathering.res" id="3_8kg0q"]
[ext_resource type="PackedScene" uid="uid://cbix54xp87fk0" path="res://core/ai/agents/human/human_base_mesh.fbx" id="3_ef4cu"]
[ext_resource type="Animation" uid="uid://ptj85lvvtjpg" path="res://core/ai/agents/human/sitting.res" id="4_8kg0q"]
[ext_resource type="Animation" uid="uid://oq22ilhxjejj" path="res://core/ai/agents/human/idle.res" id="4_cuxdk"]
[ext_resource type="Animation" uid="uid://6xnsf8x7nmsl" path="res://core/ai/agents/human/walking.res" id="6_cuxdk"]
[sub_resource type="AnimationLibrary" id="AnimationLibrary_8kg0q"]
_data = {
&"gathering": ExtResource("3_8kg0q"),
&"idle": ExtResource("4_cuxdk"),
&"sitting": ExtResource("4_8kg0q"),
&"walking": ExtResource("6_cuxdk")
}
[node name="AiHuman" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_hko2w")]
anim_player = NodePath("BaseMesh/AnimationPlayer")
[node name="BaseMesh" parent="." index="3" unique_id=1846171523 instance=ExtResource("3_ef4cu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.9, 0)
[node name="Skeleton3D" parent="BaseMesh/BaseMesh" parent_id_path=PackedInt32Array(1846171523, 1142246531) index="0" unique_id=928995817]
bones/0/position = Vector3(0.00060560287, 0.9719096, 0.007789615)
bones/0/rotation = Quaternion(-0.03158553, -0.024531638, -0.086598895, 0.9954402)
bones/1/rotation = Quaternion(-0.068302006, -0.011589706, 0.088431515, 0.99367017)
bones/2/rotation = Quaternion(0.013750468, -0.0028497525, 0.022636604, 0.99964523)
bones/3/rotation = Quaternion(0.014052153, -0.0046672956, 0.021981178, 0.99964875)
bones/4/rotation = Quaternion(0.08060878, 0.0009885994, -0.05385771, 0.99528927)
bones/5/rotation = Quaternion(-0.08819712, -0.010719821, 0.004734955, 0.9960341)
bones/8/rotation = Quaternion(-0.5780019, -0.40066734, 0.5948007, -0.38934776)
bones/9/rotation = Quaternion(0.5403529, 0.038538188, -0.087646246, 0.8359735)
bones/10/rotation = Quaternion(-0.009744837, 0.0007412914, 0.18789424, 0.98214066)
bones/11/rotation = Quaternion(0.019992959, 0.15807849, 0.15262179, 0.9753554)
bones/12/rotation = Quaternion(0.11525436, -0.03521942, -0.0147265345, 0.9926023)
bones/13/rotation = Quaternion(0.004553697, -0.0011956134, 0.0748576, 0.9971832)
bones/14/rotation = Quaternion(-0.021573644, -0.09607655, -0.02610063, 0.9947978)
bones/17/rotation = Quaternion(0.10615231, -0.012490018, -0.06538699, 0.9921191)
bones/18/rotation = Quaternion(0.112639524, -0.0005986789, -0.020016164, 0.99343413)
bones/19/rotation = Quaternion(0.13624819, 0.001439244, -0.018421004, 0.9905025)
bones/22/rotation = Quaternion(0.051831737, -0.007218998, -0.063239366, 0.9966254)
bones/23/rotation = Quaternion(0.12439526, 0.00031310506, -0.03746358, 0.99152523)
bones/24/rotation = Quaternion(0.14832872, 0.0028264069, -0.017447466, 0.9887802)
bones/27/rotation = Quaternion(0.6085938, -0.37735197, 0.5827399, 0.3842309)
bones/28/rotation = Quaternion(0.42811802, -0.12440211, 0.04666202, 0.8939026)
bones/29/rotation = Quaternion(-0.010464899, -0.0008133942, -0.24076757, 0.97052604)
bones/30/rotation = Quaternion(0.01554073, -0.15455346, -0.11519627, 0.9811226)
bones/31/rotation = Quaternion(0.109474085, 0.02398801, 0.02464503, 0.99339455)
bones/32/rotation = Quaternion(-0.03558804, 0.04901748, 0.08471445, 0.9945624)
bones/33/rotation = Quaternion(0.014632019, 0.019343862, -0.1317728, 0.9909832)
bones/36/rotation = Quaternion(0.19392295, 0.020005528, 0.11780725, 0.973712)
bones/37/rotation = Quaternion(0.090232305, 2.462184e-07, 0.01726049, 0.9957712)
bones/38/rotation = Quaternion(0.13336712, -0.0009009653, 0.002359003, 0.9910635)
bones/41/rotation = Quaternion(0.12012116, 0.015946638, 0.088212825, 0.9887037)
bones/42/rotation = Quaternion(0.11693482, 0.00096280884, 0.06057904, 0.99128985)
bones/43/rotation = Quaternion(0.22191456, 0.026510797, -0.016629422, 0.9745638)
bones/46/rotation = Quaternion(0.00039673893, 0.021240532, 0.99960107, -0.018613452)
bones/47/rotation = Quaternion(-0.34151906, -0.06546942, 0.0071559767, 0.93756455)
bones/48/rotation = Quaternion(0.60213244, 0.010313871, -0.012120304, 0.7982376)
bones/49/rotation = Quaternion(0.31586254, 0.059334766, -0.020474449, 0.9467265)
bones/52/rotation = Quaternion(-0.07240856, 0.034467246, 0.9931159, -0.085380435)
bones/53/rotation = Quaternion(-0.20515193, 0.049833227, 0.0071537, 0.9774345)
bones/54/rotation = Quaternion(0.55275166, -0.049315806, -0.007871797, 0.8318483)
bones/55/rotation = Quaternion(0.326561, -0.058840513, 0.019667907, 0.9431378)
[node name="AnimationPlayer" parent="BaseMesh" index="1" unique_id=2096005878]
libraries/custom = SubResource("AnimationLibrary_8kg0q")
[editable path="BaseMesh"]

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,44 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://cbix54xp87fk0"
path="res://.godot/imported/human_base_mesh.fbx-f7c776fe2fa7f0a6658ca2b639d0b975.scn"
[deps]
source_file="res://core/ai/agents/human/human_base_mesh.fbx"
dest_files=["res://.godot/imported/human_base_mesh.fbx-f7c776fe2fa7f0a6658ca2b639d0b975.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

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
[gd_scene format=3 uid="uid://dgpkoccwlypct"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_seif5"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_c6y48"]
[ext_resource type="PackedScene" uid="uid://b3s7f6ntc8lua" path="res://core/ai/agents/racoon/Raccoon_rig.fbx" id="2_obtl0"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_x67t3"]
[node name="AiRacoon" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_seif5")]
anim_player = NodePath("Raccoon_rig/AnimationPlayer")
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=445061494]
script = ExtResource("2_c6y48")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "Raccoon_Idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1096336671]
script = ExtResource("3_x67t3")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "Raccoon_walk"
exit_on_action_finished = true
[node name="Raccoon_rig" parent="." index="3" unique_id=338211330 instance=ExtResource("2_obtl0")]
[node name="Skeleton3D" parent="Raccoon_rig/Rig_Raccoon" parent_id_path=PackedInt32Array(338211330, 1484615769) index="0" unique_id=689430915]
bones/1/position = Vector3(2.0224038e-08, 0.20926544, 0.2908604)
bones/1/rotation = Quaternion(0.12769087, -0.6954821, -0.12769023, 0.69548184)
bones/1/scale = Vector3(1, 0.99999994, 0.99999994)
bones/2/position = Vector3(0.12958723, 0.07514775, -1.15517205e-08)
bones/2/rotation = Quaternion(-8.768937e-08, -9.441525e-08, -0.59041584, 0.8070993)
bones/2/scale = Vector3(0.99999994, 1, 1)
bones/3/position = Vector3(0.22119753, 0.0069588325, 4.8590223e-08)
bones/3/rotation = Quaternion(4.7472064e-08, -1.1799982e-07, 0.017411917, 0.9998484)
bones/3/scale = Vector3(1, 0.99999994, 1)
bones/4/position = Vector3(0.19968472, -0.07484539, -3.6076216e-08)
bones/4/rotation = Quaternion(5.3009783e-09, 1.2681039e-07, 0.30337906, 0.95286995)
bones/4/scale = Vector3(0.9999999, 0.9999999, 1)
bones/5/position = Vector3(-1.6408816e-08, -2.420219e-08, 7.257661e-15)
bones/5/rotation = Quaternion(5.51443e-16, 1.517952e-14, 4.7269896e-08, 1)
bones/5/scale = Vector3(1.0000001, 1, 1)
bones/7/position = Vector3(0.103939, -0.07868026, 2.3476135e-08)
bones/7/rotation = Quaternion(9.0738554e-09, -1.3033788e-07, -0.40028542, 0.91639054)
bones/7/scale = Vector3(1, 1, 1)
bones/9/position = Vector3(0.11748607, -0.13258429, 0.069675714)
bones/9/rotation = Quaternion(0.0004671751, -0.00044618634, -0.7121794, 0.7019972)
bones/9/scale = Vector3(1, 1, 1)
bones/10/position = Vector3(0.12467117, -0.0022201955, -2.8368248e-08)
bones/10/rotation = Quaternion(5.363282e-08, 1.05591454e-07, 0.037125982, 0.9993106)
bones/10/scale = Vector3(1, 1, 1)
bones/11/position = Vector3(0.16112469, 0.046494268, -0.006244522)
bones/11/rotation = Quaternion(-0.0120373955, -0.007822201, 0.46056247, 0.8875113)
bones/11/scale = Vector3(1.0000001, 0.99999994, 1)
bones/13/position = Vector3(0.117486075, -0.1325843, -0.0696799)
bones/13/rotation = Quaternion(0.0004971096, -0.00088223023, -0.7120875, 0.70209)
bones/13/scale = Vector3(0.9999999, 0.9999999, 1)
bones/14/position = Vector3(0.12467118, -0.0022202404, -3.56783e-08)
bones/14/rotation = Quaternion(5.3701754e-08, 1.05572354e-07, 0.037125997, 0.9993106)
bones/14/scale = Vector3(1.0000001, 1.0000001, 1)
bones/15/position = Vector3(0.16112465, 0.04649423, 0.0062444974)
bones/15/rotation = Quaternion(0.016517976, 0.014013659, 0.46007556, 0.88761556)
bones/15/scale = Vector3(0.9999999, 0.9999999, 1)
bones/17/position = Vector3(0.04661899, 0.17346847, -1.18498086e-07)
bones/17/rotation = Quaternion(2.770023e-07, 3.177246e-07, 0.99957025, -0.029315341)
bones/17/scale = Vector3(1.000003, 1, 1)
bones/18/position = Vector3(0.14637275, -0.04410621, -9.865532e-08)
bones/18/rotation = Quaternion(-2.6851015e-07, -5.1783097e-08, -0.38697308, 0.92209107)
bones/18/scale = Vector3(1, 0.99999994, 1)
bones/19/position = Vector3(0.14074759, 0.012081423, -1.07438225e-07)
bones/19/rotation = Quaternion(-5.266017e-08, 3.9203155e-07, -0.22906616, 0.9734109)
bones/19/scale = Vector3(0.99999994, 1.0000001, 1)
bones/21/position = Vector3(0.08406017, 0.07054766, -0.046703663)
bones/21/rotation = Quaternion(2.472915e-07, 4.2034915e-07, 0.9653872, -0.26082113)
bones/21/scale = Vector3(0.99999994, 1.0000001, 1)
bones/22/position = Vector3(0.18519638, 0.014841081, -0.03856185)
bones/22/rotation = Quaternion(-1.04219914e-07, 2.4218835e-07, -0.36804387, 0.92980844)
bones/23/position = Vector3(0.09934621, 0.042793605, -0.011642947)
bones/23/rotation = Quaternion(0.00024863242, 5.0840557e-05, 0.45848417, 0.88870263)
bones/23/scale = Vector3(1, 0.9999999, 1)
bones/24/position = Vector3(0.10396489, 0.016853496, -0.010173391)
bones/24/rotation = Quaternion(9.3242754e-08, 2.4390525e-07, 0.5472883, 0.83694416)
bones/24/scale = Vector3(1.0000001, 1.0000001, 1)
bones/26/position = Vector3(0.08406015, 0.07054774, 0.046699274)
bones/26/rotation = Quaternion(2.1619995e-07, 5.3543306e-07, 0.96538764, -0.2608197)
bones/26/scale = Vector3(0.99999994, 1.0000001, 1)
bones/27/position = Vector3(0.18519638, 0.014841113, 0.038561605)
bones/27/rotation = Quaternion(-1.0420509e-07, 2.4219113e-07, -0.36804387, 0.92980844)
bones/27/scale = Vector3(1, 0.9999999, 1)
bones/28/position = Vector3(0.09934621, 0.04279366, 0.011642782)
bones/28/rotation = Quaternion(-0.00015323279, -7.909327e-05, 0.45790946, 0.8889988)
bones/28/scale = Vector3(0.9999999, 0.9999999, 1)
bones/29/position = Vector3(0.10396492, 0.01685347, 0.0101733515)
bones/29/rotation = Quaternion(6.860365e-08, 2.2637091e-07, 0.5472883, 0.83694416)
bones/29/scale = Vector3(1.0000001, 1, 1)
[editable path="Raccoon_rig"]

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,54 @@
[gd_scene format=3 uid="uid://cp8tf1uitoj57"]
[ext_resource type="PackedScene" uid="uid://clx701xdwelgx" path="res://core/ai/agents/base/ai_base.tscn" id="1_01jto"]
[ext_resource type="Script" uid="uid://d3hy70ec8vqo5" path="res://core/ai/framework/run_animation_state.gd" id="2_euyvm"]
[ext_resource type="PackedScene" uid="uid://dg6eq5bjdv77x" path="res://core/ai/agents/wagyu/Wagyu_rig.fbx" id="2_kinfw"]
[ext_resource type="Script" uid="uid://bngfthvt04ivv" path="res://core/ai/framework/patrol_state.gd" id="3_stslt"]
[node name="AiWagyu" unique_id=1228675528 node_paths=PackedStringArray("anim_player") instance=ExtResource("1_01jto")]
anim_player = NodePath("Wagyu_rig/AnimationPlayer")
entity_type = 1
entity_name = "Wagyu"
[node name="StateMachine" parent="." index="1" unique_id=1286404264 node_paths=PackedStringArray("initial_state")]
initial_state = NodePath("IdleState")
[node name="IdleState" type="Node" parent="StateMachine" index="0" unique_id=1768876006]
script = ExtResource("2_euyvm")
state_id = &"idle"
next_state_id = &"patrol"
animation_name = "wagyu_Idle"
[node name="PatrolState" type="Node" parent="StateMachine" index="1" unique_id=1424605081]
script = ExtResource("3_stslt")
state_id = &"patrol"
next_state_id = &"idle"
animation_name = "wagyu_walk"
exit_on_action_finished = true
[node name="Wagyu_rig" parent="." index="3" unique_id=434062845 instance=ExtResource("2_kinfw")]
[node name="Skeleton3D" parent="Wagyu_rig/Rig_wagyu" parent_id_path=PackedInt32Array(434062845, 984050088) index="0" unique_id=1381831503]
bones/1/position = Vector3(3.0605813e-06, 0.93198204, 1.5827273)
bones/1/rotation = Quaternion(0.12769, -0.69548225, -0.12769146, 0.6954816)
bones/2/rotation = Quaternion(-7.474808e-08, -1.0355375e-07, -0.5904155, 0.80709946)
bones/3/rotation = Quaternion(4.6805877e-08, -1.1830556e-07, 0.017411785, 0.9998484)
bones/4/rotation = Quaternion(1.771281e-08, 1.0884481e-07, 0.19398119, 0.9810053)
bones/7/rotation = Quaternion(3.415823e-08, -6.211047e-10, -0.29438308, 0.9556875)
bones/9/rotation = Quaternion(0.00046733156, -0.00044638076, -0.7121791, 0.7019975)
bones/10/rotation = Quaternion(1.1991547e-07, 8.809733e-08, 0.037125666, 0.9993106)
bones/11/rotation = Quaternion(-0.012037467, -0.007821967, 0.46056256, 0.88751113)
bones/13/rotation = Quaternion(0.00049730047, -0.0008825069, -0.71208733, 0.7020902)
bones/14/rotation = Quaternion(1.5469529e-07, -1.483681e-08, 0.037125666, 0.9993106)
bones/15/rotation = Quaternion(0.016517892, 0.014014246, 0.46007577, 0.8876154)
bones/17/rotation = Quaternion(9.343425e-08, 2.4610299e-07, 0.9818929, 0.18943687)
bones/18/rotation = Quaternion(2.348474e-07, -1.7702094e-07, 0.3209432, 0.9470985)
bones/19/rotation = Quaternion(2.0569273e-09, 2.3186735e-07, 0.008903695, 0.99996036)
bones/21/rotation = Quaternion(3.5893487e-07, 1.1177136e-06, 0.9652683, -0.2612609)
bones/22/rotation = Quaternion(-6.1835095e-07, -2.3081903e-07, -0.36804387, 0.92980844)
bones/23/rotation = Quaternion(0.0002490793, 5.1833915e-05, 0.45848417, 0.88870263)
bones/26/rotation = Quaternion(3.2779312e-07, 1.2327837e-06, 0.9652686, -0.2612597)
bones/27/rotation = Quaternion(-6.191086e-07, -2.305114e-07, -0.36804327, 0.9298087)
bones/28/rotation = Quaternion(-0.0001528551, -7.8230434e-05, 0.45790893, 0.8889991)
[editable path="Wagyu_rig"]

View File

@@ -0,0 +1,64 @@
extends State
class_name FlyAwayState
@export var fly_speed: float = 6.0
@export var fly_up_speed: float = 3.0
@export var destroy_after_seconds: float = 8.0
var _timer: float = 0.0
var _fly_direction: Vector3 = Vector3.UP
func enter() -> void:
super.enter()
run_animation()
# Disable NavigationAgent3D influence since we want manual flight
agent.nav_agent.process_mode = Node.PROCESS_MODE_DISABLED
var weather_nodes = get_tree().get_nodes_in_group("weather_node")
var train_node = null
for node in weather_nodes:
if "Treno" in node.name or "Train" in node.name:
train_node = node
break
if not train_node:
var train = get_tree().root.find_child("*Treno*", true, false)
if train and train is Node3D:
train_node = train
else:
train = get_tree().root.find_child("*Train*", true, false)
if train and train is Node3D:
train_node = train
if train_node:
# Fly away from the train
var dir_to_train = agent.global_position.direction_to(train_node.global_position)
dir_to_train.y = 0
if dir_to_train.length() > 0.1:
_fly_direction = -dir_to_train.normalized()
else:
_fly_direction = -agent.global_transform.basis.z.normalized()
else:
# If no train found, just fly forward relative to current facing
_fly_direction = -agent.global_transform.basis.z.normalized()
func physics_update(delta: float) -> void:
_timer += delta
if _timer >= destroy_after_seconds:
agent.queue_free()
return
var horizontal_vel = _fly_direction * fly_speed
agent.velocity.x = horizontal_vel.x
agent.velocity.y = fly_up_speed
agent.velocity.z = horizontal_vel.z
# Rotate agent to face flight direction
if horizontal_vel.length_squared() > 0.1:
var look_dir = Vector3(agent.velocity.x, 0, agent.velocity.z)
var target_transform = agent.global_transform.looking_at(agent.global_position - look_dir, Vector3.UP)
agent.global_transform = agent.global_transform.interpolate_with(target_transform, delta * 5.0)
agent.move_and_slide()

View File

@@ -0,0 +1 @@
uid://tys4fmqvneom

View File

@@ -0,0 +1,12 @@
extends State
func enter() -> void:
super.enter()
run_animation()
agent.navigate_to_random_point()
func physics_update(_delta) -> void:
if agent.nav_agent.is_navigation_finished():
transitioned.emit(self, get_next_state())
elif agent.nav_agent.get_current_navigation_path().is_empty():
transitioned.emit(self, get_next_state())

View File

@@ -0,0 +1 @@
uid://bngfthvt04ivv

View File

@@ -0,0 +1,6 @@
extends State
func enter() -> void:
super.enter()
run_animation()

View File

@@ -0,0 +1 @@
uid://d3hy70ec8vqo5

View File

@@ -0,0 +1,18 @@
extends State
var starting_speed: float
func enter() -> void:
super.enter()
run_animation()
agent.navigate_to_random_point()
starting_speed = agent.speed
agent.speed = agent.speed * 1.5
func physics_update(_delta) -> void:
if agent.nav_agent.is_navigation_finished():
transitioned.emit(self, get_next_state())
func exit() -> void:
agent.speed = starting_speed
super.exit()

View File

@@ -0,0 +1 @@
uid://b5y4u0itec8g1

View File

@@ -0,0 +1,70 @@
extends Node
class_name State
@export var state_id: StringName = &""
@export var next_state_id: StringName
@export var random_next_state_ids: Array[StringName] = []
@export var animation_name: String
@export var blend_time: float = 0.2
@export var exit_on_action_finished: bool
@export var exit_on_animation_finished: bool
@export var min_wait_time: float = 3.0
@export var max_wait_time: float = 10
var runtime_timer: Timer
@onready var agent: AIBase = owner
signal transitioned(state: State, new_state_id: StringName)
func _ready() -> void:
if min_wait_time > 0 and !exit_on_action_finished:
runtime_timer = Timer.new()
runtime_timer.name = "IdleTimer"
runtime_timer.one_shot = true
add_child(runtime_timer)
runtime_timer.timeout.connect(_on_timer_timeout)
func enter() -> void:
if exit_on_animation_finished:
if not agent.anim_player.animation_finished.is_connected(_on_animation_finished):
agent.anim_player.animation_finished.connect(_on_animation_finished)
elif min_wait_time > 0 and !exit_on_action_finished:
var wait_time:= randf_range(min_wait_time, max_wait_time)
runtime_timer.start(wait_time)
func exit() -> void:
if exit_on_animation_finished and agent.anim_player.animation_finished.is_connected(_on_animation_finished):
agent.anim_player.animation_finished.disconnect(_on_animation_finished)
if runtime_timer and not runtime_timer.is_stopped():
runtime_timer.stop()
func update(_delta: float) -> void:
pass
func physics_update(_delta: float) -> void:
pass
func run_animation() -> void:
if agent.anim_player and agent.anim_player.has_animation(animation_name):
agent.anim_player.play(animation_name, blend_time)
func _on_animation_finished(anim_name: StringName) -> void:
if animation_name == anim_name:
if exit_on_action_finished:
return
elif min_wait_time > 0:
var wait_time := randf_range(min_wait_time, max_wait_time)
runtime_timer.start(wait_time)
else:
transitioned.emit(self, get_next_state())
func _on_timer_timeout() -> void:
transitioned.emit(self, get_next_state())
func get_next_state() -> StringName:
if random_next_state_ids.size() > 0:
return random_next_state_ids.pick_random()
return next_state_id

View File

@@ -0,0 +1 @@
uid://dpso7abi5ftyw

View 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()

View File

@@ -0,0 +1 @@
uid://ps3vlu2qvmop

View File

@@ -0,0 +1,37 @@
extends State
class_name WaitTrainState
@export var fly_distance_threshold: float = 30.0
var _train_node: Node3D = null
func enter() -> void:
super.enter()
run_animation()
_train_node = _find_train_node()
func physics_update(_delta: float) -> void:
if not _train_node:
_train_node = _find_train_node()
if _train_node:
var dist = agent.global_position.distance_to(_train_node.global_position)
if dist <= fly_distance_threshold:
transitioned.emit(self, get_next_state())
func _find_train_node() -> Node3D:
var weather_nodes = get_tree().get_nodes_in_group("weather_node")
for node in weather_nodes:
if "Treno" in node.name or "Train" in node.name:
return node as Node3D
var train = get_tree().root.find_child("*Treno*", true, false)
if train and train is Node3D:
return train as Node3D
train = get_tree().root.find_child("*Train*", true, false)
if train and train is Node3D:
return train as Node3D
return null

View File

@@ -0,0 +1 @@
uid://da5vhmxbxkdbc

View File

@@ -0,0 +1,34 @@
extends Node
signal volume_changed(bus_name: StringName, linear_value: float)
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()
volume_changed.emit(bus_name, clamped_value)
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))

View File

@@ -0,0 +1 @@
uid://dcttbbavtwtsg

File diff suppressed because it is too large Load Diff

View File

@@ -2,7 +2,9 @@
[ext_resource type="Script" uid="uid://ct2k25kslaxe5" path="res://core/biome_generator/biome_generator.gd" id="1_c7ilo"] [ext_resource type="Script" uid="uid://ct2k25kslaxe5" path="res://core/biome_generator/biome_generator.gd" id="1_c7ilo"]
[ext_resource type="Material" uid="uid://b8p1sjxisi522" path="res://core/biome_generator/wires.tres" id="2_w42pm"] [ext_resource type="Material" uid="uid://b8p1sjxisi522" path="res://core/biome_generator/wires.tres" id="2_w42pm"]
[ext_resource type="Resource" path="res://core/biome_generator/railway_pool.tres" id="3_railway_pool"]
[node name="biome_generator" type="Node3D" unique_id=1861369341] [node name="biome_generator" type="Node3D" unique_id=1861369341]
script = ExtResource("1_c7ilo") script = ExtResource("1_c7ilo")
railway_pool = ExtResource("3_railway_pool")
lamppost_wire_material = ExtResource("2_w42pm") lamppost_wire_material = ExtResource("2_w42pm")

View File

@@ -5,6 +5,7 @@ class_name ChunkInfo
@export_group("Set Piece Rules (Unique pieces)") @export_group("Set Piece Rules (Unique pieces)")
@export var exclusive_biome: String = "" # Es: "Forest" @export var exclusive_biome: String = "" # Es: "Forest"
@export_range(0, 5, 1) var uniqueness: int = 0 #0=common; 5=unique
@export_group("Base exit") @export_group("Base exit")
@export var north: bool = false @export var north: bool = false
@@ -12,6 +13,12 @@ class_name ChunkInfo
@export var south: bool = false @export var south: bool = false
@export var west: 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_group("Margin heights (level 0, 1, 2)")
@export_range(0, 2, 1) var height_north: int = 0 @export_range(0, 2, 1) var height_north: int = 0
@export_range(0, 2, 1) var height_est: int = 0 @export_range(0, 2, 1) var height_est: int = 0
@@ -29,14 +36,17 @@ func _ready() -> void:
func get_rotated_data(steps_90: int) -> Dictionary: func get_rotated_data(steps_90: int) -> Dictionary:
var original_exit = [north, est, south, west] 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 original_height = [height_north, height_est, height_south, height_west]
var calculated_exit = [] var calculated_exit = []
var calculated_river_exit = []
var calculated_height = [] var calculated_height = []
for i in range(4): for i in range(4):
var index = (i - steps_90 + 4) % 4 var index = (i - steps_90 + 4) % 4
calculated_exit.append(original_exit[index]) calculated_exit.append(original_exit[index])
calculated_river_exit.append(original_river_exit[index])
calculated_height.append(original_height[index]) calculated_height.append(original_height[index])
return { return {
@@ -44,6 +54,10 @@ func get_rotated_data(steps_90: int) -> Dictionary:
"north": calculated_exit[0], "est": calculated_exit[1], "north": calculated_exit[0], "est": calculated_exit[1],
"south": calculated_exit[2], "west": calculated_exit[3] "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": { "heights": {
"north": calculated_height[0], "est": calculated_height[1], "north": calculated_height[0], "est": calculated_height[1],
"south": calculated_height[2], "west": calculated_height[3] "south": calculated_height[2], "west": calculated_height[3]

View File

@@ -0,0 +1,17 @@
[gd_resource type="Resource" script_class="EntityPool" format=3 uid="uid://cmd6s6thq4f7r"]
[ext_resource type="PackedScene" uid="uid://duppccreftg3v" path="res://core/ai/agents/cat/ai_cat.tscn" id="1_ow458"]
[ext_resource type="Script" uid="uid://53ryr0fsqiq7" path="res://core/biome_generator/entity_pool.gd" id="1_vccp2"]
[ext_resource type="PackedScene" uid="uid://cxi6phs4fieli" path="res://core/ai/agents/crow/ai_crow.tscn" id="2_iqga3"]
[ext_resource type="PackedScene" uid="uid://bk45etvtdd6m5" path="res://core/ai/agents/fox/ai_fox.tscn" id="3_76rvd"]
[ext_resource type="PackedScene" uid="uid://c8e8vy2yx0vuj" path="res://core/ai/agents/goat/ai_goat.tscn" id="4_hq17p"]
[ext_resource type="PackedScene" uid="uid://dgpkoccwlypct" path="res://core/ai/agents/racoon/ai_racoon.tscn" id="5_5yjl1"]
[ext_resource type="PackedScene" uid="uid://cp8tf1uitoj57" path="res://core/ai/agents/wagyu/ai_wagyu.tscn" id="6_xd1cg"]
[ext_resource type="PackedScene" uid="uid://ceqxsqfiotm5j" path="res://core/ai/agents/human/ai_farmer.tscn" id="7_hhs8l"]
[ext_resource type="PackedScene" uid="uid://bbseno7clbepx" path="res://core/ai/agents/human/ai_citizen_sitter.tscn" id="9_x3pn3"]
[ext_resource type="PackedScene" uid="uid://bnnuke5e7e1yr" path="res://core/ai/agents/human/ai_citizen_walker.tscn" id="10_ctysb"]
[resource]
script = ExtResource("1_vccp2")
name = "Entity Pool"
available_entities = Array[PackedScene]([ExtResource("1_ow458"), ExtResource("2_iqga3"), ExtResource("3_76rvd"), ExtResource("4_hq17p"), ExtResource("5_5yjl1"), ExtResource("6_xd1cg"), ExtResource("7_hhs8l"), ExtResource("9_x3pn3"), ExtResource("10_ctysb")])

View File

@@ -0,0 +1,5 @@
extends Resource
class_name EntityPool
@export var name: String = "New Entity Pool"
@export var available_entities: Array[PackedScene] = []

View File

@@ -0,0 +1 @@
uid://53ryr0fsqiq7

View File

@@ -0,0 +1,8 @@
extends Marker3D
class_name EntitySpawnPoint
enum AllowedType { ANY, HUMANOID_ONLY, ANIMAL_ONLY }
@export var allowed_type: AllowedType = AllowedType.ANY
@export_range(0.0, 1.0, 0.01) var spawn_chance: float = 1.0
@export var random_y_rotation: bool = true

View File

@@ -0,0 +1 @@
uid://c5ercbqy7srx3

View File

@@ -0,0 +1,5 @@
extends Marker3D
class_name PropInfo
@export var available_props: Array[PackedScene]
@export_range(0, 5, 1) var uniqueness: int = 0 #0=common; 5=unique

View File

@@ -0,0 +1 @@
uid://dg6ngy4pmtsyc

View File

@@ -1,31 +1,60 @@
extends Path3D extends Path3D
@export_group("Train") @export_group("Train")
##train speed
@export var train_speed: float = 6.0 @export var train_speed: float = 6.0
##if true the train is in motion
@export var is_inmotion: bool = true @export var is_inmotion: bool = true
##the model for the locomotive
@export var train_model: PackedScene @export var train_model: PackedScene
##array of wagon scenes
@export var wagon_pool: Resource
##if true the number of wagons is random from 1 to wagon_count
@export var wagon_random_number: bool = true
##if wagon_random_number = true is used as max wagons
@export_range(0, 32, 1, "or_greater") var wagon_count: int = 3
##the distance between two wagons
@export var wagon_gap: float = 0.4
##the scale to calculate the distance of the bounds
@export_range(0.1, 2.0, 0.05, "or_greater") var wagon_spacing_scale: float = 0.5
##override spacing using this value
@export var wagon_spacing_override: float = 0.0
##distance of the rail axes
@export var axes_distance: float = 3.0 @export var axes_distance: float = 3.0
##discance between rails
@export var rail_distance: float = 1.2 @export var rail_distance: float = 1.2
##current camera
@export var cameras: Node3D @export var cameras: Node3D
##swing of the train during the ran
@export_range(0.0, 1.0) var basic_swing: float = 0.1 @export_range(0.0, 1.0) var basic_swing: float = 0.1
@export_group("Rails Bulding") @export_group("Rails Bulding")
##distance between sleepers of the rails
@export var sleepers_distance: float = 1.0 @export var sleepers_distance: float = 1.0
##nodel for the sleeper of the rail
@export var sleepers_model: PackedScene @export var sleepers_model: PackedScene
@export_group("Manual Controls") @export_group("Manual Controls")
##max speed
@export var speed_max: float = 15.0 @export var speed_max: float = 15.0
##min speed
@export var speed_min: float = -5.0 @export var speed_min: float = -5.0
##acceleration
@export var manual_acceleration: float = 5.0 @export var manual_acceleration: float = 5.0
@export_group("Train Stops") @export_group("Train Stops")
##if true the train stop the ran on stops
@export var enable_stops: bool = true @export var enable_stops: bool = true
##time of stop
@export var stop_time: float = 4.0 @export var stop_time: float = 4.0
##distance when the train start to brake
@export var brake_distance: float = 15.0 @export var brake_distance: float = 15.0
##restart time
@export var restart_time: float = 3.0 @export var restart_time: float = 3.0
##scene for fireworks
@export var fireworks_scene: PackedScene @export var fireworks_scene: PackedScene
##array of colors for fireworks
var fireworks_colors: Array[Color] = [ @export var fireworks_colors: Array[Color] = [
Color(1.0, 0.2, 0.2), # Rosso vivo Color(1.0, 0.2, 0.2), # Rosso vivo
Color(0.2, 1.0, 0.2), # Verde lime Color(0.2, 1.0, 0.2), # Verde lime
Color(0.3, 0.5, 1.0), # Blu cielo Color(0.3, 0.5, 1.0), # Blu cielo
@@ -48,9 +77,14 @@ var stop_multiply: float = 1.0
var is_restarting: bool = false var is_restarting: bool = false
var tween_restart: Tween var tween_restart: Tween
var environment_config: EnvironmentConfig var environment_config: EnvironmentConfig
var wagon_instances: Array[Node3D] = []
var wagon_progress_offsets: Array[float] = []
func _ready() -> void: func _ready() -> void:
randomize()
_cache_environment_config() _cache_environment_config()
if curve != null and curve.get_baked_length() > 0: if curve != null and curve.get_baked_length() > 0:
build_rails() build_rails()
build_train() build_train()
@@ -153,6 +187,8 @@ func _snap_train_to_progress() -> void:
cameras.global_position = center_position cameras.global_position = center_position
cameras.global_basis = train_instance.global_basis cameras.global_basis = train_instance.global_basis
_snap_wagons_to_progress(total_length)
func build_rails() -> void: func build_rails() -> void:
var mat_wood = StandardMaterial3D.new() var mat_wood = StandardMaterial3D.new()
mat_wood.albedo_color = Color(0.35, 0.2, 0.1) mat_wood.albedo_color = Color(0.35, 0.2, 0.1)
@@ -228,8 +264,8 @@ func _input(event: InputEvent) -> void:
if event is InputEventKey and event.pressed and not event.echo: if event is InputEventKey and event.pressed and not event.echo:
if event.keycode == KEY_T: if event.keycode == KEY_T:
_goto_next_stop() _goto_next_stop()
elif event.keycode == KEY_F: #elif event.keycode == KEY_F:
_test_manual_fireworks() #_test_manual_fireworks()
func _test_manual_fireworks() -> void: func _test_manual_fireworks() -> void:
if fireworks_scene == null or train_instance == null: return if fireworks_scene == null or train_instance == null: return
@@ -324,6 +360,8 @@ func train_move(delta: float) -> void:
cameras.global_position = center_position cameras.global_position = center_position
cameras.global_basis = train_instance.global_basis cameras.global_basis = train_instance.global_basis
_snap_wagons_to_progress(total_length)
var real_speed = abs(train_speed * stop_multiply) var real_speed = abs(train_speed * stop_multiply)
var speed_factor = clamp(real_speed / max(speed_max, 0.001), 0.0, 1.0) var speed_factor = clamp(real_speed / max(speed_max, 0.001), 0.0, 1.0)
var dir_prev = (center_position - back_position).normalized() var dir_prev = (center_position - back_position).normalized()
@@ -401,6 +439,34 @@ func build_train() -> void:
else: else:
build_default_train() build_default_train()
var wagons = wagon_count
if wagon_random_number:
wagons = randi_range(1, wagon_count)
build_train_wagons(wagons)
func build_train_wagons(wagon_number: int) -> void:
_clear_train_wagons()
if wagon_number <= 0 or wagon_pool == null or not "available_wagons" in wagon_pool:
return
if wagon_pool.available_wagons.is_empty():
return
for i in range(wagon_number):
var wagon_scene: PackedScene = wagon_pool.available_wagons.pick_random()
if wagon_scene == null:
continue
var wagon: Node3D = wagon_scene.instantiate() as Node3D
if wagon == null:
push_warning("Wagon scene root must be a Node3D.")
continue
add_child(wagon)
wagon_instances.append(wagon)
_update_wagon_progress_offsets()
_snap_wagons_to_progress()
func build_default_train() -> void: func build_default_train() -> void:
train_instance = Node3D.new() train_instance = Node3D.new()
add_child(train_instance) add_child(train_instance)
@@ -435,3 +501,110 @@ func build_default_train() -> void:
stack.material_override = mat_body stack.material_override = mat_body
stack.position = Vector3(0, 1.2, 1.0) stack.position = Vector3(0, 1.2, 1.0)
train_instance.add_child(stack) train_instance.add_child(stack)
func _clear_train_wagons() -> void:
for wagon in wagon_instances:
if is_instance_valid(wagon):
wagon.queue_free()
wagon_instances.clear()
wagon_progress_offsets.clear()
func _update_wagon_progress_offsets() -> void:
wagon_progress_offsets.clear()
if train_instance == null or wagon_instances.is_empty():
return
var train_length: float = _get_vehicle_length(train_instance)
var previous_length: float = train_length
var accumulated_distance: float = 0.0
for wagon in wagon_instances:
var wagon_length: float = _get_vehicle_length(wagon)
if wagon_spacing_override > 0.0:
accumulated_distance += wagon_spacing_override + wagon_gap
else:
var detected_spacing: float = previous_length * 0.5 + wagon_length * 0.5
accumulated_distance += detected_spacing * wagon_spacing_scale + wagon_gap
wagon_progress_offsets.append(accumulated_distance)
previous_length = wagon_length
func _snap_wagons_to_progress(total_length: float = 0.0) -> void:
if curve == null or wagon_instances.is_empty():
return
if total_length <= 0.0:
total_length = curve.get_baked_length()
if total_length <= 0.0:
return
for i in range(wagon_instances.size()):
var wagon: Node3D = wagon_instances[i]
if not is_instance_valid(wagon):
continue
var wagon_offset: float = float(i + 1) * 7.0
if i < wagon_progress_offsets.size():
wagon_offset = wagon_progress_offsets[i]
var wagon_progress: float = train_progress - wagon_offset
var vehicle_progress: float = wrapf(wagon_progress, 0.0, total_length)
var center_position: Vector3 = to_global(curve.sample_baked(vehicle_progress, true))
var prog_forward: float = wrapf(vehicle_progress + 2.0, 0.0, total_length)
var forward_position: Vector3 = to_global(curve.sample_baked(prog_forward, true))
wagon.global_position = center_position
if center_position.distance_to(forward_position) > 0.01:
wagon.look_at(forward_position, Vector3.UP)
wagon.rotate_y(PI)
func _get_vehicle_length(vehicle: Node3D) -> float:
var bounds: AABB = _get_node_local_bounds(vehicle, vehicle)
if bounds.size == Vector3.ZERO:
return 7.0
return maxf(bounds.size.z, 0.1)
func _get_node_local_bounds(root: Node3D, node: Node) -> AABB:
var result: AABB = AABB()
var has_bounds: bool = false
var mesh_instance := node as MeshInstance3D
if mesh_instance != null and mesh_instance.mesh != null:
var mesh_bounds: AABB = mesh_instance.get_aabb()
var mesh_transform: Transform3D = root.global_transform.affine_inverse() * mesh_instance.global_transform
for corner in _get_aabb_corners(mesh_bounds):
var local_point: Vector3 = mesh_transform * corner
if has_bounds:
result = result.expand(local_point)
else:
result = AABB(local_point, Vector3.ZERO)
has_bounds = true
for child in node.get_children():
var child_bounds: AABB = _get_node_local_bounds(root, child)
if child_bounds.size == Vector3.ZERO:
continue
if has_bounds:
result = result.merge(child_bounds)
else:
result = child_bounds
has_bounds = true
return result
func _get_aabb_corners(bounds: AABB) -> Array[Vector3]:
var start: Vector3 = bounds.position
var end: Vector3 = bounds.end
return [
Vector3(start.x, start.y, start.z),
Vector3(end.x, start.y, start.z),
Vector3(start.x, end.y, start.z),
Vector3(end.x, end.y, start.z),
Vector3(start.x, start.y, end.z),
Vector3(end.x, start.y, end.z),
Vector3(start.x, end.y, end.z),
Vector3(end.x, end.y, end.z),
]

View File

@@ -0,0 +1,5 @@
extends Resource
class_name RailwayPool
@export var name: String = "New Railway Pool"
@export var available_railways: Array[PackedScene] = []

View File

@@ -0,0 +1 @@
uid://c374rv220mvh1

View File

@@ -0,0 +1,17 @@
[gd_resource type="Resource" script_class="RailwayPool" format=3 uid="uid://nrm040srfjwo"]
[ext_resource type="PackedScene" uid="uid://cl2ast2tk7ifw" path="res://tgcc/chunk/railway/scene/chunk_railway_curve.tscn" id="1_86h1y"]
[ext_resource type="PackedScene" uid="uid://cewdxvcpqb53f" path="res://tgcc/chunk/railway/scene/chunk_railway_station_doubleside.tscn" id="3_3auto"]
[ext_resource type="PackedScene" uid="uid://d3pcshw2bioic" path="res://tgcc/chunk/railway/scene/chunk_railway_station_oneside.tscn" id="4_i1umq"]
[ext_resource type="PackedScene" uid="uid://bqxpqhla2kogq" path="res://tgcc/chunk/railway/scene/chunk_railway_straight.tscn" id="5_x44at"]
[ext_resource type="PackedScene" uid="uid://c3ub6rj0tlt6q" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_2.tscn" id="6_vrrkw"]
[ext_resource type="PackedScene" uid="uid://cqevecsd1cm1v" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_3.tscn" id="7_l17bw"]
[ext_resource type="PackedScene" uid="uid://f53hfrjaxkwa" path="res://tgcc/chunk/railway/scene/chunk_railway_straight_bridge.tscn" id="8_qcl5o"]
[ext_resource type="PackedScene" uid="uid://fi6faw7ag1i0" path="res://tgcc/chunk/railway/scene/chunk_railway_curve_3.tscn" id="8_r0882"]
[ext_resource type="PackedScene" uid="uid://dglpoh63x2lpy" path="res://tgcc/chunk/railway/scene/chunk_railway_curve_4.tscn" id="9_3auto"]
[ext_resource type="Script" uid="uid://c374rv220mvh1" path="res://core/biome_generator/railway_pool.gd" id="9_8tdc7"]
[resource]
script = ExtResource("9_8tdc7")
name = "Railway Pool"
available_railways = Array[PackedScene]([ExtResource("1_86h1y"), ExtResource("3_3auto"), ExtResource("4_i1umq"), ExtResource("5_x44at"), ExtResource("6_vrrkw"), ExtResource("7_l17bw"), ExtResource("8_qcl5o"), ExtResource("8_r0882"), ExtResource("9_3auto")])

View File

@@ -0,0 +1,6 @@
## Resource that lists the wagon scenes available for train composition.
class_name WagonPool
extends Resource
@export var name: String = "New Wagon Pool"
@export var available_wagons: Array[PackedScene] = []

View File

@@ -0,0 +1 @@
uid://c3bgupfogjvv2

View File

@@ -0,0 +1,9 @@
[gd_resource type="Resource" script_class="WagonPool" format=3 uid="uid://bjnytgwt8tmf4"]
[ext_resource type="PackedScene" uid="uid://bny4kv08j8j40" path="res://tgcc/train/wagon.tscn" id="1_t6q5r"]
[ext_resource type="Script" uid="uid://c3bgupfogjvv2" path="res://core/biome_generator/wagon_pool.gd" id="2_x6bmc"]
[resource]
script = ExtResource("2_x6bmc")
name = "Wagon Pool"
available_wagons = Array[PackedScene]([ExtResource("1_t6q5r")])

View File

@@ -1,6 +1,9 @@
class_name EdgeDetectionCompositor class_name EdgeDetectionCompositor
extends CompositorEffect extends CompositorEffect
# --- MODIFICATO: Parametro esportato per l'Inspector ---
@export_range(0.0, 5.0, 0.1) var line_thickness: float = 1.0
var rd: RenderingDevice var rd: RenderingDevice
var shader: RID var shader: RID
var pipeline: RID var pipeline: RID
@@ -78,8 +81,8 @@ func _render_callback(p_effect_callback_type: EffectCallbackType, p_render_data:
var texture_sampler = RDSamplerState.new() var texture_sampler = RDSamplerState.new()
texture_sampler = rd.sampler_create(texture_sampler) texture_sampler = rd.sampler_create(texture_sampler)
# --- MODIFICATO: Inviato il parametro line_thickness nel buffer GPU ---
var parameters := PackedFloat32Array([size.x, size.y, 0.0, 0.0]) var parameters := PackedFloat32Array([size.x, size.y, line_thickness, 0.0])
var inv_proj_mat := p_render_data.get_render_scene_data().get_cam_projection().inverse() var inv_proj_mat := p_render_data.get_render_scene_data().get_cam_projection().inverse()
var inv_proj_mat_array := PackedVector4Array([inv_proj_mat.x, inv_proj_mat.y, inv_proj_mat.z, inv_proj_mat.w]) var inv_proj_mat_array := PackedVector4Array([inv_proj_mat.x, inv_proj_mat.y, inv_proj_mat.z, inv_proj_mat.w])

View File

@@ -4,9 +4,11 @@
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
// --- MODIFICATO: Inserito line_thickness e mantenuto il padding (reserved) ---
layout(set = 0, binding = 0, std430) readonly buffer Params { layout(set = 0, binding = 0, std430) readonly buffer Params {
vec2 raster_size; vec2 raster_size;
vec2 reserved; float line_thickness;
float reserved;
mat4 inv_proj_mat; mat4 inv_proj_mat;
} params; } params;
@@ -89,12 +91,13 @@ void main() {
// Da qui in poi, il codice prosegue normalmente solo per gli altri oggetti // Da qui in poi, il codice prosegue normalmente solo per gli altri oggetti
// UV ofssets // --- MODIFICATO: Aggiunto multiplier "thickness" agli UV offsets ---
float thickness = params.line_thickness;
vec2 uv_offsets[4]; vec2 uv_offsets[4];
uv_offsets[0] = uv_normalized + vec2(0.0, -1.0) * texel_size + offset; uv_offsets[0] = uv_normalized + vec2(0.0, -1.0) * texel_size * thickness + offset;
uv_offsets[1] = uv_normalized + vec2(0.0, 1.0) * texel_size + offset; uv_offsets[1] = uv_normalized + vec2(0.0, 1.0) * texel_size * thickness + offset;
uv_offsets[2] = uv_normalized + vec2(1.0, 0.0) * texel_size + offset; uv_offsets[2] = uv_normalized + vec2(1.0, 0.0) * texel_size * thickness + offset;
uv_offsets[3] = uv_normalized + vec2(-1.0, 0.0) * texel_size + offset; uv_offsets[3] = uv_normalized + vec2(-1.0, 0.0) * texel_size * thickness + offset;
float mask = ceil(raw_roughness); float mask = ceil(raw_roughness);

View File

@@ -32,6 +32,7 @@ render_priority = 0
shader = ExtResource("2_r4tfj") shader = ExtResource("2_r4tfj")
shader_parameter/use_red_as_alpha = true shader_parameter/use_red_as_alpha = true
shader_parameter/fog_color = Color(0.8, 0.85, 0.9, 0.5) shader_parameter/fog_color = Color(0.8, 0.85, 0.9, 0.5)
shader_parameter/fog_density = 0.25
shader_parameter/scroll_speed = Vector2(0.05, 0.01) shader_parameter/scroll_speed = Vector2(0.05, 0.01)
shader_parameter/texture_scale = Vector2(1, 1) shader_parameter/texture_scale = Vector2(1, 1)
shader_parameter/edge_softness_y = 0.2 shader_parameter/edge_softness_y = 0.2
@@ -66,12 +67,13 @@ grad_intensity_morning = 0.05
grad_intensity_afternoon = 0.1 grad_intensity_afternoon = 0.1
grad_intensity_night = 0.5 grad_intensity_night = 0.5
fog_color_morning = Color(0.7490196, 0.8509804, 0.9490196, 1) fog_color_morning = Color(0.7490196, 0.8509804, 0.9490196, 1)
fog_color_afternoon = Color(0.9647059, 0.5882353, 0.7607843, 1) fog_color_afternoon = Color(0.9823975, 0.8034449, 0.8778439, 1)
fog_color_night = Color(0.14901961, 0.101960786, 0.2509804, 1) fog_color_night = Color(0.38409987, 0.28720453, 0.5907528, 1)
fog_density_morning = 0.01 fog_density_morning = 0.01
fog_density_afternoon = 0.02 fog_density_afternoon = 0.02
glow_morning = 0.4 glow_morning = 0.4
glow_night = 0.6 glow_night = 0.8
enable_fog = true
material_fog = SubResource("ShaderMaterial_b5atu") material_fog = SubResource("ShaderMaterial_b5atu")
material_drops = SubResource("StandardMaterial3D_r4tfj") material_drops = SubResource("StandardMaterial3D_r4tfj")
material_clouds = SubResource("ShaderMaterial_ruhh7") material_clouds = SubResource("ShaderMaterial_ruhh7")
@@ -80,7 +82,7 @@ lightning_min = 2
lightning_max = 4 lightning_max = 4
lightning_scale_min = 2.0 lightning_scale_min = 2.0
lightning_scale_max = 5.0 lightning_scale_max = 5.0
godray_max_rain = 60 godray_max_rain = 30
godray_spawn_radius = 100.0 godray_spawn_radius = 100.0
godray_spawn_offset = Vector3(20, 80, 20) godray_spawn_offset = Vector3(20, 80, 20)
godray_rotation_degrees = Vector3(50, 30, 0) godray_rotation_degrees = Vector3(50, 30, 0)
@@ -261,6 +263,7 @@ shader = ExtResource("2_r4tfj")
shader_parameter/fog_noise = ExtResource("11_tuauy") shader_parameter/fog_noise = ExtResource("11_tuauy")
shader_parameter/use_red_as_alpha = true shader_parameter/use_red_as_alpha = true
shader_parameter/fog_color = Color(0.8, 0.8509804, 0.9019608, 0.2509804) shader_parameter/fog_color = Color(0.8, 0.8509804, 0.9019608, 0.2509804)
shader_parameter/fog_density = 0.25
shader_parameter/scroll_speed = Vector2(0, 0.01) shader_parameter/scroll_speed = Vector2(0, 0.01)
shader_parameter/texture_scale = Vector2(1, 1) shader_parameter/texture_scale = Vector2(1, 1)
shader_parameter/edge_softness_y = 0.16400000779 shader_parameter/edge_softness_y = 0.16400000779
@@ -268,7 +271,7 @@ shader_parameter/edge_softness_x = 0.5
shader_parameter/night_intensity = 0.0 shader_parameter/night_intensity = 0.0
shader_parameter/sun_color = Color(1, 1, 1, 1) 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") script = ExtResource("1_wecen")
environment_config = SubResource("Resource_r4tfj") environment_config = SubResource("Resource_r4tfj")
particles_wind = NodePath("Particles_Wind") particles_wind = NodePath("Particles_Wind")
@@ -279,6 +282,7 @@ godray = ExtResource("5_411rw")
environment_dust = NodePath("EnvironmentDust") environment_dust = NodePath("EnvironmentDust")
blur = NodePath("Blur") blur = NodePath("Blur")
environment_shadows = NodePath("EnvironmentCloudsShadows") environment_shadows = NodePath("EnvironmentCloudsShadows")
fog = NodePath("Fog")
[node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133] [node name="Particles_Fireflies" type="GPUParticles3D" parent="." unique_id=947538133]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2, 0)
@@ -343,11 +347,11 @@ surface_material_override/0 = SubResource("ShaderMaterial_oqt1s")
[node name="Fog" type="Node3D" parent="." unique_id=1626352238] [node name="Fog" type="Node3D" parent="." unique_id=1626352238]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Fog" unique_id=96635311] [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") mesh = SubResource("QuadMesh_yn8v8")
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7") surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Fog" unique_id=10121049] [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") mesh = SubResource("QuadMesh_yn8v8")
surface_material_override/0 = SubResource("ShaderMaterial_sxgg7") surface_material_override/0 = SubResource("ShaderMaterial_sxgg7")

View File

@@ -3,7 +3,7 @@ extends Node3D
const NOISE_TEXTURE: Texture2D = preload("res://core/daynight/noise.tres") const NOISE_TEXTURE: Texture2D = preload("res://core/daynight/noise.tres")
const WEATHER_SHADER: Material = preload("res://core/daynight/weather_overlay.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 = 32 #how many update of the environment (apply materials) will be done per frame
@export var environment_config: EnvironmentConfig @export var environment_config: EnvironmentConfig
@@ -20,6 +20,7 @@ const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plai
@export var environment_dust: ColorRect @export var environment_dust: ColorRect
@export var blur: ColorRect @export var blur: ColorRect
@export var environment_shadows: MeshInstance3D @export var environment_shadows: MeshInstance3D
@export var fog: Node3D
@export_group("Sound") @export_group("Sound")
@export var thunder_sounds: Array[AudioStream] @export var thunder_sounds: Array[AudioStream]
@@ -28,19 +29,18 @@ const WEATHER_PLAIN_SHADER: Material = preload("res://core/daynight/weather_plai
#environment nodes #environment nodes
@onready var sun: DirectionalLight3D = $"../DirectionalLight3D" @onready var sun: DirectionalLight3D = $"../DirectionalLight3D"
@onready var environment: WorldEnvironment = $"../WorldEnvironment" @onready var environment: WorldEnvironment = $"../WorldEnvironment"
@onready var fog_node: Node3D = $Fog
var day_night_controller: DayNightController var day_night_controller: DayNightController
var weather_controller: WeatherController var weather_controller: WeatherController
var day_tween: Tween var day_tween: Tween
var day_time: float = 0.0 var day_time: float = 0.0
var pending_environment_nodes: Dictionary = {}
func _ready() -> void: func _ready() -> void:
#connect shader when new node is added #connect shader when new node is added
get_tree().node_added.connect(_on_tree_node_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 #set noise texture 2d to materials in special group
ApplyWindNoiseToMaterials() ApplyWindNoiseToMaterials()
@@ -64,6 +64,7 @@ func _ready() -> void:
godray, godray,
environment_dust, environment_dust,
blur, blur,
fog,
environment_shadows, environment_shadows,
sun, sun,
environment, environment,
@@ -76,9 +77,53 @@ func _ready() -> void:
weather_controller.name = "WeatherController" weather_controller.name = "WeatherController"
add_child(weather_controller) add_child(weather_controller)
func _process(_delta: float) -> void:
_process_pending_environment_nodes()
func flush_pending_environment_nodes() -> void:
_process_pending_environment_nodes(-1)
func _on_tree_node_added(node: Node) -> void: 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"): 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(max_nodes: int = DYNAMIC_ENVIRONMENT_UPDATES_PER_FRAME) -> void:
var processed = 0
for node_id in pending_environment_nodes.keys():
if max_nodes >= 0 and processed >= max_nodes:
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: func _apply_dynamic_environment_materials(node: Node) -> void:
if not is_instance_valid(node): if not is_instance_valid(node):
@@ -90,8 +135,8 @@ func _apply_dynamic_environment_materials(node: Node) -> void:
if node.is_in_group("weather_node"): if node.is_in_group("weather_node"):
_apply_weather_overlay_to_node(node, WEATHER_SHADER) _apply_weather_overlay_to_node(node, WEATHER_SHADER)
if node.is_in_group("weather_vegetables_node"): if _should_clear_weather_overlay(node):
_apply_weather_overlay_to_node(node, WEATHER_PLAIN_SHADER) _clear_weather_overlay_from_node(node)
func ApplyWindNoiseToMaterials(): func ApplyWindNoiseToMaterials():
for node in get_tree().get_nodes_in_group("wind_node"): for node in get_tree().get_nodes_in_group("wind_node"):
@@ -117,15 +162,58 @@ func ApplyWeatherShaderToMaterials():
_apply_weather_overlay_to_node(node, WEATHER_SHADER) _apply_weather_overlay_to_node(node, WEATHER_SHADER)
for node in get_tree().get_nodes_in_group("weather_vegetables_node"): for node in get_tree().get_nodes_in_group("weather_vegetables_node"):
_apply_weather_overlay_to_node(node, WEATHER_PLAIN_SHADER) if _should_clear_weather_overlay(node):
_clear_weather_overlay_from_node(node)
func _apply_weather_overlay_to_node(node: Node, material: Material) -> void: func _apply_weather_overlay_to_node(node: Node, material: Material) -> void:
if _should_clear_weather_overlay(node):
_clear_weather_overlay_from_node(node)
return
if node is GeometryInstance3D: if node is GeometryInstance3D:
node.material_overlay = material if _geometry_uses_alpha_texture(node):
node.material_overlay = null
else:
node.material_overlay = material
for child in node.get_children(): for child in node.get_children():
_apply_weather_overlay_to_node(child, material) _apply_weather_overlay_to_node(child, material)
func _clear_weather_overlay_from_node(node: Node) -> void:
if node is GeometryInstance3D:
node.material_overlay = null
for child in node.get_children():
_clear_weather_overlay_from_node(child)
func _geometry_uses_alpha_texture(node: GeometryInstance3D) -> bool:
var material_override := node.material_override as ShaderMaterial
if _shader_material_uses_alpha_texture(material_override):
return true
if node is MeshInstance3D:
for surface_index in node.get_surface_override_material_count():
var surface_material := node.get_surface_override_material(surface_index) as ShaderMaterial
if _shader_material_uses_alpha_texture(surface_material):
return true
if node.mesh:
for surface_index in node.mesh.get_surface_count():
var mesh_material := node.mesh.surface_get_material(surface_index) as ShaderMaterial
if _shader_material_uses_alpha_texture(mesh_material):
return true
return false
func _shader_material_uses_alpha_texture(material: ShaderMaterial) -> bool:
if material == null or material.shader == null:
return false
return material.shader.code.find("alpha_texture") != -1
func _should_clear_weather_overlay(node: Node) -> bool:
return node.is_in_group("weather_vegetables_node")
func select_day_time(normalized_time: float) -> void: func select_day_time(normalized_time: float) -> void:
#set show_day_time_debug = true to show debug on screen #set show_day_time_debug = true to show debug on screen
#normalized_time is a value between 0 and 1; the time of the day is calculate as "normalized_time" * 1440; day_time is the step to pass from sunrise, to day, to sunset, to night #normalized_time is a value between 0 and 1; the time of the day is calculate as "normalized_time" * 1440; day_time is the step to pass from sunrise, to day, to sunset, to night
@@ -160,7 +248,3 @@ func select_day_time(normalized_time: float) -> void:
if weather_controller: if weather_controller:
weather_controller.day_time = day_time weather_controller.day_time = day_time
func toggle_fog(value: bool) -> void:
if fog_node:
fog_node.visible = value

View File

@@ -56,7 +56,7 @@ void fragment() {
} else { } else {
vec2 projected_xz = world_pos.xz + (world_pos.y * sun_angle); vec2 projected_xz = world_pos.xz + (world_pos.y * sun_angle);
vec2 uv = projected_xz * cloud_scale; vec2 uv = projected_xz * cloud_scale;
uv += TIME * cloud_speed * direction; uv -= TIME * cloud_speed * direction;
float n = texture(noise_texture, uv).r; float n = texture(noise_texture, uv).r;
@@ -67,7 +67,6 @@ void fragment() {
float is_center = step(center_sharpness, internal_n); float is_center = step(center_sharpness, internal_n);
ALBEDO = shadow_color; ALBEDO = shadow_color;
ALPHA = mix(opacity_edge, opacity_center, is_center) * final_fade; ALPHA = mix(opacity_edge, opacity_center, is_center) * final_fade;
} }
} }

View File

@@ -1,7 +1,7 @@
[gd_resource type="ShaderMaterial" format=3 uid="uid://cknq8qhom7ral"] [gd_resource type="ShaderMaterial" format=3 uid="uid://cknq8qhom7ral"]
[ext_resource type="Shader" uid="uid://c0gopfoe0ij8g" path="res://Shaders/Shadow_postProcess.gdshader" id="1_23efu"] [ext_resource type="Shader" uid="uid://b5wa82soyhsqm" path="res://core/daynight/environment_shadows.gdshader" id="1_23efu"]
[ext_resource type="FastNoiseLite" uid="uid://c0mtwrkptjcuw" path="res://Assets/Textures/Noise_Clouds.tres" id="2_n0ip8"] [ext_resource type="FastNoiseLite" uid="uid://c0mtwrkptjcuw" path="res://core/daynight/environment_shadows_noise_clouds.tres" id="2_n0ip8"]
[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_5lko7"] [sub_resource type="NoiseTexture2D" id="NoiseTexture2D_5lko7"]
noise = ExtResource("2_n0ip8") noise = ExtResource("2_n0ip8")

View File

@@ -7,6 +7,7 @@ uniform bool use_red_as_alpha = true;
group_uniforms Settings; group_uniforms Settings;
uniform vec4 fog_color : source_color = vec4(0.8, 0.85, 0.9, 0.5); uniform vec4 fog_color : source_color = vec4(0.8, 0.85, 0.9, 0.5);
uniform float fog_density : hint_range(0.0, 1.0) = 0.25;
uniform vec2 scroll_speed = vec2(0.05, 0.01); uniform vec2 scroll_speed = vec2(0.05, 0.01);
uniform vec2 texture_scale = vec2(1.0, 1.0); uniform vec2 texture_scale = vec2(1.0, 1.0);
@@ -36,5 +37,5 @@ void fragment() {
vec3 dark_fog = tinted_fog * 0.5; vec3 dark_fog = tinted_fog * 0.5;
ALBEDO = mix(tinted_fog, dark_fog, night_intensity); ALBEDO = mix(tinted_fog, dark_fog, night_intensity);
ALPHA = fog_color.a * noise_alpha * edge_mask; ALPHA = fog_color.a * fog_density * noise_alpha * edge_mask;
} }

View File

@@ -1,6 +1,6 @@
[gd_resource type="ShaderMaterial" format=3 uid="uid://cwbxvmtih5wsc"] [gd_resource type="ShaderMaterial" format=3 uid="uid://cwbxvmtih5wsc"]
[ext_resource type="Shader" uid="uid://dkmdtejrbks8n" path="res://Shaders/godrays.gdshader" id="1_pbkwa"] [ext_resource type="Shader" uid="uid://caavljcth87so" path="res://core/daynight/godrays.gdshader" id="1_pbkwa"]
[sub_resource type="FastNoiseLite" id="FastNoiseLite_xa3jw"] [sub_resource type="FastNoiseLite" id="FastNoiseLite_xa3jw"]
noise_type = 3 noise_type = 3

View File

@@ -8,10 +8,12 @@ global uniform float global_wind_speed;
global uniform float global_wind_strength; global uniform float global_wind_strength;
global uniform vec2 global_wind_direction; global uniform vec2 global_wind_direction;
//global uniform sampler2D global_wind_noise : filter_linear_mipmap; //global uniform sampler2D global_wind_noise : filter_linear_mipmap;
global uniform float global_snow_start_time; global uniform float global_snow_start_time = -1.0;
global uniform float global_snow_accumulation_speed; global uniform float global_snow_accumulation_speed = 0.005;
global uniform float global_snow_melt_time; global uniform float global_snow_melt_time = -1.0;
global uniform float global_snow_melt_speed; global uniform float global_snow_melt_speed = 0.1;
global uniform float global_snow_amount = 0.0;
global uniform float global_rain_intensity;
// --- PARAMETRI ESTETICI --- // --- PARAMETRI ESTETICI ---
uniform bool billboard_enabled = true; uniform bool billboard_enabled = true;
@@ -31,6 +33,8 @@ uniform vec4 variance_color : source_color = vec4(0.3, 0.5, 0.2, 1.0); // Colore
uniform float variance_intensity : hint_range(0.0, 1.0) = 0.4; // Quanto si vedono le chiazze uniform float variance_intensity : hint_range(0.0, 1.0) = 0.4; // Quanto si vedono le chiazze
uniform vec4 snow_color : source_color = vec4(0.85, 0.9, 0.95, 1.0); uniform vec4 snow_color : source_color = vec4(0.85, 0.9, 0.95, 1.0);
uniform float snow_visibility : hint_range(0.0, 3.0) = 1.0;
uniform float snow_coverage : hint_range(0.05, 1.0) = 0.35;
// --- CONTROLLO GRADIENTE E RANDOM --- // --- CONTROLLO GRADIENTE E RANDOM ---
uniform float height_min = 0.0; uniform float height_min = 0.0;
@@ -41,6 +45,7 @@ uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
uniform float random_mix : hint_range(0.0, 1.0) = 0.3; uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6; uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25;
varying vec3 v_final_color; varying vec3 v_final_color;
varying float v_shade_factor; varying float v_shade_factor;
@@ -52,6 +57,21 @@ float hash(vec3 p) {
return fract((p.x + p.y) * p.z); return fract((p.x + p.y) * p.z);
} }
float get_snow_progress() {
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
snow_progress = max(snow_progress, timed_progress);
}
if (global_snow_melt_time >= 0.0) {
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
snow_progress = min(snow_progress, 1.0 - melt);
}
return snow_progress;
}
void vertex() { void vertex() {
vec3 instance_pos = MODEL_MATRIX[3].xyz; vec3 instance_pos = MODEL_MATRIX[3].xyz;
v_world_pos = instance_pos; // Salviamo la posizione dell'istanza v_world_pos = instance_pos; // Salviamo la posizione dell'istanza
@@ -113,30 +133,28 @@ void fragment() {
// Applichiamo la variazione al colore finale dell'erba // Applichiamo la variazione al colore finale dell'erba
vec3 varied_grass_color = mix(v_final_color, variance_color.rgb, noise_sample * variance_intensity); vec3 varied_grass_color = mix(v_final_color, variance_color.rgb, noise_sample * variance_intensity);
float snow_amount = 0.0; float snow_amount = smoothstep(0.0, 1.0, get_snow_progress());
if (global_snow_start_time >= 0.0) {
snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
}
if (global_snow_melt_time >= 0.0) {
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
snow_amount *= (1.0 - melt);
}
float top_mask = 1.0 - shifted_uv.y; float top_mask = 1.0 - shifted_uv.y;
float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask); float snow_start = 1.0 - clamp(snow_coverage, 0.05, 1.0);
float snow_mask = smoothstep(snow_start, 1.0, top_mask) * snow_amount * snow_visibility;
snow_mask *= step(0.01, snow_amount); snow_mask *= step(0.01, snow_amount);
snow_mask = clamp(snow_mask, 0.0, 1.0);
vec3 dark_snow = snow_color.rgb * (1.0 - shadow_intensity); vec3 dark_snow = snow_color.rgb * (1.0 - shadow_intensity);
vec3 shaded_snow = mix(dark_snow, snow_color.rgb, v_shade_factor); vec3 shaded_snow = mix(dark_snow, snow_color.rgb, v_shade_factor);
// Mescoliamo il colore variato con la neve // Mescoliamo il colore variato con la neve
vec3 final_albedo = mix(varied_grass_color, shaded_snow, snow_mask); vec3 final_albedo = mix(varied_grass_color, shaded_snow, snow_mask);
float rain_int = clamp(global_rain_intensity, 0.0, 1.0);
final_albedo *= mix(1.0, 1.0 - wetness_darkening, rain_int);
float final_roughness = mix(0.02, 0.005, rain_int);
ALBEDO = final_albedo; ALBEDO = final_albedo;
ALPHA = tex.r * opacity; ALPHA = tex.r * opacity;
ALPHA_SCISSOR_THRESHOLD = 0.5; ALPHA_SCISSOR_THRESHOLD = 0.5;
ROUGHNESS = 0.02; ROUGHNESS = final_roughness;
} }
void light() { void light() {

View File

@@ -118,7 +118,7 @@ void sky() {
//Clouds //Clouds
vec2 cloud_uv = EYEDIR.xz / (EYEDIR.y + 0.5); vec2 cloud_uv = EYEDIR.xz / (EYEDIR.y + 0.5);
cloud_uv = cloud_uv * cloud_scale + (TIME * cloud_direction * cloud_speed); cloud_uv = cloud_uv * cloud_scale - (TIME * cloud_direction * cloud_speed);
float noise = texture(cloud_noise, cloud_uv).r; float noise = texture(cloud_noise, cloud_uv).r;
float cloud_alpha = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_softness, noise); float cloud_alpha = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_softness, noise);
float color_gradient = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_thickness, noise); float color_gradient = smoothstep(cloud_threshold, cloud_threshold + cloud_edge_thickness, noise);

View File

@@ -20,17 +20,14 @@ const SNOW_CAP_SHADER: Shader = preload("res://core/daynight/snow_cap.gdshader")
var _mesh_instance: MeshInstance3D var _mesh_instance: MeshInstance3D
func _ready() -> void: func _ready() -> void:
add_to_group("weather_overlay_ignore") add_to_group("weather_overlay_ignore")
_ensure_mesh_instance() _ensure_mesh_instance()
_rebuild() _rebuild()
func rebuild() -> void: func rebuild() -> void:
_rebuild() _rebuild()
func _ensure_mesh_instance() -> void: func _ensure_mesh_instance() -> void:
_mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D _mesh_instance = get_node_or_null("SnowCapMesh") as MeshInstance3D
if _mesh_instance != null: if _mesh_instance != null:
@@ -41,7 +38,6 @@ func _ensure_mesh_instance() -> void:
_mesh_instance.add_to_group("weather_overlay_ignore") _mesh_instance.add_to_group("weather_overlay_ignore")
add_child(_mesh_instance) add_child(_mesh_instance)
func _rebuild() -> void: func _rebuild() -> void:
var cap_width: float = 0.0 var cap_width: float = 0.0
var cap_depth: 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.material_override = _build_material(cap_width, cap_depth)
_mesh_instance.visible = true _mesh_instance.visible = true
func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial: func _build_material(cap_width: float, cap_depth: float) -> ShaderMaterial:
var material := ShaderMaterial.new() var material := ShaderMaterial.new()
material.shader = SNOW_CAP_SHADER 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) material.set_shader_parameter("half_depth", cap_depth * 0.5)
return material return material
func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB: func _get_target_aabb(target_mesh: MeshInstance3D) -> AABB:
var points: Array[Vector3] = [] var points: Array[Vector3] = []
for point in _get_aabb_points(target_mesh.get_aabb()): 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) merged = merged.expand(point)
return merged return merged
func _get_aabb_points(aabb: AABB) -> Array[Vector3]: func _get_aabb_points(aabb: AABB) -> Array[Vector3]:
var p: Vector3 = aabb.position var p: Vector3 = aabb.position
var s: Vector3 = aabb.size var s: Vector3 = aabb.size

View File

@@ -2,10 +2,12 @@ shader_type spatial;
render_mode blend_mix, cull_back, depth_draw_opaque; render_mode blend_mix, cull_back, depth_draw_opaque;
global uniform float global_snow_start_time = -1.0; global uniform float global_snow_start_time = -1.0;
global uniform float global_snow_accumulation_speed = 0.1; global uniform float global_snow_accumulation_speed = 0.005;
global uniform float global_snow_melt_time = -1.0; global uniform float global_snow_melt_time = -1.0;
global uniform float global_snow_melt_speed = 0.1; global uniform float global_snow_melt_speed = 0.1;
global uniform float global_snow_amount = 0.0;
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0); global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
const float SNOW_VISUAL_RESPONSE = 0.55;
uniform float max_height : hint_range(0.02, 1.0) = 0.2; uniform float max_height : hint_range(0.02, 1.0) = 0.2;
uniform float half_width : hint_range(0.01, 20.0) = 1.0; uniform float half_width : hint_range(0.01, 20.0) = 1.0;
@@ -51,25 +53,30 @@ float fbm(vec2 p) {
} }
float get_snow_amount() { float get_snow_amount() {
float snow_amount = 0.0; float snow_amount = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) { if (global_snow_start_time >= 0.0) {
snow_amount = clamp( float timed_amount = clamp(
(TIME - global_snow_start_time) * global_snow_accumulation_speed, (TIME - global_snow_start_time) * global_snow_accumulation_speed,
0.0, 0.0,
1.0 1.0
); );
snow_amount = max(snow_amount, timed_amount);
} }
if (global_snow_melt_time >= 0.0) { if (global_snow_melt_time >= 0.0) {
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0); float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
snow_amount *= (1.0 - melt); snow_amount = min(snow_amount, 1.0 - melt);
} }
return snow_amount; return snow_amount;
} }
float get_visual_snow_amount(float snow_amount) {
return pow(clamp(snow_amount, 0.0, 1.0), SNOW_VISUAL_RESPONSE);
}
void vertex() { void vertex() {
vec3 base_vertex = VERTEX; vec3 base_vertex = VERTEX;
vec3 world_pos = (MODEL_MATRIX * vec4(base_vertex, 1.0)).xyz; vec3 world_pos = (MODEL_MATRIX * vec4(base_vertex, 1.0)).xyz;
float snow_amount = get_snow_amount(); float snow_amount = get_visual_snow_amount(get_snow_amount());
float noise_val = fbm(world_pos.xz * noise_scale); float noise_val = fbm(world_pos.xz * noise_scale);
float thickness = max_height * snow_amount * mix( float thickness = max_height * snow_amount * mix(
1.0 - noise_strength, 1.0 - noise_strength,

View File

@@ -6,12 +6,12 @@ global uniform vec2 global_wind_direction;
global uniform float global_wind_scale; global uniform float global_wind_scale;
global uniform float global_wind_strength; global uniform float global_wind_strength;
global uniform float global_wind_fade; global uniform float global_wind_fade;
/* global uniform float global_snow_start_time = -1.0;
global uniform float global_snow_start_time; global uniform float global_snow_accumulation_speed = 0.005;
global uniform float global_snow_accumulation_speed; global uniform float global_snow_melt_time = -1.0;
global uniform float global_snow_melt_time; global uniform float global_snow_melt_speed = 0.1;
global uniform float global_snow_melt_speed; global uniform float global_snow_amount = 0.0;
global uniform vec4 global_snow_color;*/ global uniform vec4 global_snow_color;
global uniform float global_rain_intensity; global uniform float global_rain_intensity;
uniform sampler2D wind_noise : filter_linear_mipmap; uniform sampler2D wind_noise : filter_linear_mipmap;
@@ -31,6 +31,7 @@ uniform float light_steps : hint_range(1.0, 10.0) = 4.0;
uniform float random_mix : hint_range(0.0, 1.0) = 0.3; uniform float random_mix : hint_range(0.0, 1.0) = 0.3;
uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6; uniform float cast_shadow_strength : hint_range(0.0, 1.0) = 0.6;
uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25; uniform float wetness_darkening : hint_range(0.0, 0.5) = 0.25;
uniform float snow_visibility : hint_range(0.0, 1.0) = 1.0;
varying vec3 v_final_color; varying vec3 v_final_color;
varying float v_shade_factor; varying float v_shade_factor;
@@ -41,6 +42,21 @@ float hash(vec3 p) {
return fract((p.x + p.y) * p.z); return fract((p.x + p.y) * p.z);
} }
float get_snow_progress() {
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
snow_progress = max(snow_progress, timed_progress);
}
if (global_snow_melt_time >= 0.0) {
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
snow_progress = min(snow_progress, 1.0 - melt);
}
return snow_progress;
}
void vertex() { void vertex() {
vec3 instance_pos = MODEL_MATRIX[3].xyz; vec3 instance_pos = MODEL_MATRIX[3].xyz;
@@ -88,24 +104,16 @@ void fragment() {
vec2 shifted_uv = UV + texture_offset; vec2 shifted_uv = UV + texture_offset;
vec4 tex = texture(alpha_texture, shifted_uv); vec4 tex = texture(alpha_texture, shifted_uv);
//// Snow accumulation // Snow accumulation
//float snow_amount = 0.0; float snow_amount = pow(get_snow_progress(), 0.55);
//if (global_snow_start_time >= 0.0) {
//snow_amount = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
//}
//if (global_snow_melt_time >= 0.0) {
//float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
//snow_amount *= (1.0 - melt);
//}
//
//float top_mask = 1.0 - shifted_uv.y;
//float snow_mask = smoothstep(1.0 - snow_amount, 1.2 - snow_amount, top_mask);
//snow_mask *= step(0.01, snow_amount);
//vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity); float top_mask = 1.0 - shifted_uv.y;
//vec3 shaded_snow = mix(dark_snow, global_snow_color.rgb, v_shade_factor); float snow_mask = smoothstep(1.0 - snow_amount * 1.35, 1.08 - snow_amount * 1.35, top_mask) * snow_visibility;
//vec3 final_albedo = mix(v_final_color, shaded_snow, snow_mask); snow_mask *= step(0.01, snow_amount);
vec3 final_albedo = v_final_color;
vec3 dark_snow = global_snow_color.rgb * (1.0 - shadow_intensity);
vec3 shaded_snow = mix(dark_snow, global_snow_color.rgb, v_shade_factor);
vec3 final_albedo = mix(v_final_color, shaded_snow, snow_mask);
// Rain wetness: darken and make shinier // Rain wetness: darken and make shinier
float rain_int = clamp(global_rain_intensity, 0.0, 1.0); float rain_int = clamp(global_rain_intensity, 0.0, 1.0);

View File

@@ -3,6 +3,12 @@ render_mode blend_mix, depth_draw_always;
global uniform float global_rain_intensity; global uniform float global_rain_intensity;
global uniform vec4 global_water_color = vec4(0.285, 0.534, 0.487, 1.0); global uniform vec4 global_water_color = vec4(0.285, 0.534, 0.487, 1.0);
global uniform float global_snow_start_time = -1.0;
global uniform float global_snow_accumulation_speed = 0.005;
global uniform float global_snow_melt_time = -1.0;
global uniform float global_snow_melt_speed = 0.1;
global uniform float global_snow_amount = 0.0;
global uniform vec4 global_snow_color = vec4(0.92, 0.96, 1.0, 1.0);
//Water color //Water color
uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0); uniform vec4 deep_water_color : source_color = vec4(0.0, 0.1, 0.2, 1.0);
@@ -29,6 +35,21 @@ uniform sampler2D depth_texture : hint_depth_texture, filter_linear_mipmap;
varying vec2 world_pos_xz; varying vec2 world_pos_xz;
varying vec2 local_uv; varying vec2 local_uv;
float get_snow_progress() {
float snow_progress = clamp(global_snow_amount, 0.0, 1.0);
if (global_snow_start_time >= 0.0) {
float timed_progress = clamp((TIME - global_snow_start_time) * global_snow_accumulation_speed, 0.0, 1.0);
snow_progress = max(snow_progress, timed_progress);
}
if (global_snow_melt_time >= 0.0) {
float melt = clamp((TIME - global_snow_melt_time) * global_snow_melt_speed, 0.0, 1.0);
snow_progress = min(snow_progress, 1.0 - melt);
}
return snow_progress;
}
void vertex() { void vertex() {
world_pos_xz = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz; world_pos_xz = (MODEL_MATRIX * vec4(VERTEX, 1.0)).xz;
local_uv = UV; local_uv = UV;
@@ -82,8 +103,15 @@ void fragment() {
float is_sky = step(ref_depth_raw, 0.00001); // Protezione anti-cielo float is_sky = step(ref_depth_raw, 0.00001); // Protezione anti-cielo
reflection_mask *= (1.0 - is_sky); reflection_mask *= (1.0 - is_sky);
vec3 final_rgb = mix(base_water.rgb, screen_ref, reflection_strength * reflection_mask); float snow_progress = get_snow_progress();
float active_snowfall = step(0.0, global_snow_start_time) * (1.0 - step(0.0, global_snow_melt_time));
float reflection_snow_damping = max(smoothstep(0.0, 0.08, snow_progress), active_snowfall * 0.75);
float effective_reflection_strength = reflection_strength * (1.0 - reflection_snow_damping * 0.85);
vec3 final_rgb = mix(base_water.rgb, screen_ref, effective_reflection_strength * reflection_mask);
final_rgb = mix(final_rgb, ripple_color.rgb, ring * ripple_color.a); final_rgb = mix(final_rgb, ripple_color.rgb, ring * ripple_color.a);
float water_snow_amount = smoothstep(0.15, 1.0, snow_progress) * 0.18;
final_rgb = mix(final_rgb, global_snow_color.rgb, water_snow_amount);
ALBEDO = final_rgb; ALBEDO = final_rgb;

Some files were not shown because too many files have changed in this diff Show More