1
Fork 0
mirror of https://github.com/Steffo99/pineapple-surf.git synced 2024-11-25 01:04:18 +00:00

Refactor SplashController

This commit is contained in:
Steffo 2023-01-08 21:46:19 +01:00
parent 0322c74bac
commit 56b59f42d3
Signed by: steffo
GPG key ID: 6965406171929D01
3 changed files with 31 additions and 14 deletions

View file

@ -1,12 +1,11 @@
[gd_scene load_steps=17 format=3 uid="uid://b5i1sqd88wlle"] [gd_scene load_steps=16 format=3 uid="uid://b5i1sqd88wlle"]
[ext_resource type="Script" path="res://player/Player.gd" id="1_rujcr"] [ext_resource type="Script" path="res://player/Player.gd" id="1_rujcr"]
[ext_resource type="Script" path="res://player/Head.gd" id="2_ohlgu"] [ext_resource type="Script" path="res://player/Head.gd" id="2_ohlgu"]
[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="Script" path="res://player/SplashController.gd" id="5_wnbq8"] [ext_resource type="PackedScene" uid="uid://dc147tdie7oem" path="res://player/SplashController.tscn" id="6_hf66s"]
[ext_resource type="AudioStream" uid="uid://xretxahxbqdr" path="res://assets/splash.ogg" id="6_xi537"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aqp8x"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_aqp8x"]
metallic_specular = 0.0 metallic_specular = 0.0
@ -262,8 +261,5 @@ metadata/_edit_lock_ = true
[node name="RigidDynamicBody3D" type="RigidBody3D" parent="."] [node name="RigidDynamicBody3D" type="RigidBody3D" parent="."]
[node name="SplashController" type="Node" parent="."] [node name="SplashController" parent="." instance=ExtResource("6_hf66s")]
script = ExtResource("5_wnbq8") target_path = NodePath("..")
[node name="SplashSound" type="AudioStreamPlayer" parent="SplashController"]
stream = ExtResource("6_xi537")

View file

@ -1,13 +1,24 @@
extends Node extends Node
@onready var player: Node3D = $".." @export_node_path(CharacterBody3D) var target_path: NodePath
@onready var spawn_point: Vector3 = player.position @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 @onready var splash_sound: AudioStreamPlayer = $SplashSound
func _process(_delta): signal splashed()
if player.position.y < 0:
func splash():
splash_sound.play() splash_sound.play()
player.position = spawn_point target.position = spawn_point
player.velocity = Vector3.ZERO target.velocity = Vector3.ZERO
emit_signal("splashed")
func _process(_delta):
if target.position.y < splash_threshold:
splash()

View file

@ -0,0 +1,10 @@
[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")