Cleaned up a few inconsistencies in pickup behaviours.
This commit is contained in:
parent
935b61bd3b
commit
92463f4465
3 changed files with 22 additions and 11 deletions
|
|
@ -22,13 +22,23 @@ func _ready() -> void:
|
|||
|
||||
if behavior != null:
|
||||
behavior.start()
|
||||
if drift_behavior != null:
|
||||
drift_behavior.start()
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if behavior == null or drift_behavior == null:
|
||||
# Handle partial configurations: if only behavior is set, compute bob/shake.
|
||||
# If only drift_behavior is set, compute drift offset. If both are set,
|
||||
# composite them (bob/shake on icon, drift on pickup position).
|
||||
var has_behavior: bool = behavior != null
|
||||
var has_drift: bool = drift_behavior != null
|
||||
|
||||
if not has_behavior and not has_drift:
|
||||
return
|
||||
|
||||
var alpha: float = behavior.process(delta)
|
||||
var alpha: float = 1.0
|
||||
if has_behavior:
|
||||
alpha = behavior.process(delta)
|
||||
|
||||
if _icon_node != null:
|
||||
_icon_node.visible = alpha > 0.01
|
||||
|
|
@ -127,6 +137,9 @@ func _compute_drift_offset() -> Vector2:
|
|||
|
||||
|
||||
func _elapsed_time() -> float:
|
||||
if behavior == null:
|
||||
return 0.0
|
||||
return behavior._elapsed
|
||||
# Prefer behavior's elapsed time; fall back to drift_behavior's.
|
||||
if behavior != null:
|
||||
return behavior._elapsed
|
||||
if drift_behavior != null:
|
||||
return drift_behavior._elapsed
|
||||
return 0.0
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue