引入属性、伤害管线
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
/// <summary>
|
||||
/// 属性修饰器。
|
||||
/// 包含修饰数值、修饰类型(固定值/百分比加算/独立乘区)以及来源对象(道具/武器/羁绊/特质/Buff)。
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从 Luban 导出的 modifier 数据结构转换。
|
||||
/// </summary>
|
||||
/// <param name="mod">Luban modifier 数据实例</param>
|
||||
/// <param name="source">来源对象引用</param>
|
||||
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}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user