''' 此Resource定义了一系列的Prop可能需要的预设的简单Effect，如果有更复杂的需求，应该重写State的OnEnter
'''
@tool
@icon("uid://cw1yyc4oeph85")
extends Resource
class_name ReedPropEffect

##用来选择Effect作用的对象
@export var effect_target_type: EffectTargetType = ETT_Owner.new()
##用来选择Effect作用的具体效果
@export var effect_apply_type: EffectApplyType = EAT_SetValue.new()

## 运行时缓存
var _cached_old_value: Variant

##应用效果
func apply(owner: Node, prop_comp: Node, ctx: Dictionary) -> void:
	var target := _resolve_target(owner, prop_comp)
	if target == null:
		return

	if not effect_apply_type:
		return
	
	effect_apply_type.apply(target)

##获取到组件或对象
func _resolve_target(owner: Node, prop_comp: Node) -> Object:
	if effect_target_type == null:
		return null
	return effect_target_type.get_effect_target(owner,prop_comp)
