Different tools do different damage to nodules

This commit is contained in:
Rob Kelly 2025-03-13 11:25:11 -06:00
parent 7018ffff34
commit 34b4ad7da2
5 changed files with 15 additions and 10 deletions

View File

@ -2,6 +2,7 @@ class_name PointSpray extends Spray
## Simple single-point spraygun
@export var spray_scale := 1.5
@export var damage := 0.3334
@onready var laser: LaserCast = %LaserCast
@ -16,4 +17,4 @@ func _spray() -> void:
point, laser.get_collision_normal(), point_scale
)
if collider is GunkNode:
(collider as GunkNode).hit()
(collider as GunkNode).hit(damage)

View File

@ -4,6 +4,8 @@ extends Tool
const PAINT_COLOR := Color(1, 0, 0, 0.3)
const BRUSH_SCALE := 0.2
@export var damage := 0.0063 # ~8 seconds to destroy standard nodule
@onready var raycast: RayCast3D = %Raycast
@onready var texture_idle: TextureRect = %TextureIdle
@ -23,7 +25,7 @@ func _fire() -> void:
PAINT_COLOR
)
if collider is GunkNode:
(collider as GunkNode).hit()
(collider as GunkNode).hit(damage)
else:
brush_animation.stop()

View File

@ -4,6 +4,8 @@ class_name WideSpray extends Spray
const SPRAYCAST_GROUP := "SprayCast"
@export var spray_scale := 1.0
# NOTE: this is damage _per spray_, so multiply by up to 7 damage per frame depending on spread.
@export var damage := 0.015
var _horizontal := true
var _busy := false
@ -56,7 +58,7 @@ func _spray() -> void:
prev_point = point
prev_normal = normal
elif collider is GunkNode:
(collider as GunkNode).hit()
(collider as GunkNode).hit(damage)
func _on_animation_finished(anim_name: StringName) -> void:

View File

@ -8,7 +8,8 @@ extends GunkNode
@onready var mesh_instance: MeshInstance3D = %MeshInstance3D
func _process(_delta: float) -> void:
func _process(delta: float) -> void:
super._process(delta)
var shader: ShaderMaterial = mesh_instance.mesh.surface_get_material(0)
var value := _sustained_damage / durability
shader.set_shader_parameter("jitter_time_scale", value * jitter_scale_factor)

View File

@ -5,7 +5,7 @@ class_name GunkNode extends StaticBody3D
## but before it's removed from the scene tree
signal destroyed
const JITTER_FADE_RATE := 0.6
const JITTER_FADE_RATE := 0.8
## Time in seconds the player must hit this node with a sustained beam before it's destroyed.
@export var durability := 1.0
@ -20,7 +20,8 @@ var _hit_this_frame := false
## Called each frame this node takes a hit.
##
## Derived types should override `_hit()` as a lifecycle method.
func hit() -> void:
func hit(damage: float = 0.05) -> void:
_sustained_damage += damage
_hit_this_frame = true
_hit()
@ -29,10 +30,8 @@ func _hit() -> void:
pass # Implemented in derived type
func _physics_process(delta: float) -> void:
if _hit_this_frame:
_sustained_damage += delta
else:
func _process(_delta: float) -> void:
if not _hit_this_frame:
_sustained_damage *= JITTER_FADE_RATE
_hit_this_frame = false