summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies/Tree.gd
blob: 5572e02aa2a836ff8baabb91cee4624e378960d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
extends CharacterBody2D


@onready var component_collision: ComponentCollision = $Collision
@onready var component_movement: ComponentMovement = $Movement


func _ready():
	add_to_group("enemies")
	
	component_collision.init()
	component_collision.collision_area.set_collision_mask_value(Utilities.Collision.Layer.EXPLOSION, false)
	
	component_movement.process_mode = Node.PROCESS_MODE_DISABLED
	set_physics_process(false)
	$AnimatedSprite2D.play("spawn")
	$AnimatedSprite2D.stop()
	$AnimatedSprite2D.set_frame_and_progress(0, 0)


func _physics_process(delta):
	component_movement.physics_process(delta)


func _on_detection_body_entered(_body):
	$AnimatedSprite2D.play("spawn")
	await $AnimatedSprite2D.animation_finished
	component_collision.collision_area.set_collision_mask_value(Utilities.Collision.Layer.EXPLOSION, true)
	component_movement.process_mode = Node.PROCESS_MODE_INHERIT
	set_physics_process(true)