bomb.gd 496 B

123456789101112131415161718192021222324
  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. # But will call explosion only on master
  8. return
  9. for p in in_area:
  10. if p.has_method("exploded"):
  11. p.rpc("exploded", from_player) # Exploded has a master keyword, so it will only be received by the master
  12. func done():
  13. queue_free()
  14. func _on_bomb_body_enter(body):
  15. if not body in in_area:
  16. in_area.append(body)
  17. func _on_bomb_body_exit(body):
  18. in_area.erase(body)