Added effects manager and two effects to test attached to the player
scene.
This commit is contained in:
parent
1200ac7e32
commit
b4c4a66ce8
19 changed files with 322 additions and 40 deletions
|
|
@ -1,25 +0,0 @@
|
|||
class_name EffectComponent
|
||||
extends Node2D
|
||||
|
||||
@export var target_node: Node
|
||||
|
||||
var active_effects: Array[BaseEffect] = []
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# Process all active effects backwards so we can safely remove finished ones
|
||||
for i in range(active_effects.size() - 1, -1, -1):
|
||||
var effect = active_effects[i]
|
||||
effect.process(delta, target_node)
|
||||
|
||||
# Example: simple time-based expiration
|
||||
effect.duration -= delta
|
||||
if effect.duration <= 0.0:
|
||||
remove_effect(effect)
|
||||
|
||||
func apply_effect(effect: BaseEffect) -> void:
|
||||
effect.start(target_node)
|
||||
active_effects.append(effect)
|
||||
|
||||
func remove_effect(effect: BaseEffect) -> void:
|
||||
effect.stop(target_node)
|
||||
active_effects.erase(effect)
|
||||
Loading…
Add table
Add a link
Reference in a new issue