Diegetic grunk gauge
All checks were successful
linting & formatting / build (push) Successful in 21s

This commit is contained in:
Rob Kelly 2025-04-18 18:36:19 -06:00
parent c74bfefe92
commit f2de25ab0f
20 changed files with 268 additions and 30 deletions

Binary file not shown.

Binary file not shown.

BIN
assets/ui/hud/tools/gauge/gauge.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bg15yxnlch3u"
path="res://.godot/imported/gauge.png-54a9e95d92eff20b36a5ee68b47fb3be.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/hud/tools/gauge/gauge.png"
dest_files=["res://.godot/imported/gauge.png-54a9e95d92eff20b36a5ee68b47fb3be.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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=0

BIN
assets/ui/hud/tools/gauge/gauge_glass.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://pjkrr68wjy54"
path="res://.godot/imported/gauge_glass.png-9dc78d704a5068e96ac53d15bc602729.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/hud/tools/gauge/gauge_glass.png"
dest_files=["res://.godot/imported/gauge_glass.png-9dc78d704a5068e96ac53d15bc602729.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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=0

BIN
assets/ui/hud/tools/gauge/gauge_needle.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://b4wooq3xvnuib"
path="res://.godot/imported/gauge_needle.png-cb4ebb48df09e8ebb666c914fe299bd3.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/ui/hud/tools/gauge/gauge_needle.png"
dest_files=["res://.godot/imported/gauge_needle.png-cb4ebb48df09e8ebb666c914fe299bd3.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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=0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://cc102xko0u6yj"] [gd_scene load_steps=17 format=3 uid="uid://cc102xko0u6yj"]
[ext_resource type="Script" uid="uid://dngia2ldbccv7" path="res://src/equipment/point_spray/point_spray.gd" id="1_2yl2v"] [ext_resource type="Script" uid="uid://dngia2ldbccv7" path="res://src/equipment/point_spray/point_spray.gd" id="1_2yl2v"]
[ext_resource type="Material" uid="uid://c00gndxoepuqh" path="res://assets/materials/laser_spray.tres" id="2_0pfy3"] [ext_resource type="Material" uid="uid://c00gndxoepuqh" path="res://assets/materials/laser_spray.tres" id="2_0pfy3"]
@ -9,6 +9,7 @@
[ext_resource type="PackedScene" uid="uid://5y7gcq6igjpf" path="res://src/equipment/beam_sfx/beam_sfx.tscn" id="5_tpavj"] [ext_resource type="PackedScene" uid="uid://5y7gcq6igjpf" path="res://src/equipment/beam_sfx/beam_sfx.tscn" id="5_tpavj"]
[ext_resource type="Script" uid="uid://dj2x7x5qkbym1" path="res://src/ui/canvas_projector.gd" id="6_h2fjt"] [ext_resource type="Script" uid="uid://dj2x7x5qkbym1" path="res://src/ui/canvas_projector.gd" id="6_h2fjt"]
[ext_resource type="Texture2D" uid="uid://brcxorcpe2g56" path="res://assets/ui/hud/tools/point_sprayer.png" id="6_otnek"] [ext_resource type="Texture2D" uid="uid://brcxorcpe2g56" path="res://assets/ui/hud/tools/point_sprayer.png" id="6_otnek"]
[ext_resource type="PackedScene" uid="uid://bnp6vqiixminx" path="res://src/ui/hud/grunk_gauge/grunk_gauge.tscn" id="10_dlin7"]
[sub_resource type="CylinderMesh" id="CylinderMesh_j5thb"] [sub_resource type="CylinderMesh" id="CylinderMesh_j5thb"]
material = ExtResource("2_0pfy3") material = ExtResource("2_0pfy3")
@ -143,3 +144,9 @@ offset_right = -192.0
offset_bottom = -122.0 offset_bottom = -122.0
scale = Vector2(10, 10) scale = Vector2(10, 10)
texture = ExtResource("6_otnek") texture = ExtResource("6_otnek")
[node name="GrunkGauge" parent="HUDTool/Rumbler/NozzleMarker/HUDElement" instance=ExtResource("10_dlin7")]
offset_left = 344.0
offset_top = 211.0
offset_right = 344.0
offset_bottom = 211.0

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=22 format=3 uid="uid://d2hnxr5l6w2x4"] [gd_scene load_steps=23 format=3 uid="uid://d2hnxr5l6w2x4"]
[ext_resource type="Script" uid="uid://dv40fyim2g2fa" path="res://src/equipment/wide_spray/wide_spray.gd" id="1_ggkto"] [ext_resource type="Script" uid="uid://dv40fyim2g2fa" path="res://src/equipment/wide_spray/wide_spray.gd" id="1_ggkto"]
[ext_resource type="Material" uid="uid://c00gndxoepuqh" path="res://assets/materials/laser_spray.tres" id="2_26efp"] [ext_resource type="Material" uid="uid://c00gndxoepuqh" path="res://assets/materials/laser_spray.tres" id="2_26efp"]
@ -12,6 +12,7 @@
[ext_resource type="Script" uid="uid://dj2x7x5qkbym1" path="res://src/ui/canvas_projector.gd" id="8_j7ker"] [ext_resource type="Script" uid="uid://dj2x7x5qkbym1" path="res://src/ui/canvas_projector.gd" id="8_j7ker"]
[ext_resource type="Texture2D" uid="uid://dxjwpai3or1hw" path="res://assets/ui/hud/tools/wide_sprayer.png" id="9_8vo2h"] [ext_resource type="Texture2D" uid="uid://dxjwpai3or1hw" path="res://assets/ui/hud/tools/wide_sprayer.png" id="9_8vo2h"]
[ext_resource type="Texture2D" uid="uid://dmwey2qj77tm0" path="res://assets/ui/hud/tools/tall_sprayer.png" id="10_hv82w"] [ext_resource type="Texture2D" uid="uid://dmwey2qj77tm0" path="res://assets/ui/hud/tools/tall_sprayer.png" id="10_hv82w"]
[ext_resource type="PackedScene" uid="uid://bnp6vqiixminx" path="res://src/ui/hud/grunk_gauge/grunk_gauge.tscn" id="13_m8r8o"]
[sub_resource type="CylinderMesh" id="CylinderMesh_48buk"] [sub_resource type="CylinderMesh" id="CylinderMesh_48buk"]
material = ExtResource("2_26efp") material = ExtResource("2_26efp")
@ -315,6 +316,17 @@ offset_bottom = -122.0
scale = Vector2(10, 10) scale = Vector2(10, 10)
texture = ExtResource("10_hv82w") texture = ExtResource("10_hv82w")
[node name="GrunkGauge" parent="HUDTool/Rumbler/NozzleMarker/HUDElement" instance=ExtResource("13_m8r8o")]
offset_left = 344.0
offset_top = 211.0
offset_right = 344.0
offset_bottom = 211.0
BUFFER_RUMBLE_FACTOR = 3.0
RUMBLE_DECAY = 10
NEEDLE_ACCEL = 1.0
NEEDLE_VELOCITY_MAX = 1.0
debug_collect = 0.0
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
libraries = { libraries = {

View File

@ -0,0 +1,61 @@
extends Control
## Goes up when u collect tha grunk!
const BUFFER_RUMBLE_FACTOR := 3.0
const RUMBLE_DECAY := 10
const NEEDLE_ANGLE_MIN := 0.0
const NEEDLE_ANGLE_MAX := PI
const NEEDLE_ACCEL := 3.0
const NEEDLE_VELOCITY_MAX := 4.0
const NEEDLE_ANGLE_EPSILON := 0.05
const TANK_WARNING_BUFFER_PCT := 0.1
@export var debug_collect: float:
set = on_grunk_collected
var _needle_velocity := 0.0
var _base_rumble := 0.0
@onready var rumbler: Rumbler = %Rumbler
@onready var needle: TextureRect = %NeedleTexture
func _ready() -> void:
Game.manager.grunk_collected.connect(on_grunk_collected)
Game.manager.grunk_emptied.connect(on_grunk_emptied)
func get_target_rotation() -> float:
return remap(
Game.manager.grunk_tank,
0,
Game.manager.grunk_tank_limit,
NEEDLE_ANGLE_MIN,
NEEDLE_ANGLE_MAX
)
func on_grunk_collected(_delta: float) -> void:
var buffer := remap(Game.manager.get_tank_fill_pct(), 1 - TANK_WARNING_BUFFER_PCT, 1, 0, 1)
_base_rumble = BUFFER_RUMBLE_FACTOR * buffer
func on_grunk_emptied(_amount: float) -> void:
_base_rumble = 0.0
func _process(delta: float) -> void:
var weight := 1 - exp(-RUMBLE_DECAY * delta)
rumbler.intensity = lerpf(rumbler.intensity, _base_rumble, weight)
var diff := get_target_rotation() - needle.rotation
var target_velocity := 0.0
if diff > NEEDLE_ANGLE_EPSILON:
target_velocity = NEEDLE_VELOCITY_MAX
elif diff < -NEEDLE_ANGLE_EPSILON:
target_velocity = -NEEDLE_VELOCITY_MAX
_needle_velocity = lerpf(_needle_velocity, target_velocity, 1 - exp(-NEEDLE_ACCEL * delta))
needle.rotation += _needle_velocity * delta

View File

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

View File

@ -0,0 +1,67 @@
[gd_scene load_steps=6 format=3 uid="uid://bnp6vqiixminx"]
[ext_resource type="Texture2D" uid="uid://bg15yxnlch3u" path="res://assets/ui/hud/tools/gauge/gauge.png" id="1_hn628"]
[ext_resource type="Script" uid="uid://dkbbrevmer6tx" path="res://src/ui/hud/grunk_gauge/grunk_gauge.gd" id="1_mgquo"]
[ext_resource type="Texture2D" uid="uid://pjkrr68wjy54" path="res://assets/ui/hud/tools/gauge/gauge_glass.png" id="2_hn8y8"]
[ext_resource type="Script" uid="uid://cjs2fen6jo0g0" path="res://src/ui/rumbler.gd" id="2_iak84"]
[ext_resource type="Texture2D" uid="uid://b4wooq3xvnuib" path="res://assets/ui/hud/tools/gauge/gauge_needle.png" id="3_mgquo"]
[node name="GrunkGauge" type="Control"]
texture_filter = 3
layout_mode = 3
anchors_preset = 0
script = ExtResource("1_mgquo")
[node name="BaseTexture" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(10, 10)
pivot_offset = Vector2(20, 20)
texture = ExtResource("1_hn628")
[node name="Rumbler" type="Control" parent="."]
unique_name_in_owner = true
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0
script = ExtResource("2_iak84")
metadata/_custom_type_script = "uid://cjs2fen6jo0g0"
[node name="NeedleTexture" type="TextureRect" parent="Rumbler"]
unique_name_in_owner = true
custom_minimum_size = Vector2(16, 5)
layout_mode = 0
offset_left = -13.5
offset_top = -2.5
offset_right = 2.5
offset_bottom = 2.5
scale = Vector2(10, 10)
pivot_offset = Vector2(13.5, 2.5)
texture = ExtResource("3_mgquo")
[node name="GlassTexture" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -20.0
offset_top = -20.0
offset_right = 20.0
offset_bottom = 20.0
grow_horizontal = 2
grow_vertical = 2
scale = Vector2(10, 10)
pivot_offset = Vector2(20, 20)
texture = ExtResource("2_hn8y8")

View File

@ -1,8 +1,7 @@
[gd_scene load_steps=10 format=3 uid="uid://dq1x21tq06dud"] [gd_scene load_steps=9 format=3 uid="uid://dq1x21tq06dud"]
[ext_resource type="Theme" uid="uid://b07fevr214mmr" path="res://src/ui/hud/hud_theme.tres" id="1_lirk3"] [ext_resource type="Theme" uid="uid://b07fevr214mmr" path="res://src/ui/hud/hud_theme.tres" id="1_lirk3"]
[ext_resource type="Script" uid="uid://lrsv0185bfu" path="res://src/ui/hud/player_hud.gd" id="2_j6lpx"] [ext_resource type="Script" uid="uid://lrsv0185bfu" path="res://src/ui/hud/player_hud.gd" id="2_j6lpx"]
[ext_resource type="PackedScene" uid="uid://cq8qcp5xg41e0" path="res://src/ui/hud/grunk_counter/grunk_counter.tscn" id="3_5be8f"]
[ext_resource type="Script" uid="uid://bdsv404evn4fk" path="res://src/ui/hud/interact_hud.gd" id="3_n6jee"] [ext_resource type="Script" uid="uid://bdsv404evn4fk" path="res://src/ui/hud/interact_hud.gd" id="3_n6jee"]
[ext_resource type="Script" uid="uid://cjs2fen6jo0g0" path="res://src/ui/rumbler.gd" id="4_ud8na"] [ext_resource type="Script" uid="uid://cjs2fen6jo0g0" path="res://src/ui/rumbler.gd" id="4_ud8na"]
@ -215,10 +214,10 @@ anchor_left = 0.5
anchor_top = 0.5 anchor_top = 0.5
anchor_right = 0.5 anchor_right = 0.5
anchor_bottom = 0.5 anchor_bottom = 0.5
offset_left = -400.498 offset_left = -401.541
offset_top = -299.892 offset_top = -299.173
offset_right = -400.498 offset_right = -401.541
offset_bottom = -299.892 offset_bottom = -299.173
grow_horizontal = 2 grow_horizontal = 2
grow_vertical = 2 grow_vertical = 2
script = ExtResource("4_ud8na") script = ExtResource("4_ud8na")
@ -239,7 +238,6 @@ mouse_filter = 2
theme_type_variation = &"AlertLabel" theme_type_variation = &"AlertLabel"
[node name="AlertLine1" type="Label" parent="AlertHUD/Rumbler/GrunkAlert2"] [node name="AlertLine1" type="Label" parent="AlertHUD/Rumbler/GrunkAlert2"]
modulate = Color(1, 1, 1, 1)
layout_mode = 1 layout_mode = 1
anchors_preset = 8 anchors_preset = 8
anchor_left = 0.5 anchor_left = 0.5
@ -261,7 +259,6 @@ text = "! GRUNK ALERT !"
horizontal_alignment = 1 horizontal_alignment = 1
[node name="AlertLine2" type="Label" parent="AlertHUD/Rumbler/GrunkAlert2"] [node name="AlertLine2" type="Label" parent="AlertHUD/Rumbler/GrunkAlert2"]
modulate = Color(1, 1, 1, 1)
layout_mode = 1 layout_mode = 1
anchors_preset = 8 anchors_preset = 8
anchor_left = 0.5 anchor_left = 0.5
@ -284,21 +281,3 @@ unique_name_in_owner = true
libraries = { libraries = {
&"": SubResource("AnimationLibrary_ud8na") &"": SubResource("AnimationLibrary_ud8na")
} }
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 2
anchor_top = 1.0
anchor_bottom = 1.0
offset_top = -77.0
offset_right = 123.0
grow_vertical = 0
theme_override_constants/margin_left = 32
theme_override_constants/margin_top = 32
theme_override_constants/margin_right = 32
theme_override_constants/margin_bottom = 32
[node name="GrunkCounter" parent="MarginContainer" instance=ExtResource("3_5be8f")]
layout_mode = 2
size_flags_horizontal = 0
size_flags_vertical = 8

View File

@ -218,7 +218,7 @@ metadata/_custom_type_script = "uid://om57w2acvgb7"
script = ExtResource("11_mbqcc") script = ExtResource("11_mbqcc")
mean_time = 4.0 mean_time = 4.0
st_dev_time = 0.6 st_dev_time = 0.6
wait_time = 3.8583 wait_time = 4.72586
metadata/_custom_type_script = "uid://beyk2xtbjrsg4" metadata/_custom_type_script = "uid://beyk2xtbjrsg4"
[node name="RandomStalkingBehavior" type="Node" parent="GrunkBeastBehavior/StateSelector/StalkingSequence/RandomDelay"] [node name="RandomStalkingBehavior" type="Node" parent="GrunkBeastBehavior/StateSelector/StalkingSequence/RandomDelay"]
@ -264,7 +264,7 @@ metadata/_custom_type_script = "uid://cg016dbe7gs1x"
script = ExtResource("11_mbqcc") script = ExtResource("11_mbqcc")
mean_time = 5.0 mean_time = 5.0
st_dev_time = 1.0 st_dev_time = 1.0
wait_time = 5.01985 wait_time = 4.0544
metadata/_custom_type_script = "uid://beyk2xtbjrsg4" metadata/_custom_type_script = "uid://beyk2xtbjrsg4"
[node name="PickRandomLurkTarget" type="Node" parent="GrunkBeastBehavior/StateSelector/LurkSequence/RandomDelay"] [node name="PickRandomLurkTarget" type="Node" parent="GrunkBeastBehavior/StateSelector/LurkSequence/RandomDelay"]