Wide-angle spray can be rotated to vertical mode

This commit is contained in:
Rob Kelly 2025-03-12 11:23:21 -06:00
parent ded02933f0
commit a0bd457535
7 changed files with 140 additions and 28 deletions

View File

@ -107,6 +107,31 @@ interact={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
] ]
} }
select_point_spray={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":49,"key_label":0,"unicode":49,"location":0,"echo":false,"script":null)
]
}
select_wide_spray={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":50,"key_label":0,"unicode":50,"location":0,"echo":false,"script":null)
]
}
switch_mode={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194306,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
select_next_tool={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}
select_prev_tool={
"deadzone": 0.2,
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
]
}
[layer_names] [layer_names]

View File

@ -12,6 +12,12 @@ func _idle() -> void:
pass pass
## Toggles between this tool's normal & alternate modes
func switch_mode() -> void:
# TODO: bonk if no mode switch is defined
pass
## Called each frame that this tool is being fired. ## Called each frame that this tool is being fired.
func fire() -> void: func fire() -> void:
firing = true firing = true

View File

@ -5,7 +5,31 @@ const SPRAYCAST_GROUP := "SprayCast"
@export var spray_scale := 1.0 @export var spray_scale := 1.0
var _horizontal := true
var _busy := false
@onready var spray_casts: Node3D = %SprayCasts @onready var spray_casts: Node3D = %SprayCasts
@onready var animation_player: AnimationPlayer = %AnimationPlayer
func switch_mode() -> void:
if not _busy:
if _horizontal:
animation_player.play("rotate")
else:
animation_player.play_backwards("rotate")
_horizontal = not _horizontal
_busy = true
else:
# TODO: bonk
pass
func _fire() -> void:
if _busy:
idle()
else:
super._fire()
func _spray() -> void: func _spray() -> void:
@ -33,3 +57,8 @@ func _spray() -> void:
prev_normal = normal prev_normal = normal
elif collider is GunkNode: elif collider is GunkNode:
(collider as GunkNode).hit() (collider as GunkNode).hit()
func _on_animation_finished(anim_name: StringName) -> void:
if anim_name == "rotate":
_busy = false

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://d2hnxr5l6w2x4"] [gd_scene load_steps=15 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"]
@ -46,73 +46,114 @@ initial_velocity_min = 8.0
initial_velocity_max = 8.0 initial_velocity_max = 8.0
gravity = Vector3(0, 0, 0) gravity = Vector3(0, 0, 0)
[sub_resource type="Animation" id="Animation_ay2b7"]
resource_name = "rotate"
length = 0.1
step = 0.0333
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Pivot:rotation")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1),
"transitions": PackedFloat32Array(1.618, 1),
"update": 0,
"values": [Vector3(0, 0, 0), Vector3(0, 0, 1.5708)]
}
[sub_resource type="Animation" id="Animation_ku0nd"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Pivot:rotation")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_fmqw2"]
_data = {
&"RESET": SubResource("Animation_ku0nd"),
&"rotate": SubResource("Animation_ay2b7")
}
[node name="WideSpray" type="Node3D"] [node name="WideSpray" type="Node3D"]
script = ExtResource("1_ggkto") script = ExtResource("1_ggkto")
[node name="SprayCasts" type="Node3D" parent="."] [node name="Pivot" type="Node3D" parent="."]
[node name="SprayCasts" type="Node3D" parent="Pivot"]
unique_name_in_owner = true unique_name_in_owner = true
[node name="LaserCast" parent="SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")] [node name="LaserCast" parent="Pivot/SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")]
target_position = Vector3(-0.5, 0, -2) target_position = Vector3(-0.5, 0, -2)
parent_tool = NodePath("../..") parent_tool = NodePath("../../..")
[node name="LaserCast2" parent="SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")] [node name="LaserCast2" parent="Pivot/SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")]
target_position = Vector3(-0.333, 0, -2) target_position = Vector3(-0.333, 0, -2)
parent_tool = NodePath("../..") parent_tool = NodePath("../../..")
[node name="LaserCast3" parent="SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")] [node name="LaserCast3" parent="Pivot/SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")]
target_position = Vector3(-0.167, 0, -2) target_position = Vector3(-0.167, 0, -2)
parent_tool = NodePath("../..") parent_tool = NodePath("../../..")
[node name="LaserCast4" parent="SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")] [node name="LaserCast4" parent="Pivot/SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")]
parent_tool = NodePath("../..") parent_tool = NodePath("../../..")
[node name="LaserCast5" parent="SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")] [node name="LaserCast5" parent="Pivot/SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")]
target_position = Vector3(0.167, 0, -2) target_position = Vector3(0.167, 0, -2)
parent_tool = NodePath("../..") parent_tool = NodePath("../../..")
[node name="LaserCast6" parent="SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")] [node name="LaserCast6" parent="Pivot/SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")]
target_position = Vector3(0.333, 0, -2) target_position = Vector3(0.333, 0, -2)
parent_tool = NodePath("../..") parent_tool = NodePath("../../..")
[node name="LaserCast7" parent="SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")] [node name="LaserCast7" parent="Pivot/SprayCasts" node_paths=PackedStringArray("parent_tool") instance=ExtResource("3_xahet")]
target_position = Vector3(0.5, 0, -2) target_position = Vector3(0.5, 0, -2)
parent_tool = NodePath("../..") parent_tool = NodePath("../../..")
[node name="SprayEffect" type="MeshInstance3D" parent="."] [node name="SprayEffect" type="MeshInstance3D" parent="Pivot"]
unique_name_in_owner = true unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -0.15, 0, 1, -6.55671e-09, 0, 0, -1) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -0.15, 0, 1, -6.55671e-09, 0, 0, -1)
layers = 2 layers = 2
sorting_offset = 1.0 sorting_offset = 1.0
mesh = SubResource("CylinderMesh_48buk") mesh = SubResource("CylinderMesh_48buk")
skeleton = NodePath("../..")
[node name="ReticleDecals" type="Node3D" parent="."] [node name="ReticleDecals" type="Node3D" parent="Pivot"]
[node name="CrosshairDecal" type="Decal" parent="ReticleDecals"] [node name="CrosshairDecal" type="Decal" parent="Pivot/ReticleDecals"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -1) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -1)
size = Vector3(0.2, 2, 0.2) size = Vector3(0.2, 2, 0.2)
texture_albedo = ExtResource("3_78jy6") texture_albedo = ExtResource("3_78jy6")
cull_mask = 1048573 cull_mask = 1048573
[node name="LeftPivot" type="Node3D" parent="ReticleDecals"] [node name="LeftPivot" type="Node3D" parent="Pivot/ReticleDecals"]
transform = Transform3D(0.970296, 0, 0.241922, 0, 1, 0, -0.241922, 0, 0.970296, 0, 0, 0) transform = Transform3D(0.970296, 0, 0.241922, 0, 1, 0, -0.241922, 0, 0.970296, 0, 0, 0)
[node name="LeftDecal" type="Decal" parent="ReticleDecals/LeftPivot"] [node name="LeftDecal" type="Decal" parent="Pivot/ReticleDecals/LeftPivot"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -1) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -1)
size = Vector3(0.2, 2, 0.2) size = Vector3(0.2, 2, 0.2)
texture_albedo = ExtResource("4_rotxf") texture_albedo = ExtResource("4_rotxf")
cull_mask = 1048573 cull_mask = 1048573
[node name="RightPivot" type="Node3D" parent="ReticleDecals"] [node name="RightPivot" type="Node3D" parent="Pivot/ReticleDecals"]
transform = Transform3D(0.970296, 0, -0.241922, 0, 1, 0, 0.241922, 0, 0.970296, 0, 0, 0) transform = Transform3D(0.970296, 0, -0.241922, 0, 1, 0, 0.241922, 0, 0.970296, 0, 0, 0)
[node name="RightDecal" type="Decal" parent="ReticleDecals/RightPivot"] [node name="RightDecal" type="Decal" parent="Pivot/ReticleDecals/RightPivot"]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -1) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, -1)
size = Vector3(0.2, 2, 0.2) size = Vector3(0.2, 2, 0.2)
texture_albedo = ExtResource("5_xo3vu") texture_albedo = ExtResource("5_xo3vu")
cull_mask = 1048573 cull_mask = 1048573
[node name="BeamParticles1" type="GPUParticles3D" parent="."] [node name="BeamParticles1" type="GPUParticles3D" parent="Pivot"]
unique_name_in_owner = true unique_name_in_owner = true
amount = 16 amount = 16
lifetime = 0.5 lifetime = 0.5
@ -120,9 +161,17 @@ local_coords = true
process_material = SubResource("ParticleProcessMaterial_pr4yq") process_material = SubResource("ParticleProcessMaterial_pr4yq")
draw_pass_1 = SubResource("QuadMesh_trcry") draw_pass_1 = SubResource("QuadMesh_trcry")
[node name="BeamParticles2" type="GPUParticles3D" parent="."] [node name="BeamParticles2" type="GPUParticles3D" parent="Pivot"]
unique_name_in_owner = true unique_name_in_owner = true
lifetime = 0.2 lifetime = 0.2
local_coords = true local_coords = true
process_material = SubResource("ParticleProcessMaterial_lyk2j") process_material = SubResource("ParticleProcessMaterial_lyk2j")
draw_pass_1 = SubResource("QuadMesh_trcry") draw_pass_1 = SubResource("QuadMesh_trcry")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true
libraries = {
&"": SubResource("AnimationLibrary_fmqw2")
}
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_finished"]

