Explosion_der_Spiele/scripts/combat/cheese_projectile.gd
copilot 1d9e0a6532 Wire quest flow and combat across all levels.
Connect bear-save, massage, farm paywall, cheese catapults, Dressler hijack, final boss phases, fat-stim UI, and scene fixes so the satire path plays through.
2026-09-14 19:08:00 +02:00

40 lines
1.1 KiB
GDScript

extends Area3D
class_name CheeseProjectile
## Moldy cheese shot at the player. Attack the cheese (not the seller) to destroy it.
var velocity: Vector3 = Vector3.ZERO
var lifetime: float = 5.0
var hp: int = 1
func _ready() -> void:
collision_layer = 4
collision_mask = 2
monitoring = true
body_entered.connect(_on_body)
add_to_group("enemy")
add_to_group("cheese_projectile")
var bill := get_node_or_null("BillboardSprite")
if bill and bill.has_method("set_texture"):
var tex: Texture2D = load("res://assets/sprites/placeholders/cheese.png")
if tex:
bill.set_texture(tex)
func _physics_process(delta: float) -> void:
global_position += velocity * delta
lifetime -= delta
if lifetime <= 0.0:
call_deferred("queue_free")
func take_hit(_amount: int = 1) -> void:
hp -= 1
AudioDirector.play_hit()
if hp <= 0:
var seller = get_meta("seller", null)
if seller != null and is_instance_valid(seller) and seller.has_method("notify_cheese_destroyed"):
seller.notify_cheese_destroyed()
call_deferred("queue_free")
func _on_body(body: Node3D) -> void:
if body.is_in_group("player"):
GameState.die("death_cheese")
call_deferred("queue_free")