53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using UnityEngine;
|
||
|
||
namespace BaseGames.Combat
|
||
{
|
||
/// <summary>
|
||
/// 攻击数据源 SO。描述单次攻击的基础伤害参数。
|
||
/// ⚡ 热路径使用零分配工厂:DamageInfo.From(sourceSO)。
|
||
/// 仅需链式覆盖多字段时才使用 CreateBuilder()。
|
||
/// </summary>
|
||
[CreateAssetMenu(menuName = "Combat/DamageSource")]
|
||
public class DamageSourceSO : ScriptableObject
|
||
{
|
||
[Header("Identity")]
|
||
public string sourceId;
|
||
public string skillId;
|
||
|
||
[Header("Base")]
|
||
public int BaseDamage = 10;
|
||
public float DamageMultiplier = 1.0f;
|
||
public DamageType Type = DamageType.Normal;
|
||
public DamageCategory Category = DamageCategory.NormalAttack;
|
||
public DamageFlags Flags = DamageFlags.CanBeParried;
|
||
public DamageTags Tags = DamageTags.MeleeHit;
|
||
|
||
[Header("Physics")]
|
||
public float KnockbackForce = 5f;
|
||
public float HitStunDuration = 0.1f;
|
||
public BreakLevel BreakLevel = BreakLevel.Light;
|
||
|
||
[Header("FX")]
|
||
public HitFxType FxType = HitFxType.Slash;
|
||
|
||
[Header("Combo")]
|
||
public float ComboWindowDuration = 0.4f;
|
||
public float CancelWindowEnd = 0.5f;
|
||
|
||
/// <summary>
|
||
/// 链式 Builder(特殊场景使用,热路径改用 DamageInfo.From(this))。
|
||
/// </summary>
|
||
public DamageInfo.Builder CreateBuilder() => new DamageInfo.Builder()
|
||
.SetRaw(Mathf.RoundToInt(BaseDamage * DamageMultiplier))
|
||
.SetType(Type)
|
||
.SetCategory(Category)
|
||
.SetFlags(Flags)
|
||
.SetTags(Tags)
|
||
.SetStun(HitStunDuration)
|
||
.SetFx(FxType)
|
||
.SetBreak(BreakLevel)
|
||
.SetSourceId(sourceId)
|
||
.SetSkillId(skillId);
|
||
}
|
||
}
|