Files
richard 09d4a60f43 Reorganize into role-based folders and consolidate art
Move every script and scene into role-based directories (actors/, systems/, ui/,
levels/, props/) and all raw art under art/ (grouped by role, snake_case,
Extract-Textures GLBs), dropping Blender version-suffix noise. Filenames are
snake_case (PascalCase reserved for class_name) to avoid case-insensitive
filesystem aliasing on the web/macOS targets. Routes the bull's hits through the
typed DamageEvent pipeline and wires the bull's abilities to the Fx library.
Updates CLAUDE.md's folder-layout overview to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CCyaJPTHCH9EDthpf4A5Sj
2026-09-08 14:56:22 +03:00

42 lines
1.3 KiB
GDScript

extends StaticBody3D
## A smashable lobby barrel. Joins the &"barrel" group so the HUD can tally how many
## remain and fire the "cleared the lobby" reward once the last one bursts.
signal destroyed
# Preload the broken barrel scene
const BARREL_BROKEN_SCENE = preload("res://props/barrel_broken.tscn")
var _destroyed := false
func _ready() -> void:
add_to_group(&"barrel")
func destroy_barrel():
# Guard against a double hit in the same frame counting the same barrel twice.
if _destroyed:
return
_destroyed = true
# 1. Instantiate the broken pieces
var broken_instance = BARREL_BROKEN_SCENE.instantiate()
# 2. Place the fragments exactly where the intact barrel currently is
broken_instance.global_transform = self.global_transform
# 3. Add the fragments to the main game tree
get_parent().add_child(broken_instance)
# 4. (Optional) Apply a physics push to the fragments if you want an explosive effect
for child in broken_instance.get_children():
if child is RigidBody3D:
# Pushes pieces slightly outward and upward
var random_direction = Vector3(randf_range(-1, 1), randf_range(0.5, 1.5), randf_range(-1, 1)).normalized()
child.apply_central_impulse(random_direction * 5.0)
# 5. Announce the smash (the HUD counts down remaining barrels) and remove the barrel
destroyed.emit()
queue_free()