26 lines
617 B
GDScript
26 lines
617 B
GDScript
class_name Weapon extends Node3D
|
|
|
|
var stats: WeaponStats
|
|
var attachments: Array[Attachment]
|
|
|
|
func init_weapon(stats: WeaponStats):
|
|
self.stats = stats;
|
|
|
|
func attach(newAttachment: Attachment)-> void:
|
|
attachments.append(newAttachment)
|
|
|
|
func unattach(attachmentToRemove: Attachment)-> void:
|
|
attachments.erase(attachmentToRemove)
|
|
|
|
func get_damage()->int:
|
|
var damage = stats.damage
|
|
for attachment in attachments:
|
|
damage += attachment.stats.damage
|
|
return damage
|
|
|
|
func get_fire_rate()->int:
|
|
var fire_rate = stats.fire_rate
|
|
for attachment in attachments:
|
|
fire_rate += attachment.stats.fire_rate
|
|
return fire_rate
|