39 lines
996 B
GDScript
39 lines
996 B
GDScript
class_name MaskData extends Resource
|
|
|
|
enum MaskType { MELEE, RANGED, SPIT }
|
|
|
|
@export_group("Assets")
|
|
@export var mask_name: String
|
|
@export var texture: Texture2D
|
|
@export var drop_texture: Texture2D
|
|
@export var spawn_sfx : String
|
|
|
|
@export_group("Combat")
|
|
@export var attack_scene: PackedScene
|
|
@export var cooldown: float = 0.5
|
|
@export var damage: int = 1
|
|
@export var is_parented_to_attacker: bool = false
|
|
|
|
func activate(attacker: Node2D, target_pos: Vector2) -> void:
|
|
if not attack_scene:
|
|
return
|
|
|
|
var atk = attack_scene.instantiate()
|
|
|
|
if is_parented_to_attacker:
|
|
attacker.add_child(atk)
|
|
atk.position = Vector2.ZERO
|
|
else:
|
|
attacker.get_parent().add_child(atk)
|
|
atk.global_position = attacker.global_position
|
|
|
|
atk.look_at(target_pos)
|
|
|
|
if atk.get("start_position"):
|
|
atk.start_position = attacker.global_position
|
|
atk.target_position = target_pos
|
|
|
|
if atk.has_method("set_from_player"):
|
|
atk.set_from_player(attacker.is_in_group("player"))
|
|
|
|
SoundManager.play_sfx(spawn_sfx)
|