mirror of
https://github.com/Steffo99/pineapple-surf.git
synced 2024-11-24 16:54:19 +00:00
Refactor splashing
This commit is contained in:
parent
18c44c2438
commit
1fb0f5542e
11 changed files with 89 additions and 62 deletions
5
island/CanSplash.gd
Normal file
5
island/CanSplash.gd
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
extends Node3D
|
||||||
|
class_name CanSplash
|
||||||
|
|
||||||
|
|
||||||
|
signal splashed()
|
10
island/CanSplash.tscn
Normal file
10
island/CanSplash.tscn
Normal file
|
@ -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")
|
|
@ -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://dh5blytk6vmdu" path="res://island/Sea.tscn" id="1_e0hpm"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b5i1sqd88wlle" path="res://player/Player.tscn" id="3_5378m"]
|
[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://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://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://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"]
|
[sub_resource type="Gradient" id="Gradient_shcpx"]
|
||||||
interpolation_mode = 2
|
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)
|
light_color = Color(1, 0.698039, 0.470588, 1)
|
||||||
|
|
||||||
[node name="Player" parent="." instance=ExtResource("3_5378m")]
|
[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="CropTiles" type="Node3D" parent="."]
|
||||||
|
|
||||||
[node name="Leafpile" parent="CropTiles" instance=ExtResource("9_472aa")]
|
[node name="Leafpile" parent="CropTiles" instance=ExtResource("9_472aa")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3, 3, 3)
|
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="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)
|
|
||||||
|
|
17
island/Sea.gd
Normal file
17
island/Sea.gd
Normal file
|
@ -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)
|
|
@ -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="Script" path="res://island/Sea.gd" id="1_45vpg"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bdoifsf6k0qb8" path="res://assets/water_tile.png" id="2_n5in5"]
|
[ext_resource type="PackedScene" uid="uid://c7lblmilr3gob" path="res://island/SeaMesh.tscn" id="1_ej5r1"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_3uyyi"]
|
[sub_resource type="WorldBoundaryShape3D" id="WorldBoundaryShape3D_hpkdw"]
|
||||||
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="PlaneMesh" id="PlaneMesh_4ibso"]
|
[node name="Sea" type="Node3D"]
|
||||||
material = SubResource("ShaderMaterial_3uyyi")
|
script = ExtResource("1_45vpg")
|
||||||
size = Vector2(1000, 1000)
|
|
||||||
|
|
||||||
[node name="Sea" type="MeshInstance3D"]
|
[node name="SeaMesh" parent="." instance=ExtResource("1_ej5r1")]
|
||||||
mesh = SubResource("PlaneMesh_4ibso")
|
|
||||||
skeleton = NodePath("../..")
|
[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"]
|
||||||
|
|
20
island/SeaMesh.tscn
Normal file
20
island/SeaMesh.tscn
Normal file
|
@ -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("../..")
|
|
@ -15,6 +15,8 @@ const AIR_ACCELERATE = 100 # Hu/39.97
|
||||||
@onready var vport: SubViewport = head.get_node("Viewport/CameraViewportContainer/GameViewport")
|
@onready var vport: SubViewport = head.get_node("Viewport/CameraViewportContainer/GameViewport")
|
||||||
@onready var gun_vport: SubViewport = $HUD/SubViewportContainer/SubViewport
|
@onready var gun_vport: SubViewport = $HUD/SubViewportContainer/SubViewport
|
||||||
@onready var aim_raycast: RayCast3D = head.get_node("RayCast3D")
|
@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 OnHand = head.get_node("OnHand")
|
||||||
@onready var active_weapon: BaseWeapon:
|
@onready var active_weapon: BaseWeapon:
|
||||||
|
@ -152,3 +154,9 @@ func _input(event):
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
var vec = event.relative
|
var vec = event.relative
|
||||||
self.mouse_movement = Vector2(vec.y / 10, vec.x / 10)
|
self.mouse_movement = Vector2(vec.y / 10, vec.x / 10)
|
||||||
|
|
||||||
|
|
||||||
|
func respawn():
|
||||||
|
position = initial_position
|
||||||
|
rotation = initial_rotation
|
||||||
|
velocity = Vector3.ZERO
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
[ext_resource type="Script" path="res://player/OnHand.gd" id="3_3rcjl"]
|
[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="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="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"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aqp8x"]
|
||||||
metallic_specular = 0.0
|
metallic_specular = 0.0
|
||||||
|
@ -263,5 +263,6 @@ metadata/_edit_lock_ = true
|
||||||
|
|
||||||
[node name="RigidDynamicBody3D" type="RigidBody3D" parent="."]
|
[node name="RigidDynamicBody3D" type="RigidBody3D" parent="."]
|
||||||
|
|
||||||
[node name="SplashController" parent="." instance=ExtResource("6_hf66s")]
|
[node name="CanSplash" parent="." instance=ExtResource("6_la1ga")]
|
||||||
target_path = NodePath("..")
|
|
||||||
|
[connection signal="splashed" from="CanSplash" to="." method="respawn"]
|
||||||
|
|
|
@ -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()
|
|
|
@ -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")
|
|
|
@ -15,6 +15,11 @@ _global_script_classes=[{
|
||||||
"path": "res://player/onhand/BaseWeapon.gd"
|
"path": "res://player/onhand/BaseWeapon.gd"
|
||||||
}, {
|
}, {
|
||||||
"base": "Node3D",
|
"base": "Node3D",
|
||||||
|
"class": &"CanSplash",
|
||||||
|
"language": &"GDScript",
|
||||||
|
"path": "res://island/CanSplash.gd"
|
||||||
|
}, {
|
||||||
|
"base": "Node3D",
|
||||||
"class": &"CropTile",
|
"class": &"CropTile",
|
||||||
"language": &"GDScript",
|
"language": &"GDScript",
|
||||||
"path": "res://island/CropTile.gd"
|
"path": "res://island/CropTile.gd"
|
||||||
|
@ -36,6 +41,7 @@ _global_script_classes=[{
|
||||||
}]
|
}]
|
||||||
_global_script_class_icons={
|
_global_script_class_icons={
|
||||||
"BaseWeapon": "",
|
"BaseWeapon": "",
|
||||||
|
"CanSplash": "",
|
||||||
"CropTile": "",
|
"CropTile": "",
|
||||||
"PeaShooter": "",
|
"PeaShooter": "",
|
||||||
"Player": "",
|
"Player": "",
|
||||||
|
|
Loading…
Reference in a new issue