Phase 1: 复合属性修饰器管线与伤害结算系统

This commit is contained in:
2026-09-24 22:37:22 +08:00
parent ba25ec1926
commit 02f4c67464
35 changed files with 334 additions and 141 deletions
@@ -51,13 +51,39 @@ namespace SepCore.CustomUtility
string colorTag = statModifierConfig.Value >= 0 ? "green" : "red";
string sign = statModifierConfig.Value >= 0 ? "+" : "";
if (statModifierConfig.ModifierType == ModifierType.PercentAdd)
StatConfig statConfig = null;
if (GameEntry.Luban != null && GameEntry.Luban.IsReady)
{
statConfig = GameEntry.Luban.Get<StatConfig>(index);
}
if (statConfig != null && !string.IsNullOrEmpty(statConfig.Name))
{
name = statConfig.Name;
}
// 是否以百分比展示:由 StatConfig.IsPercentDisplay 真正驱动(Luban 未就绪时 fallback 到已知百分比属性)
bool isPercentDisplay = statConfig != null
? statConfig.IsPercentDisplay
: (statModifierConfig.StatType is StatType.DamagePercent or StatType.AttackSpeed or StatType.CritChance or StatType.Dodge);
// 1. 修饰类型判断
bool isPercentAdd = statModifierConfig.ModifierType == ModifierType.PercentAdd;
bool isPercentMult = statModifierConfig.ModifierType == ModifierType.PercentMult;
bool isFlat = statModifierConfig.ModifierType == ModifierType.Flat;
// 2. UI 百分比展示裁决:
// - 任意属性的 PercentAdd 词条属于比例加成(如 攻速 +19%、伤害 +5%、移速 +15%)
// - 或属性自身在配置表中标记为百分比显示(IsPercentDisplay 为 true,如暴击率、闪避率等),其 Flat 加成应以百分比呈现(如 0.1 -> +10%)
bool shouldDisplayAsPercent = isPercentAdd || (isFlat && isPercentDisplay);
if (shouldDisplayAsPercent)
{
float displayPercent = statModifierConfig.Value * 100f;
return $"{name}: <color={colorTag}>{sign}{displayPercent:0.##}%</color>";
}
if (statModifierConfig.ModifierType == ModifierType.PercentMult)
if (isPercentMult)
{
return $"{name}: <color={colorTag}>x{statModifierConfig.Value:0.##}</color>";
}
@@ -89,8 +115,8 @@ namespace SepCore.CustomUtility
return null;
}
return CreateWeaponDescription(weaponConfig.Attack, weaponConfig.Cooldown / 1000f,
weaponConfig.AttackRange / 1000f, weaponConfig.StatModifierConfigs, weaponConfig.Parameters);
return CreateWeaponDescription(weaponConfig.Attack, weaponConfig.Cooldown,
weaponConfig.AttackRange, weaponConfig.StatModifierConfigs, weaponConfig.Parameters);
}
public static string CreateWeaponDescription(WeaponBase weapon)
@@ -125,7 +151,7 @@ namespace SepCore.CustomUtility
}
private static string CreateWeaponDescription(int attack, float cooldown, float attackRange,
IEnumerable<StatModifierConfig> modifiers, IReadOnlyDictionary<ParamType, int> parameters)
IEnumerable<StatModifierConfig> modifiers, IReadOnlyDictionary<ParamType, float> parameters)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine($"攻击: {attack}");
@@ -152,7 +178,7 @@ namespace SepCore.CustomUtility
string valStr = kvp.Key == ParamType.SectorAngle
? kvp.Value.ToString()
: (kvp.Value / 1000f).ToString("0.##");
: kvp.Value.ToString("0.##");
sb.AppendLine($"{paramName}: {valStr}");
}