class_name ActionEffect extends Resource const KIND_METRIC_DELTA := &"metric_delta" const KIND_NEED_DELTA := &"need_delta" const KIND_INVENTORY_TRANSFER := &"inventory_transfer" const KIND_DAMAGE := &"damage" const KIND_HEALING := &"healing" const KIND_RELATIONSHIP_DELTA := &"relationship_delta" const KIND_SCHEDULE_ACTION := &"schedule_action" const KIND_SITE_CONDITION := &"site_condition" const VALID_KINDS := [ KIND_METRIC_DELTA, KIND_NEED_DELTA, KIND_INVENTORY_TRANSFER, KIND_DAMAGE, KIND_HEALING, KIND_RELATIONSHIP_DELTA, KIND_SCHEDULE_ACTION, KIND_SITE_CONDITION, ] @export var effect_id: StringName @export var effect_kind: StringName @export var subject_key: StringName @export var value := 0.0 @export var item_id: StringName @export var amount := 0.0 @export var source_role: StringName @export var destination_role: StringName @export var scheduled_action_id: StringName @export var parameters: Dictionary = {} func validate() -> Array[String]: var errors: Array[String] = [] if effect_id.is_empty(): errors.append("effect_id is empty") if effect_kind not in VALID_KINDS: errors.append("effect_kind '%s' is invalid for '%s'" % [effect_kind, effect_id]) if not is_finite(value) or not is_finite(amount): errors.append("numeric values must be finite for '%s'" % effect_id) match effect_kind: KIND_METRIC_DELTA, KIND_NEED_DELTA, KIND_RELATIONSHIP_DELTA, KIND_SITE_CONDITION: if subject_key.is_empty(): errors.append("subject_key is empty for '%s'" % effect_id) KIND_INVENTORY_TRANSFER: if item_id.is_empty() or amount <= 0.0: errors.append( "inventory transfer '%s' needs an item and positive amount" % effect_id ) if source_role.is_empty() or destination_role.is_empty(): errors.append("inventory transfer '%s' needs source/destination roles" % effect_id) KIND_DAMAGE, KIND_HEALING: if amount <= 0.0: errors.append("effect '%s' needs a positive amount" % effect_id) KIND_SCHEDULE_ACTION: if scheduled_action_id.is_empty(): errors.append("scheduled action is empty for '%s'" % effect_id) if WorldTargetCapability._contains_object(parameters): errors.append("parameters contain a runtime object for '%s'" % effect_id) return errors