extends StaticBody2D @export_enum("up", "down", "left", "right") var fall_direction: String @onready var map: TileMap = get_parent().get_parent().get_node("TileMap") func _ready(): add_to_group("breakables") var collision_area = Utilities.Collision.Area.new(self, $CollisionShape2D, false) collision_area.connect("collided", Callable(self, "_collide")) add_child(collision_area) func hit_by_explosion(): var direction = Vector2(0, 0) if fall_direction == "up": position.y -= 5 direction = Vector2(0, -1) elif fall_direction == "down": rotate(deg_to_rad(180)) position.y += 5 direction = Vector2(0, 1) elif fall_direction == "left": rotate(deg_to_rad(-90)) position.x -= 5 direction = Vector2(-1, 0) elif fall_direction == "right": rotate(deg_to_rad(90)) position.x += 5 direction = Vector2(1, 0) for r in range(3): var vec = map.local_to_map(self.position + direction*16*r) map.set_cell( 0, vec, 6, map.get_cell_atlas_coords(0, vec), map.get_cell_alternative_tile(0, vec) ) $Edges.process_mode = Node.PROCESS_MODE_INHERIT $CollisionShape2D.disabled = true $SpriteStanding.visible = false $SpriteFallen.visible = true