Added a loot component
This commit is contained in:
parent
a510a5bb7b
commit
38133969fc
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=27 format=3 uid="uid://b40y7iuskv1ar"]
|
[gd_scene load_steps=26 format=3 uid="uid://b40y7iuskv1ar"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://Main.gd" id="1_cw3ws"]
|
[ext_resource type="Script" path="res://Main.gd" id="1_cw3ws"]
|
||||||
[ext_resource type="Script" path="res://network/Client.gd" id="2_8hxcx"]
|
[ext_resource type="Script" path="res://network/Client.gd" id="2_8hxcx"]
|
||||||
@ -21,7 +21,6 @@
|
|||||||
[ext_resource type="Material" uid="uid://bdsblfaxbipaa" path="res://world/grass/GrassMaterial.tres" id="18_tja64"]
|
[ext_resource type="Material" uid="uid://bdsblfaxbipaa" path="res://world/grass/GrassMaterial.tres" id="18_tja64"]
|
||||||
[ext_resource type="MultiMesh" uid="uid://dog5aq5n2q025" path="res://assets/grass/grass.multimesh" id="19_ae26a"]
|
[ext_resource type="MultiMesh" uid="uid://dog5aq5n2q025" path="res://assets/grass/grass.multimesh" id="19_ae26a"]
|
||||||
[ext_resource type="PackedScene" uid="uid://cm0rho6adv2p7" path="res://world/water/Water.tscn" id="20_bmo3k"]
|
[ext_resource type="PackedScene" uid="uid://cm0rho6adv2p7" path="res://world/water/Water.tscn" id="20_bmo3k"]
|
||||||
[ext_resource type="PackedScene" uid="uid://daaqqc0e3gy7b" path="res://test/souls.tscn" id="21_8ne8m"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://b0w38xjifulq6" path="res://assets/house/House.blend" id="23_5j7b3"]
|
[ext_resource type="PackedScene" uid="uid://b0w38xjifulq6" path="res://assets/house/House.blend" id="23_5j7b3"]
|
||||||
|
|
||||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_he5c5"]
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_he5c5"]
|
||||||
@ -119,6 +118,36 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 5.11323, 0, 7.80548)
|
|||||||
[node name="Slime" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
[node name="Slime" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.53558, 1.28057, -3.79687)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.53558, 1.28057, -3.79687)
|
||||||
|
|
||||||
|
[node name="Slime4" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.37742, 1.28057, 9.85779)
|
||||||
|
|
||||||
|
[node name="Slime5" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.00287, 1.28057, 8.21748)
|
||||||
|
|
||||||
|
[node name="Slime6" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.34112, 1.28057, 10.4239)
|
||||||
|
|
||||||
|
[node name="Slime7" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.16031, 1.28057, 9.27569)
|
||||||
|
|
||||||
|
[node name="Slime8" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.94264, 1.28057, 7.91351)
|
||||||
|
|
||||||
|
[node name="Slime9" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -9.94264, 1.28057, 0.495064)
|
||||||
|
|
||||||
|
[node name="Slime10" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -8.80971, 1.28057, -0.975526)
|
||||||
|
|
||||||
|
[node name="Slime11" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -5.41412, 1.28057, -9.61036)
|
||||||
|
|
||||||
|
[node name="Slime12" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.40571, 1.28057, -11.0707)
|
||||||
|
|
||||||
|
[node name="Slime13" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.04643, 1.28057, -10.0513)
|
||||||
|
|
||||||
[node name="Slime2" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
[node name="Slime2" parent="World/Enemies" instance=ExtResource("15_hgl78")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.00829, 1.28057, -1.95247)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 7.00829, 1.28057, -1.95247)
|
||||||
|
|
||||||
@ -176,12 +205,6 @@ skeleton = NodePath("../..")
|
|||||||
[node name="House" parent="World" instance=ExtResource("23_5j7b3")]
|
[node name="House" parent="World" instance=ExtResource("23_5j7b3")]
|
||||||
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -6.04985, 0, -6.15938)
|
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, -6.04985, 0, -6.15938)
|
||||||
|
|
||||||
[node name="Souls" parent="World" instance=ExtResource("21_8ne8m")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, -9)
|
|
||||||
|
|
||||||
[node name="Souls2" parent="World" instance=ExtResource("21_8ne8m")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3, 0, 9)
|
|
||||||
|
|
||||||
[node name="Players" type="Node3D" parent="."]
|
[node name="Players" type="Node3D" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
script = ExtResource("16_dp6bj")
|
script = ExtResource("16_dp6bj")
|
||||||
|
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="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="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://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://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://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"]
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_ub3kk"]
|
||||||
height = 0.5
|
height = 0.5
|
||||||
@ -64,3 +66,7 @@ autoplay = "slime_idle"
|
|||||||
max_value = 100.0
|
max_value = 100.0
|
||||||
|
|
||||||
[node name="Movement" parent="." instance=ExtResource("3_2phqx")]
|
[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")
|
||||||
|
@ -66,9 +66,10 @@ billboard_mode = 1
|
|||||||
billboard_keep_scale = true
|
billboard_keep_scale = true
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_rytrf"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_rytrf"]
|
||||||
radius = 1.5
|
radius = 1.0
|
||||||
|
|
||||||
[node name="Soul" type="Node3D"]
|
[node name="Soul" type="Node3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
|
||||||
script = ExtResource("1_mm7cb")
|
script = ExtResource("1_mm7cb")
|
||||||
|
|
||||||
[node name="Particles" type="GPUParticles3D" parent="."]
|
[node name="Particles" type="GPUParticles3D" parent="."]
|
||||||
@ -77,6 +78,7 @@ cast_shadow = 0
|
|||||||
amount = 50
|
amount = 50
|
||||||
sub_emitter = NodePath("../Trail")
|
sub_emitter = NodePath("../Trail")
|
||||||
lifetime = 0.5
|
lifetime = 0.5
|
||||||
|
visibility_aabb = AABB(-1, -0.5, -1, 2, 2, 2)
|
||||||
transform_align = 1
|
transform_align = 1
|
||||||
process_material = SubResource("ParticleProcessMaterial_uyeuh")
|
process_material = SubResource("ParticleProcessMaterial_uyeuh")
|
||||||
draw_pass_1 = SubResource("QuadMesh_6nr8a")
|
draw_pass_1 = SubResource("QuadMesh_6nr8a")
|
||||||
@ -85,6 +87,7 @@ draw_pass_1 = SubResource("QuadMesh_6nr8a")
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
amount = 5000
|
amount = 5000
|
||||||
lifetime = 0.5
|
lifetime = 0.5
|
||||||
|
visibility_aabb = AABB(-1, -0.5, -1, 2, 2, 2)
|
||||||
transform_align = 1
|
transform_align = 1
|
||||||
process_material = SubResource("ParticleProcessMaterial_l1npq")
|
process_material = SubResource("ParticleProcessMaterial_l1npq")
|
||||||
draw_pass_1 = SubResource("QuadMesh_pthhm")
|
draw_pass_1 = SubResource("QuadMesh_pthhm")
|
||||||
@ -112,7 +115,7 @@ collision_layer = 64
|
|||||||
collision_mask = 512
|
collision_mask = 512
|
||||||
monitorable = false
|
monitorable = false
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area"]
|
[node name="SphereShape" type="CollisionShape3D" parent="Area"]
|
||||||
shape = SubResource("SphereShape3D_rytrf")
|
shape = SubResource("SphereShape3D_rytrf")
|
||||||
|
|
||||||
[connection signal="body_entered" from="Area" to="." method="on_body_entered"]
|
[connection signal="body_entered" from="Area" to="." method="on_body_entered"]
|
||||||
|
@ -2,6 +2,9 @@ class_name HealthComponent
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
signal value_changed
|
signal value_changed
|
||||||
|
signal death
|
||||||
|
|
||||||
|
const DEATH_THRESHOLD = 0.01
|
||||||
|
|
||||||
@export var max_value: float
|
@export var max_value: float
|
||||||
var value: float
|
var value: float
|
||||||
@ -11,8 +14,8 @@ func _ready():
|
|||||||
value_changed.emit()
|
value_changed.emit()
|
||||||
|
|
||||||
func take_damage(attack: DamageInstance):
|
func take_damage(attack: DamageInstance):
|
||||||
value -= attack.damage
|
value = clampf(value - attack.damage, 0, max_value)
|
||||||
value_changed.emit()
|
value_changed.emit()
|
||||||
|
|
||||||
if value <= 0:
|
if value < DEATH_THRESHOLD:
|
||||||
owner.queue_free()
|
death.emit()
|
||||||
|
@ -2,13 +2,14 @@ class_name SkillsComponent
|
|||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var player: Player
|
var player: Player
|
||||||
|
var area: Area3D
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
player = owner
|
player = owner
|
||||||
|
area = %MeleeArea
|
||||||
player.attacked.connect(attack)
|
player.attacked.connect(attack)
|
||||||
|
|
||||||
func attack():
|
func attack():
|
||||||
var area := %MeleeArea as Area3D
|
|
||||||
await get_tree().create_timer(0.5).timeout
|
await get_tree().create_timer(0.5).timeout
|
||||||
area.monitoring = true
|
area.monitoring = true
|
||||||
await get_tree().create_timer(0.1).timeout
|
await get_tree().create_timer(0.1).timeout
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://daaqqc0e3gy7b"]
|
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://dl4vcp04t8iyr" path="res://item/soul/Soul.tscn" id="1_8iduu"]
|
|
||||||
|
|
||||||
[node name="Souls" type="Node3D"]
|
|
||||||
|
|
||||||
[node name="Soul" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 0)
|
|
||||||
|
|
||||||
[node name="Soul2" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, 2)
|
|
||||||
|
|
||||||
[node name="Soul3" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8, -2)
|
|
||||||
|
|
||||||
[node name="Soul4" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0.8, 0)
|
|
||||||
|
|
||||||
[node name="Soul5" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0.8, 2)
|
|
||||||
|
|
||||||
[node name="Soul6" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0.8, -2)
|
|
||||||
|
|
||||||
[node name="Soul7" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0.8, 0)
|
|
||||||
|
|
||||||
[node name="Soul8" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0.8, 2)
|
|
||||||
|
|
||||||
[node name="Soul9" parent="." instance=ExtResource("1_8iduu")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0.8, -2)
|
|
Loading…
Reference in New Issue
Block a user