class_name HitBox extends Area3D ## Konstanten statt magischer Zahlen für bessere Lesbarkeit/Wartbarkeit const COLLISION_LAYER: int = 2 const COLLISION_MASK: int = 2 const DEFAULT_DAMAGE: int = 0 func _ready() -> void: # Initialisierung im _ready, wenn der Node sicher im Baum ist collision_layer = COLLISION_LAYER collision_mask = COLLISION_MASK ## Liefert den Schaden des Owners, falls dieser eine entsprechende API anbietet. ## Erwartet eine Methode `get_damage()` am Owner. Fällt sonst auf DEFAULT_DAMAGE zurück. func get_owner_damage() -> int: if owner == null: return DEFAULT_DAMAGE if owner.has_method("get_damage"): return int(owner.call("get_damage")) return DEFAULT_DAMAGE