View File

@ -62,6 +62,9 @@ func _physics_process(delta: float) -> void:
firing = false firing = false
tool_rumbler.intensity *= 0.8 tool_rumbler.intensity *= 0.8
if Input.is_action_just_pressed("switch_mode"):
get_tool().switch_mode()
# Gravity # Gravity
if not is_on_floor(): if not is_on_floor():
velocity += gravity * delta velocity += gravity * delta

View File

@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://buwh0g1ga2aka" path="res://src/player/player.gd" id="1_npueo"] [ext_resource type="Script" uid="uid://buwh0g1ga2aka" path="res://src/player/player.gd" id="1_npueo"]
[ext_resource type="Script" uid="uid://cx1yt0drthpw3" path="res://src/player/camera_controller.gd" id="2_veeqv"] [ext_resource type="Script" uid="uid://cx1yt0drthpw3" path="res://src/player/camera_controller.gd" id="2_veeqv"]
[ext_resource type="PackedScene" uid="uid://cc102xko0u6yj" path="res://src/equipment/point_spray/point_spray.tscn" id="3_6wgkm"] [ext_resource type="PackedScene" uid="uid://d2hnxr5l6w2x4" path="res://src/equipment/wide_spray/wide_spray.tscn" id="3_ibq07"]
[ext_resource type="Script" uid="uid://b274q7uvn0cvp" path="res://src/ui/rumbler_3d.gd" id="5_ipd7g"] [ext_resource type="Script" uid="uid://b274q7uvn0cvp" path="res://src/ui/rumbler_3d.gd" id="5_ipd7g"]
[ext_resource type="PackedScene" uid="uid://dq1x21tq06dud" path="res://src/ui/hud/player_hud.tscn" id="5_jvafu"] [ext_resource type="PackedScene" uid="uid://dq1x21tq06dud" path="res://src/ui/hud/player_hud.tscn" id="5_jvafu"]
@ -27,7 +27,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15, -0.1, -0.1)
unique_name_in_owner = true unique_name_in_owner = true
transform = Transform3D(1, 0, 0, 0, 0.997564, -0.0697565, 0, 0.0697565, 0.997564, 0, 0, -0.15) transform = Transform3D(1, 0, 0, 0, 0.997564, -0.0697565, 0, 0.0697565, 0.997564, 0, 0, -0.15)
[node name="PointSpray" parent="CameraPivot/ToolMount/ToolMuzzle" instance=ExtResource("3_6wgkm")] [node name="WideSpray" parent="CameraPivot/ToolMount/ToolMuzzle" instance=ExtResource("3_ibq07")]
[node name="ToolRumbler" type="Node3D" parent="CameraPivot/ToolMount"] [node name="ToolRumbler" type="Node3D" parent="CameraPivot/ToolMount"]
unique_name_in_owner = true unique_name_in_owner = true

View File

@ -8,7 +8,7 @@
- [ ] Spray nozzle asset - [ ] Spray nozzle asset
- [x] Point spray - [x] Point spray
- [x] Wide-angle spray - [x] Wide-angle spray
- [ ] Tall-angle spray? - [x] Tall-angle spray?
- [ ] Spray-can? - [ ] Spray-can?
- [ ] [[chisel]] - [ ] [[chisel]]
- [ ] [[radar]] - [ ] [[radar]]