generated from krampus/template-godot4
Null check in laser-cast ID association
Some checks failed
linting & formatting / build (push) Failing after 32s
Some checks failed
linting & formatting / build (push) Failing after 32s
This commit is contained in:
parent
22de43fa6f
commit
f9c62e02aa
@ -28,32 +28,8 @@ func _process(_delta: float) -> void:
|
|||||||
(c as Node3D).global_position = child_pos
|
(c as Node3D).global_position = child_pos
|
||||||
|
|
||||||
var collider: Object = get_collider()
|
var collider: Object = get_collider()
|
||||||
var new_gunk_id: int = collider.get_instance_id()
|
if is_instance_valid(collider):
|
||||||
if new_gunk_id != gunk_id:
|
_connect_gunkable(collider)
|
||||||
gunk_id = new_gunk_id
|
|
||||||
if gunkable:
|
|
||||||
# Disconnect old signals to avoid emitting from previous node and accumulating connections
|
|
||||||
if gunkable.painted_at_point.is_connected(grunk_dust._on_gunkable_painted_at_point):
|
|
||||||
gunkable.painted_at_point.disconnect(grunk_dust._on_gunkable_painted_at_point)
|
|
||||||
if gunkable.clear_total_updated.is_connected(
|
|
||||||
grunk_dust._on_gunkable_clear_total_updated
|
|
||||||
):
|
|
||||||
gunkable.clear_total_updated.disconnect(
|
|
||||||
grunk_dust._on_gunkable_clear_total_updated
|
|
||||||
)
|
|
||||||
gunkable = Gunkable.get_component(collider)
|
|
||||||
if gunkable:
|
|
||||||
# Connect signals of new gunkable to our gunk dust
|
|
||||||
if !gunkable.painted_at_point.is_connected(
|
|
||||||
grunk_dust._on_gunkable_painted_at_point
|
|
||||||
):
|
|
||||||
gunkable.painted_at_point.connect(grunk_dust._on_gunkable_painted_at_point)
|
|
||||||
if !gunkable.clear_total_updated.is_connected(
|
|
||||||
grunk_dust._on_gunkable_clear_total_updated
|
|
||||||
):
|
|
||||||
gunkable.clear_total_updated.connect(
|
|
||||||
grunk_dust._on_gunkable_clear_total_updated
|
|
||||||
)
|
|
||||||
|
|
||||||
laser_dust.emitting = true
|
laser_dust.emitting = true
|
||||||
|
|
||||||
@ -61,3 +37,26 @@ func _process(_delta: float) -> void:
|
|||||||
else:
|
else:
|
||||||
laser_dust.emitting = false
|
laser_dust.emitting = false
|
||||||
glow_light.visible = false
|
glow_light.visible = false
|
||||||
|
|
||||||
|
|
||||||
|
func _connect_gunkable(collider: Object) -> void:
|
||||||
|
var new_gunk_id: int = collider.get_instance_id()
|
||||||
|
if new_gunk_id != gunk_id:
|
||||||
|
gunk_id = new_gunk_id
|
||||||
|
if gunkable:
|
||||||
|
# Disconnect old signals to avoid emitting from previous node and accumulating connections
|
||||||
|
if gunkable.painted_at_point.is_connected(grunk_dust._on_gunkable_painted_at_point):
|
||||||
|
gunkable.painted_at_point.disconnect(grunk_dust._on_gunkable_painted_at_point)
|
||||||
|
if gunkable.clear_total_updated.is_connected(
|
||||||
|
grunk_dust._on_gunkable_clear_total_updated
|
||||||
|
):
|
||||||
|
gunkable.clear_total_updated.disconnect(grunk_dust._on_gunkable_clear_total_updated)
|
||||||
|
gunkable = Gunkable.get_component(collider)
|
||||||
|
if gunkable:
|
||||||
|
# Connect signals of new gunkable to our gunk dust
|
||||||
|
if !gunkable.painted_at_point.is_connected(grunk_dust._on_gunkable_painted_at_point):
|
||||||
|
gunkable.painted_at_point.connect(grunk_dust._on_gunkable_painted_at_point)
|
||||||
|
if !gunkable.clear_total_updated.is_connected(
|
||||||
|
grunk_dust._on_gunkable_clear_total_updated
|
||||||
|
):
|
||||||
|
gunkable.clear_total_updated.connect(grunk_dust._on_gunkable_clear_total_updated)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user