mirror of
https://github.com/RYGhub/the-cold-night.git
synced 2024-11-22 12:44:20 +00:00
⚙️ Dead enemies spawn a branch
This commit is contained in:
parent
1f4c3734c7
commit
6fa26636ba
3 changed files with 21 additions and 1 deletions
|
@ -2,4 +2,7 @@ extends KinematicBody2D
|
||||||
|
|
||||||
|
|
||||||
func _on_Damageable_dead():
|
func _on_Damageable_dead():
|
||||||
|
for child in get_children():
|
||||||
|
if child.name == "BranchSpawn":
|
||||||
|
child.BranchSpawn()
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=8 format=2]
|
[gd_scene load_steps=9 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/mechanics/Black.png" type="Texture" id=1]
|
[ext_resource path="res://src/mechanics/Black.png" type="Texture" id=1]
|
||||||
[ext_resource path="res://src/entities/behaviours/ErraticMovement.tscn" type="PackedScene" id=2]
|
[ext_resource path="res://src/entities/behaviours/ErraticMovement.tscn" type="PackedScene" id=2]
|
||||||
|
@ -6,6 +6,7 @@
|
||||||
[ext_resource path="res://src/entities/behaviours/Damageable.tscn" type="PackedScene" id=4]
|
[ext_resource path="res://src/entities/behaviours/Damageable.tscn" type="PackedScene" id=4]
|
||||||
[ext_resource path="res://src/entities/behaviours/Alliance.tscn" type="PackedScene" id=5]
|
[ext_resource path="res://src/entities/behaviours/Alliance.tscn" type="PackedScene" id=5]
|
||||||
[ext_resource path="res://src/entities/Enemy.gd" type="Script" id=6]
|
[ext_resource path="res://src/entities/Enemy.gd" type="Script" id=6]
|
||||||
|
[ext_resource path="res://src/entities/behaviours/BranchSpawn.gd" type="Script" id=7]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 16, 16 )
|
extents = Vector2( 16, 16 )
|
||||||
|
@ -28,4 +29,7 @@ texture = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Alliance" parent="." instance=ExtResource( 5 )]
|
[node name="Alliance" parent="." instance=ExtResource( 5 )]
|
||||||
alliance = -1
|
alliance = -1
|
||||||
|
|
||||||
|
[node name="BranchSpawn" type="Node" parent="."]
|
||||||
|
script = ExtResource( 7 )
|
||||||
[connection signal="dead" from="Damageable" to="." method="_on_Damageable_dead"]
|
[connection signal="dead" from="Damageable" to="." method="_on_Damageable_dead"]
|
||||||
|
|
13
src/entities/behaviours/BranchSpawn.gd
Normal file
13
src/entities/behaviours/BranchSpawn.gd
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
|
||||||
|
export var branch: PackedScene = preload("res://src/entities/Pickup.tscn")
|
||||||
|
export var branch_container_node_path: String = "../.."
|
||||||
|
onready var branch_container_node: Node = get_node(branch_container_node_path)
|
||||||
|
onready var source: Node2D = get_parent()
|
||||||
|
|
||||||
|
|
||||||
|
func BranchSpawn():
|
||||||
|
var new_branch = branch.instance()
|
||||||
|
new_branch.set_position(source.global_position)
|
||||||
|
branch_container_node.add_child(new_branch)
|
Loading…
Reference in a new issue