Pooled enemy characters stop animating while hidden
A released, faded, or cleared character was hidden but its AnimationPlayer kept looping (the #28 soak found 1-55 still animating at the end of a night, and on through the day). EnemyCharacters._hide stops it; acquire already clears the clip, so the next enemy's animation starts at once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8132567ece
commit
1fdbecd034
1 changed files with 10 additions and 3 deletions
|
|
@ -168,7 +168,7 @@ func release(id: int, killed: bool) -> void:
|
|||
corpse[c] = CORPSE_TIME
|
||||
_play(c, CLIPS[type[c]]["death"], 0.1)
|
||||
else:
|
||||
_roots[c].visible = false
|
||||
_hide(c)
|
||||
|
||||
|
||||
func hit(id: int) -> void:
|
||||
|
|
@ -182,7 +182,7 @@ func clear() -> void:
|
|||
for c in type.size():
|
||||
enemy_id[c] = -1
|
||||
corpse[c] = 0.0
|
||||
_roots[c].visible = false
|
||||
_hide(c)
|
||||
|
||||
|
||||
## How many characters are drawing an enemy right now (tests).
|
||||
|
|
@ -202,7 +202,7 @@ func _process(delta: float) -> void:
|
|||
if corpse[c] > 0.0:
|
||||
corpse[c] = maxf(corpse[c] - delta, 0.0)
|
||||
if corpse[c] == 0.0:
|
||||
root.visible = false
|
||||
_hide(c)
|
||||
continue
|
||||
if enemy_id[c] < 0:
|
||||
continue
|
||||
|
|
@ -246,6 +246,13 @@ func _animate(c: int, d: int) -> void:
|
|||
_play(c, clip, 0.15)
|
||||
|
||||
|
||||
## Back in the pool: hidden, and its animation stopped so an idle character costs nothing (acquire
|
||||
## clears the clip, so the next enemy's starts on its first frame).
|
||||
func _hide(c: int) -> void:
|
||||
_roots[c].visible = false
|
||||
_anims[c].stop()
|
||||
|
||||
|
||||
func _play(c: int, clip: StringName, blend: float) -> void:
|
||||
_clip[c] = clip
|
||||
if _anims[c].has_animation(clip):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue