added project with nerabochie cows
This commit is contained in:
9
scenes/components/collectable_component.gd
Normal file
9
scenes/components/collectable_component.gd
Normal file
@ -0,0 +1,9 @@
|
||||
class_name CollectableComponent
|
||||
extends Area2D
|
||||
|
||||
@export var collectable_name : String
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
if body is Player:
|
||||
print("Collected")
|
||||
get_parent().queue_free()
|
||||
1
scenes/components/collectable_component.gd.uid
Normal file
1
scenes/components/collectable_component.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dwlg7rbe070vb
|
||||
10
scenes/components/collectable_component.tscn
Normal file
10
scenes/components/collectable_component.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dk2en4pak8e6f"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dwlg7rbe070vb" path="res://scenes/components/collectable_component.gd" id="1_14mdg"]
|
||||
|
||||
[node name="CollectableComponent" type="Area2D"]
|
||||
collision_layer = 32
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_14mdg")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
13
scenes/components/damage_component.gd
Normal file
13
scenes/components/damage_component.gd
Normal file
@ -0,0 +1,13 @@
|
||||
class_name DamageComponent
|
||||
extends Node2D
|
||||
|
||||
@export var max_damage = 1
|
||||
@export var current_damage = 0
|
||||
|
||||
signal max_damaged_reached
|
||||
|
||||
func apply_damage(damage: int) -> void:
|
||||
current_damage = clamp(current_damage + damage, 0, max_damage)
|
||||
|
||||
if current_damage == max_damage:
|
||||
max_damaged_reached.emit()
|
||||
1
scenes/components/damage_component.gd.uid
Normal file
1
scenes/components/damage_component.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dabtkv831n7fm
|
||||
6
scenes/components/damage_component.tscn
Normal file
6
scenes/components/damage_component.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cd3awkrirej8q"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dabtkv831n7fm" path="res://scenes/components/damage_component.gd" id="1_am71n"]
|
||||
|
||||
[node name="DamageComponent" type="Node2D"]
|
||||
script = ExtResource("1_am71n")
|
||||
5
scenes/components/hit_component.gd
Normal file
5
scenes/components/hit_component.gd
Normal file
@ -0,0 +1,5 @@
|
||||
class_name HitComponent
|
||||
extends Area2D
|
||||
|
||||
@export var current_tool : DataTypes.Tools = DataTypes.Tools.None
|
||||
@export var hit_damage : int = 1
|
||||
1
scenes/components/hit_component.gd.uid
Normal file
1
scenes/components/hit_component.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://tetr72as3jkf
|
||||
8
scenes/components/hit_component.tscn
Normal file
8
scenes/components/hit_component.tscn
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://04bcami5g18j"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://tetr72as3jkf" path="res://scenes/components/hit_component.gd" id="1_t7wh5"]
|
||||
|
||||
[node name="HitComponent" type="Area2D"]
|
||||
collision_layer = 8
|
||||
collision_mask = 16
|
||||
script = ExtResource("1_t7wh5")
|
||||
12
scenes/components/hurt_component.gd
Normal file
12
scenes/components/hurt_component.gd
Normal file
@ -0,0 +1,12 @@
|
||||
class_name HurtComponent
|
||||
extends Area2D
|
||||
|
||||
@export var tool : DataTypes.Tools = DataTypes.Tools.None
|
||||
|
||||
signal hurt
|
||||
|
||||
|
||||
func _on_area_entered(area: Area2D) -> void:
|
||||
var hit_component = area as HitComponent
|
||||
if tool == hit_component.current_tool:
|
||||
hurt.emit(hit_component.hit_damage)
|
||||
1
scenes/components/hurt_component.gd.uid
Normal file
1
scenes/components/hurt_component.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b24ulc41sykw5
|
||||
10
scenes/components/hurt_component.tscn
Normal file
10
scenes/components/hurt_component.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c82ghkmm1uxfp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b24ulc41sykw5" path="res://scenes/components/hurt_component.gd" id="1_d1uqi"]
|
||||
|
||||
[node name="HurtComponent" type="Area2D"]
|
||||
collision_layer = 16
|
||||
collision_mask = 8
|
||||
script = ExtResource("1_d1uqi")
|
||||
|
||||
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
|
||||
15
scenes/components/interactable_component.gd
Normal file
15
scenes/components/interactable_component.gd
Normal file
@ -0,0 +1,15 @@
|
||||
class_name InteractableComponent
|
||||
extends Area2D
|
||||
|
||||
signal interactable_activated
|
||||
signal interactable_deactivated
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
interactable_activated.emit()
|
||||
|
||||
|
||||
func _on_body_exited(body: Node2D) -> void:
|
||||
interactable_deactivated.emit()
|
||||
1
scenes/components/interactable_component.gd.uid
Normal file
1
scenes/components/interactable_component.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://clqjplcd1qock
|
||||
11
scenes/components/interactable_component.tscn
Normal file
11
scenes/components/interactable_component.tscn
Normal file
@ -0,0 +1,11 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://d3iqdpvqhfyf5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://clqjplcd1qock" path="res://scenes/components/interactable_component.gd" id="1_onphe"]
|
||||
|
||||
[node name="InteractableComponent" type="Area2D"]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_onphe")
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
[connection signal="body_exited" from="." to="." method="_on_body_exited"]
|
||||
Reference in New Issue
Block a user