Houses ~8.5 m; chimps capped ~0.85 m with safer axis fitting. Large GLB/PBR packs stay local until Git LFS (Forgejo HTTP 413). Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
1.2 KiB
GDScript
45 lines
1.2 KiB
GDScript
extends Area3D
|
|
class_name HazardZone
|
|
## Damages the player on enter. Optional billboard art via texture_path.
|
|
|
|
@export var damage: int = 1
|
|
@export var death_cause_key: String = "death_default"
|
|
@export var cooldown: float = 1.0
|
|
@export var texture_path: String = ""
|
|
@export var billboard_height: float = 1.4
|
|
|
|
var _ready_to_hurt: bool = true
|
|
|
|
func _ready() -> void:
|
|
body_entered.connect(_on_body_entered)
|
|
collision_layer = 0
|
|
collision_mask = 2
|
|
_ensure_billboard()
|
|
|
|
func _ensure_billboard() -> void:
|
|
if texture_path == "":
|
|
return
|
|
var bill := get_node_or_null("BillboardSprite")
|
|
if bill == null:
|
|
var packed: PackedScene = load("res://scenes/prefabs/billboard_sprite.tscn")
|
|
if packed == null:
|
|
return
|
|
bill = packed.instantiate()
|
|
bill.name = "BillboardSprite"
|
|
add_child(bill)
|
|
if bill.has_method("set_target_height"):
|
|
bill.set_target_height(billboard_height)
|
|
if bill.has_method("set_texture"):
|
|
var tex: Texture2D = load(texture_path)
|
|
if tex:
|
|
bill.set_texture(tex)
|
|
|
|
func _on_body_entered(body: Node3D) -> void:
|
|
if not _ready_to_hurt:
|
|
return
|
|
if not body.is_in_group("player"):
|
|
return
|
|
_ready_to_hurt = false
|
|
GameState.take_damage(damage, death_cause_key)
|
|
await get_tree().create_timer(cooldown).timeout
|
|
_ready_to_hurt = true
|