Explosion.gd 449 B

123456789101112131415161718
  1. class_name Explosion
  2. extends Node2D
  3. const destructable_tiles := {Vector2i(4, 0): Rect2(32, 160, 16, 16), Vector2i(4, 2): Rect2(48, 160, 16, 16)}
  4. const BLOCK_DESTRUCTION_PARTICLES = preload("uid://cyw7kk1em8h16")
  5. func on_body_entered(body: Node2D) -> void:
  6. if body is Block:
  7. if body.destructable: body.destroy()
  8. if body is Player:
  9. body.damage()
  10. func on_area_entered(area: Area2D) -> void:
  11. if area.owner is Player:
  12. area.owner.damage()