various fixes

This commit is contained in:
Spencer Killen 2022-12-27 13:24:35 -07:00
parent d8dc798a7b
commit a63c8e03e9
Signed by: sjkillen
GPG Key ID: F307025B65C860BA
10 changed files with 73 additions and 21 deletions

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=2]
[gd_scene load_steps=15 format=2]
[ext_resource path="res://assets/meat_creek/side_tunnel_1.glb" type="PackedScene" id=1]
[ext_resource path="res://player/player.tscn" type="PackedScene" id=2]
@ -10,6 +10,8 @@
[ext_resource path="res://assets/meat_creek/StaticBody.tscn" type="PackedScene" id=8]
[ext_resource path="res://assets/meat_creek/creek_cage.tscn" type="PackedScene" id=9]
[ext_resource path="res://assets/models/meat_creek_elevator.tscn" type="PackedScene" id=10]
[ext_resource path="res://assets/audio/walkie_talkie/buzz_static.ogg" type="AudioStream" id=11]
[ext_resource path="res://assets/models/walkie_talkie/signal_generator.tscn" type="PackedScene" id=12]
[sub_resource type="PanoramaSky" id=2]
panorama = ExtResource( 4 )
@ -123,3 +125,9 @@ transform = Transform( 0.65383, 0, 0.756641, 0, 1, 0, -0.756641, 0, 0.65383, 18.
[node name="elevator" parent="." index="8" instance=ExtResource( 10 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0735546, -35.4611, -41.1766 )
[node name="SignalGenerator" parent="." index="9" instance=ExtResource( 12 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.489914, -35.0689, -41.5684 )
stream = ExtResource( 11 )
max_db = 6.0
max_distance = 200.0

View File

@ -0,0 +1,11 @@
extends AudioStreamPlayer3D
func _ready():
var _ignore = GlobalEventBus.connect("player_walkie_talkie_state_change", self, "state")
func state(is_active: bool):
stream_paused = not is_active
func _process(_delta):
var distance = (transform.origin - Util.player.camera_position()).length()
GlobalEventBus.emit_signal("player_objective_ping", self, distance)

View File

@ -0,0 +1,8 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://assets/models/walkie_talkie/signal_generator.gd" type="Script" id=1]
[node name="SignalGenerator" type="AudioStreamPlayer3D"]
autoplay = true
stream_paused = true
script = ExtResource( 1 )

View File

@ -5,9 +5,10 @@ onready var fsm: AnimationNodeStateMachinePlayback = $Animations/AnimationTree.g
export var default_screen_color = Color(0.886275, 1, 0, 1)
export var screen_off_color = Color(0.0, 0.0, 0.0)
var is_screen_on: bool
export var screen_flicker_fastest: float = 0.1
export var screen_flicker_slowest: float = 1.0
onready var util = get_node("/root/Util")
onready var player = util.player
func _ready():
is_screen_on = false
@ -35,18 +36,16 @@ func toggle_screen():
func make_active():
if active:
return
if fsm.is_playing():
fsm.travel("WalkieTalkieEnter")
else:
fsm.start("WalkieTalkieEnter")
$StaticBuzz.play()
$StaticFizz.play()
$Talk.play()
$Whale1.play()
$Whale2.play()
fsm.travel("WalkieTalkieEnter")
#$StaticBuzz.play()
#$StaticFizz.play()
#$Talk.play()
#$Whale1.play()
#$Whale2.play()
turn_screen_on()
$Click.play()
active = true
GlobalEventBus.emit_signal("player_walkie_talkie_state_change", true)
func make_inactive():
if not active:
@ -60,24 +59,20 @@ func make_inactive():
turn_screen_off()
$Click.play()
active = false
GlobalEventBus.emit_signal("player_walkie_talkie_state_change", false)
func toggle_active():
if active:
make_inactive()
else:
make_active()
func put_away():
fsm.travel("WalkieTalkieLeave")
if $DestroyTimer.is_stopped():
$DestroyTimer.start(1)
func _process(_delta):
if Input.is_action_just_pressed("toggle_walkie_talkie"):
toggle_active()
if not active or not fsm.is_playing():
return
if player.is_ground_walking():
if Util.player.is_ground_walking():
fsm.travel("WalkieTalkieWalking")
else:
fsm.travel("WalkieTalkieIdle")
@ -85,3 +80,6 @@ func _process(_delta):
func _on_ScreenFlicker_timeout():
if active:
toggle_screen()
var weight = Util.player.objective_distance() / 115.0
var time = Util.clamped_lerp(screen_flicker_fastest, screen_flicker_slowest, weight, 0.0)
$Animations/walkie_talkie/Body/ScreenFlicker.start(time)

View File

@ -273,6 +273,7 @@ omni_range = 0.449905
[node name="ScreenFlicker" type="Timer" parent="Animations/walkie_talkie/Body"]
wait_time = 0.3
one_shot = true
autostart = true
[node name="BigKnob" type="MeshInstance" parent="Animations/walkie_talkie"]

View File

@ -3,9 +3,13 @@ extends Node
# Player enters or leaves an area for a block where they should start slowly sinking into it
signal player_entered_meat_sink
signal player_exited_meat_sink
signal player_walkie_talkie_state_change(is_active)
signal player_objective_ping(who, distance)
# This is only here to remove warnings about these signals not getting called (they get called by other nodes
# This is only here to remove warnings about these signals not getting called (they get called by other nodes)
func never_called():
emit_signal("player_entered_meat_sink")
emit_signal("player_exited_meat_sink")
emit_signal("player_walkie_talkie_state_change", false)
emit_signal("player_objective_ping", null, 0.0)

View File

@ -0,0 +1,13 @@
extends Node
var objective_who: WeakRef = weakref(null)
var objective_distance: float = 0.0
func _ready():
var _ignored = GlobalEventBus.connect("player_objective_ping", self, "update_objective_distance")
func update_objective_distance(who: Node, distance: float):
var node = objective_who.get_ref()
if node == null or node == who or distance < objective_distance:
objective_who = weakref(who)
objective_distance = distance

View File

@ -1,8 +1,10 @@
extends Spatial
onready var util = get_node("/root/Util")
onready var active_physics_node: Spatial = $OnFootPhysics
func _ready():
Util.player = self
func is_on_foot():
return active_physics_node == $OnFootPhysics
@ -26,3 +28,5 @@ func set_physics_node(node: Spatial):
node.global_transform = active_physics_node.global_transform
active_physics_node = node
func objective_distance() -> float:
return $ObjectiveTracker.objective_distance

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=29 format=2]
[gd_scene load_steps=30 format=2]
[ext_resource path="res://player/CameraController.gd" type="Script" id=1]
[ext_resource path="res://player/OnFootPhysics.gd" type="Script" id=2]
@ -20,6 +20,7 @@
[ext_resource path="res://assets/audio/404327__pfranzen__male-grunts-and-groans.ogg" type="AudioStream" id=18]
[ext_resource path="res://effects/player/MovementSoundsAnimations.gd" type="Script" id=19]
[ext_resource path="res://screens/PauseScreen.tscn" type="PackedScene" id=20]
[ext_resource path="res://player/ObjectiveTracker.gd" type="Script" id=21]
[sub_resource type="Animation" id=8]
length = 0.001
@ -254,6 +255,9 @@ anims/opacity = SubResource( 7 )
[node name="PauseScreen" parent="Overlay" instance=ExtResource( 20 )]
[node name="ObjectiveTracker" type="Node" parent="."]
script = ExtResource( 21 )
[connection signal="area_entered" from="ElevatorPhysics/Area" to="ElevatorPhysics" method="_on_Area_area_entered"]
[connection signal="area_exited" from="ElevatorPhysics/Area" to="ElevatorPhysics" method="_on_Area_area_exited"]
[connection signal="timeout" from="MovementInput/VerticalTimer" to="MovementInput" method="_on_VerticalTimer_timeout"]

View File

@ -1,6 +1,7 @@
extends Node
onready var player = $"/root".find_node("Player", true, false)
# Updated by player
onready var player = null
func vec3_componentwise_clamp(vec: Vector3, lower: float, upper: float) -> Vector3:
return Vector3(