feat(wiring): MobSpawner integration + take_damage API on dolphin
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
6
scenes/mobs/MobSpawner.tscn
Normal file
6
scenes/mobs/MobSpawner.tscn
Normal file
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/mobs/MobSpawner.gd" id="1"]
|
||||
|
||||
[node name="MobSpawner" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
@@ -40,6 +40,15 @@ func _ready() -> void:
|
||||
inventory.add_item(6, 5) # 5 KELP
|
||||
inventory.add_item(8, 2) # 2 ICE
|
||||
|
||||
# Add dolphin to player group (for mob detection)
|
||||
dolphin.add_to_group("player")
|
||||
|
||||
# Spawner de mobs
|
||||
var MobSpawnerScene: PackedScene = load("res://scenes/mobs/MobSpawner.tscn")
|
||||
var mob_spawner: Node3D = MobSpawnerScene.instantiate()
|
||||
add_child(mob_spawner)
|
||||
mob_spawner.player = mob_spawner.get_path_to(dolphin)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
world.update_player_position(dolphin.global_position)
|
||||
|
||||
@@ -250,6 +250,13 @@ func _raycast(reach: float) -> Dictionary:
|
||||
return result
|
||||
|
||||
|
||||
func take_damage(amount: float) -> void:
|
||||
health = max(0.0, health - amount)
|
||||
emit_signal("stats_changed", oxygen, health, hunger)
|
||||
if health <= 0.0:
|
||||
emit_signal("player_died")
|
||||
|
||||
|
||||
func _trigger_echolocation() -> void:
|
||||
if is_echolocating:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user