using System;
using UnityEngine;
namespace SepCore.Definition
{
///
/// 属性修饰器。
/// 包含修饰数值、修饰类型(固定值/百分比加算/独立乘区)以及来源对象(道具/武器/羁绊/特质/Buff)。
///
public sealed class StatModifier
{
public float Value { get; }
public ModifierType Type { get; }
public object Source { get; }
public StatModifier(float value, ModifierType type, object source = null)
{
Value = value;
Type = type;
Source = source;
}
///
/// 从 Luban 导出的 modifier 数据结构转换。
///
/// Luban modifier 数据实例
/// 来源对象引用
public static StatModifier FromLuban(StatModifierConfig mod, object source = null)
{
if (mod == null)
{
throw new ArgumentNullException(nameof(mod));
}
ModifierType type = mod.ModifierType;
return new StatModifier(mod.Value, type, source);
}
public override string ToString()
{
return $"[StatModifier Type={Type}, Value={Value}, Source={Source}]";
}
}
}