diff --git a/modules/weapons/Weapon.gd b/modules/weapons/Weapon.gd new file mode 100644 index 0000000..d6e728b --- /dev/null +++ b/modules/weapons/Weapon.gd @@ -0,0 +1,39 @@ +class_name Weapon extends Node + +enum Type { + MELEE, + PROJECTILE, + AOF, # area of effect + RAY, +} + +var effects : Callable +var durationInMilliseconds : int +var area: Area2D + +func onBodyEntered (): + print('onBodyEntered') + +func onTimeEnd (): + print('onTimeEnd') + + +func _ready() -> void: + var children = self.get_children() + for i in children.size(): + if (children[i] is Area2D): + area = children[i] + area.connect('body_entered', onBodyEntered) + + +func _process(delta: float) -> void: + set_process(true) + + +func _physics_process(delta: float) -> void: + if (durationInMilliseconds > 0): + durationInMilliseconds -= delta * 1000 + if durationInMilliseconds <= 0: + durationInMilliseconds = 0 # Ensure duration doesn't go negative + set_process(false) +