diff --git a/island/CanSplash.gd b/island/CanSplash.gd new file mode 100644 index 0000000..8e5f1f4 --- /dev/null +++ b/island/CanSplash.gd @@ -0,0 +1,5 @@ +extends Node3D +class_name CanSplash + + +signal splashed() diff --git a/island/CanSplash.tscn b/island/CanSplash.tscn new file mode 100644 index 0000000..803a526 --- /dev/null +++ b/island/CanSplash.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://bj4d3a0jxgvpu"] + +[ext_resource type="Script" path="res://island/CanSplash.gd" id="1_vsqjx"] +[ext_resource type="AudioStream" uid="uid://xretxahxbqdr" path="res://assets/splash.ogg" id="2_y72wi"] + +[node name="CanSplash" type="Node3D"] +script = ExtResource("1_vsqjx") + +[node name="SplashSound" type="AudioStreamPlayer3D" parent="."] +stream = ExtResource("2_y72wi") diff --git a/island/Island.tscn b/island/Island.tscn index da70ab1..de4193e 100644 --- a/island/Island.tscn +++ b/island/Island.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=16 format=3 uid="uid://bg88gc1w1gw5m"] +[gd_scene load_steps=15 format=3 uid="uid://bg88gc1w1gw5m"] [ext_resource type="PackedScene" uid="uid://dh5blytk6vmdu" path="res://island/Sea.tscn" id="1_e0hpm"] [ext_resource type="PackedScene" uid="uid://b5i1sqd88wlle" path="res://player/Player.tscn" id="3_5378m"] @@ -9,7 +9,6 @@ [ext_resource type="PackedScene" uid="uid://boxtb3trgcy8c" path="res://island/PillarMesh.tscn" id="7_grmwj"] [ext_resource type="PackedScene" uid="uid://cwf11kdk7t64k" path="res://island/HoppityMesh.tscn" id="8_5pio0"] [ext_resource type="PackedScene" uid="uid://dutcugv574855" path="res://island/Leafpile.tscn" id="9_472aa"] -[ext_resource type="PackedScene" uid="uid://cm0apcnq0f26s" path="res://island/Seeds.tscn" id="10_l32rj"] [sub_resource type="Gradient" id="Gradient_shcpx"] interpolation_mode = 2 @@ -79,17 +78,14 @@ transform = Transform3D(1, 0, 0, 0, -0.249636, 0.96834, 0, -0.96834, -0.249636, light_color = Color(1, 0.698039, 0.470588, 1) [node name="Player" parent="." instance=ExtResource("3_5378m")] -transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 2.08165e-12, 4.896, 2.08165e-12) +transform = Transform3D(-1, 3.48787e-16, -8.74228e-08, 3.48787e-16, 1, -3.48787e-16, 8.74228e-08, -3.48787e-16, -1, 2.08165e-12, 3.896, 2.08165e-12) [node name="CropTiles" type="Node3D" parent="."] [node name="Leafpile" parent="CropTiles" instance=ExtResource("9_472aa")] transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 3, 3) +[node name="Leafpile2" parent="CropTiles" instance=ExtResource("9_472aa")] +transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4, 3, -4) + [node name="Produce" type="Node3D" parent="."] - -[node name="Seeds" parent="Produce" instance=ExtResource("10_l32rj")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 4, 22) - -[node name="Seeds2" parent="Produce" instance=ExtResource("10_l32rj")] -transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 4, 22) diff --git a/island/Sea.gd b/island/Sea.gd new file mode 100644 index 0000000..7fbadb4 --- /dev/null +++ b/island/Sea.gd @@ -0,0 +1,17 @@ +extends Node3D + + +signal splashed(splasher: CanSplash) + + +func splash(splasher: CanSplash): + var splash_sound = splasher.get_node("SplashSound") + splash_sound.play() + splasher.emit_signal("splashed") + emit_signal("splashed", splasher) + + +func _on_splash_area_body_entered(body: Node3D): + var splashers: Array[Node] = body.find_children("*", "CanSplash", false, false) + for splasher in splashers: + splash(splasher) diff --git a/island/Sea.tscn b/island/Sea.tscn index 4fbc7aa..993c6d0 100644 --- a/island/Sea.tscn +++ b/island/Sea.tscn @@ -1,20 +1,18 @@ -[gd_scene load_steps=5 format=3 uid="uid://dh5blytk6vmdu"] +[gd_scene load_steps=4 format=3 uid="uid://dh5blytk6vmdu"] -[ext_resource type="Shader" path="res://island/Sea.gdshader" id="1_hkdu5"] -[ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="2_n5in5"] +[ext_resource type="Script" path="res://island/Sea.gd" id="1_45vpg"] +[ext_resource type="PackedScene" uid="uid://c7lblmilr3gob" path="res://island/SeaMesh.tscn" id="1_ej5r1"] -[sub_resource type="ShaderMaterial" id="ShaderMaterial_3uyyi"] -render_priority = 0 -shader = ExtResource("1_hkdu5") -shader_parameter/speed_x = 1.0 -shader_parameter/speed_y = 0.1 -shader_parameter/size = 1000.0 -shader_parameter/sea = ExtResource("2_n5in5") +[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_hpkdw"] -[sub_resource type="PlaneMesh" id="PlaneMesh_4ibso"] -material = SubResource("ShaderMaterial_3uyyi") -size = Vector2(1000, 1000) +[node name="Sea" type="Node3D"] +script = ExtResource("1_45vpg") -[node name="Sea" type="MeshInstance3D"] -mesh = SubResource("PlaneMesh_4ibso") -skeleton = NodePath("../..") +[node name="SeaMesh" parent="." instance=ExtResource("1_ej5r1")] + +[node name="SplashArea" type="Area3D" parent="."] + +[node name="Shape" type="CollisionShape3D" parent="SplashArea"] +shape = SubResource("WorldBoundaryShape3D_hpkdw") + +[connection signal="body_entered" from="SplashArea" to="." method="_on_splash_area_body_entered"] diff --git a/island/SeaMesh.tscn b/island/SeaMesh.tscn new file mode 100644 index 0000000..eed8e7d --- /dev/null +++ b/island/SeaMesh.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=5 format=3 uid="uid://c7lblmilr3gob"] + +[ext_resource type="Shader" path="res://island/Sea.gdshader" id="1_tu2de"] +[ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="2_c8qvh"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_3uyyi"] +render_priority = 0 +shader = ExtResource("1_tu2de") +shader_parameter/speed_x = 1.0 +shader_parameter/speed_y = 0.1 +shader_parameter/size = 1000.0 +shader_parameter/sea = ExtResource("2_c8qvh") + +[sub_resource type="PlaneMesh" id="PlaneMesh_4ibso"] +material = SubResource("ShaderMaterial_3uyyi") +size = Vector2(1000, 1000) + +[node name="SeaMesh" type="MeshInstance3D"] +mesh = SubResource("PlaneMesh_4ibso") +skeleton = NodePath("../..") diff --git a/player/Player.gd b/player/Player.gd index 6993d2e..a8982a0 100644 --- a/player/Player.gd +++ b/player/Player.gd @@ -15,6 +15,8 @@ const AIR_ACCELERATE = 100 # Hu/39.97 @onready var vport: SubViewport = head.get_node("Viewport/CameraViewportContainer/GameViewport") @onready var gun_vport: SubViewport = $HUD/SubViewportContainer/SubViewport @onready var aim_raycast: RayCast3D = head.get_node("RayCast3D") +@onready var initial_position: Vector3 = position +@onready var initial_rotation: Vector3 = rotation @onready var OnHand = head.get_node("OnHand") @onready var active_weapon: BaseWeapon: @@ -152,3 +154,9 @@ func _input(event): if event is InputEventMouseMotion: var vec = event.relative self.mouse_movement = Vector2(vec.y / 10, vec.x / 10) + + +func respawn(): + position = initial_position + rotation = initial_rotation + velocity = Vector3.ZERO diff --git a/player/Player.tscn b/player/Player.tscn index bdddee6..09241c8 100644 --- a/player/Player.tscn +++ b/player/Player.tscn @@ -5,7 +5,7 @@ [ext_resource type="Script" path="res://player/OnHand.gd" id="3_3rcjl"] [ext_resource type="Theme" uid="uid://c5a1nyqumj46j" path="res://menu/menu_theme.tres" id="4_d7ru6"] [ext_resource type="Shader" path="res://player/crosshair.gdshader" id="4_dut1p"] -[ext_resource type="PackedScene" uid="uid://dc147tdie7oem" path="res://player/SplashController.tscn" id="6_hf66s"] +[ext_resource type="PackedScene" uid="uid://bj4d3a0jxgvpu" path="res://island/CanSplash.tscn" id="6_la1ga"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aqp8x"] metallic_specular = 0.0 @@ -263,5 +263,6 @@ metadata/_edit_lock_ = true [node name="RigidDynamicBody3D" type="RigidBody3D" parent="."] -[node name="SplashController" parent="." instance=ExtResource("6_hf66s")] -target_path = NodePath("..") +[node name="CanSplash" parent="." instance=ExtResource("6_la1ga")] + +[connection signal="splashed" from="CanSplash" to="." method="respawn"] diff --git a/player/SplashController.gd b/player/SplashController.gd deleted file mode 100644 index 42ad4f4..0000000 --- a/player/SplashController.gd +++ /dev/null @@ -1,24 +0,0 @@ -extends Node - - -@export_node_path(CharacterBody3D) var target_path: NodePath -@export var splash_threshold: float = 0.0 - -@onready var target: CharacterBody3D = get_node(target_path) -@onready var spawn_point: Vector3 = target.position -@onready var splash_sound: AudioStreamPlayer = $SplashSound - - -signal splashed() - - -func splash(): - splash_sound.play() - target.position = spawn_point - target.velocity = Vector3.ZERO - emit_signal("splashed") - - -func _process(_delta): - if target.position.y < splash_threshold: - splash() diff --git a/player/SplashController.tscn b/player/SplashController.tscn deleted file mode 100644 index fcb28c1..0000000 --- a/player/SplashController.tscn +++ /dev/null @@ -1,10 +0,0 @@ -[gd_scene load_steps=3 format=3 uid="uid://dc147tdie7oem"] - -[ext_resource type="Script" path="res://player/SplashController.gd" id="1_m4yh2"] -[ext_resource type="AudioStream" uid="uid://xretxahxbqdr" path="res://assets/splash.ogg" id="2_esng3"] - -[node name="SplashController" type="Node"] -script = ExtResource("1_m4yh2") - -[node name="SplashSound" type="AudioStreamPlayer" parent="."] -stream = ExtResource("2_esng3") diff --git a/project.godot b/project.godot index 146a216..5cf9c91 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,11 @@ _global_script_classes=[{ "path": "res://player/onhand/BaseWeapon.gd" }, { "base": "Node3D", +"class": &"CanSplash", +"language": &"GDScript", +"path": "res://island/CanSplash.gd" +}, { +"base": "Node3D", "class": &"CropTile", "language": &"GDScript", "path": "res://island/CropTile.gd" @@ -36,6 +41,7 @@ _global_script_classes=[{ }] _global_script_class_icons={ "BaseWeapon": "", +"CanSplash": "", "CropTile": "", "PeaShooter": "", "Player": "",