Added a loot component
This commit is contained in:
15
client/enemy/loot/LootComponent.gd
Normal file
15
client/enemy/loot/LootComponent.gd
Normal file
@ -0,0 +1,15 @@
|
||||
class_name LootComponent
|
||||
extends Node
|
||||
|
||||
@export var health: HealthComponent
|
||||
@export var drop: PackedScene
|
||||
|
||||
func _ready():
|
||||
health.death.connect(on_death)
|
||||
|
||||
func on_death():
|
||||
prints(owner.name, "death")
|
||||
var loot := drop.instantiate() as Node3D
|
||||
owner.get_parent().add_child(loot)
|
||||
loot.global_position = owner.global_position + loot.position
|
||||
owner.queue_free()
|
6
client/enemy/loot/LootComponent.tscn
Normal file
6
client/enemy/loot/LootComponent.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://bfvudkup0xsq4"]
|
||||
|
||||
[ext_resource type="Script" path="res://enemy/loot/LootComponent.gd" id="1_5qhry"]
|
||||
|
||||
[node name="Loot" type="Node"]
|
||||
script = ExtResource("1_5qhry")
|
@ -1,10 +1,12 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://cb2t7bvvf3gwh"]
|
||||
[gd_scene load_steps=12 format=3 uid="uid://cb2t7bvvf3gwh"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://b358op5h1y83m" path="res://assets/slime/Slime.blend" id="1_1h1hj"]
|
||||
[ext_resource type="Script" path="res://enemy/Enemy.gd" id="1_r5888"]
|
||||
[ext_resource type="PackedScene" uid="uid://2bbycjulf00g" path="res://player/health/HealthComponent.tscn" id="2_fsqxc"]
|
||||
[ext_resource type="PackedScene" uid="uid://x102pryt2s5a" path="res://player/movement/MovementComponent.tscn" id="3_2phqx"]
|
||||
[ext_resource type="PackedScene" uid="uid://6jpnl6c4fdvo" path="res://player/hud/HUDComponent.tscn" id="3_4jtio"]
|
||||
[ext_resource type="PackedScene" uid="uid://bfvudkup0xsq4" path="res://enemy/loot/LootComponent.tscn" id="6_68kgw"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl4vcp04t8iyr" path="res://item/soul/Soul.tscn" id="7_i0rtb"]
|
||||
|
||||
[sub_resource type="CylinderShape3D" id="CylinderShape3D_ub3kk"]
|
||||
height = 0.5
|
||||
@ -64,3 +66,7 @@ autoplay = "slime_idle"
|
||||
max_value = 100.0
|
||||
|
||||
[node name="Movement" parent="." instance=ExtResource("3_2phqx")]
|
||||
|
||||
[node name="Loot" parent="." node_paths=PackedStringArray("health") instance=ExtResource("6_68kgw")]
|
||||
health = NodePath("../Health")
|
||||
drop = ExtResource("7_i0rtb")
|
||||
|
Reference in New Issue
Block a user