bodypartfighter/BodyParts/PushingBodyPart.gd
2020-02-02 13:59:16 +01:00

36 lines
740 B
GDScript

extends BodyPart
class_name PushingBodyPart
onready var touch_area = get_node("TouchArea")
onready var push_sound = get_node("PushSound")
export(float) var damage = 10.0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
touch_area.connect("body_entered", self, "_on_touch_area_entered")
# Override in derived classes!
func _is_animation_playing():
return true
func _on_touch_area_entered(body):
if body.name != base.name and _is_animation_playing():
if body.is_in_group("Terrain"):
push_wrapper(body)
elif body.is_in_group("Player"):
InGameState.subtract_player_health(body.player_id, damage)
func push_wrapper(body):
push_sound.play(0.0)
push(body)
func push(body):
pass