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>
43 lines
1.2 KiB
GDScript
43 lines
1.2 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:
|
|
if bill.has_method("set_target_height"):
|
|
bill.set_target_height(SpriteFit.WORLD_PROP_HEIGHT)
|
|
if 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")
|