bomb.gd 489 B

12345678910111213141516171819202122232425262728
  1. extends Area2D
  2. var in_area = []
  3. var from_player
  4. # Called from the animation.
  5. func explode():
  6. if not is_network_master():
  7. # Explode only on master.
  8. return
  9. for p in in_area:
  10. if p.has_method("exploded"):
  11. # Exploded has a master keyword, so it will only be received by the master.
  12. p.rpc("exploded", from_player)
  13. func done():
  14. queue_free()
  15. func _on_bomb_body_enter(body):
  16. if not body in in_area:
  17. in_area.append(body)
  18. func _on_bomb_body_exit(body):
  19. in_area.erase(body)