-
Notifications
You must be signed in to change notification settings - Fork 258
Void spreading enemy: Add defeat method #1370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Actually it's not, as I discovered in #1282 (comment) you can configure a signal connection to discard arguments of the signal that the receiving method doesn't want |
|
Play this branch at https://endlessm.github.io/threadbare/branches/endlessm/void-enemy-defeat. (This launches the game from the start, not directly at the change(s) in this pull request.) |
Ah great! I'll use that instead. |
6b1824c to
425bda8
Compare
| for particles: GPUParticles2D in get_children().filter( | ||
| func(c: Node) -> bool: return c is GPUParticles2D | ||
| ): | ||
| await particles.finished |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might work in practice but in theory it won't work as you expect. Suppose you have 2 GPUParticles2D child nodes, A and B. Suppose they are in the scene tree in that order. But suppose B emits finished before A. This loop will first await A.finished, and then await B.finished which will never come.
In practice I think it works because particles are will emit finished in the order that they appear in the scene tree.
I think a better approach would be to do this in _emit_particles:
func _emit_particle() -> void:
_live_particles += 1
# current body
_live_particles -= 1
if state == DEFEATED and _live_particles == 0:
queue_free()And then in this function, replace this loop with:
if _live_particles == 0:
queue_free()
# else wait for `_emit_particles` to free this node after all particles are finished.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a very good point, I was in doubt and since it worked in practice, I moved on. While doing this I checked an addon: https://godotengine.org/asset-library/asset/3592
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find - I was wondering how hard it would be to write that the other day!
When called, wait for all particles to finish and then queue free. This can be a callback of an Area2D body_entered signal. Co-authored-by: Will Thompson <wjt@endlessaccess.org>
425bda8 to
4b26a7d
Compare
When called, wait for all particles to finish and then queue free.
This can be a callback of an Area2D body_entered signal.
This allows a scene to have with multiple Void enemies, each one chasing the player after the other. The player has to run (or walk!) from the Area2D that triggers the chasing to the Area2D that defeats the enemy.