Phase 1: 复合属性修饰器管线与伤害结算系统
This commit is contained in:
@@ -13,6 +13,7 @@ namespace SepCore.Battle
|
||||
{
|
||||
private readonly List<StatModifier> _modifiers = new();
|
||||
private float _baseValue;
|
||||
private bool _isBaseValueExplicitlySet;
|
||||
private bool _isDirty = true;
|
||||
private float _cachedValue;
|
||||
private StatConfig _config;
|
||||
@@ -26,6 +27,11 @@ namespace SepCore.Battle
|
||||
if (_config == null && GameEntry.Luban != null && GameEntry.Luban.IsReady)
|
||||
{
|
||||
_config = GameEntry.Luban.Get<StatConfig>((int)Type);
|
||||
if (!_isBaseValueExplicitlySet && _config != null)
|
||||
{
|
||||
_baseValue = _config.DefaultBaseValue;
|
||||
_isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
return _config;
|
||||
@@ -33,15 +39,35 @@ namespace SepCore.Battle
|
||||
set
|
||||
{
|
||||
_config = value;
|
||||
if (!_isBaseValueExplicitlySet && _config != null)
|
||||
{
|
||||
_baseValue = _config.DefaultBaseValue;
|
||||
}
|
||||
_isDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
public float BaseValue
|
||||
{
|
||||
get => _baseValue;
|
||||
get
|
||||
{
|
||||
if (!_isBaseValueExplicitlySet)
|
||||
{
|
||||
if (Config != null)
|
||||
{
|
||||
_baseValue = Config.DefaultBaseValue;
|
||||
}
|
||||
else if (Type is StatType.DamagePercent or StatType.AttackSpeed)
|
||||
{
|
||||
_baseValue = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
return _baseValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
_isBaseValueExplicitlySet = true;
|
||||
if (Math.Abs(_baseValue - value) > 1e-6f)
|
||||
{
|
||||
_baseValue = value;
|
||||
@@ -69,8 +95,21 @@ namespace SepCore.Battle
|
||||
public CharacterStat(StatType type, float baseValue = 0f, StatConfig config = null)
|
||||
{
|
||||
Type = type;
|
||||
_baseValue = baseValue;
|
||||
_config = config;
|
||||
if (Math.Abs(baseValue) > 1e-6f)
|
||||
{
|
||||
_baseValue = baseValue;
|
||||
_isBaseValueExplicitlySet = true;
|
||||
}
|
||||
else if (_config != null)
|
||||
{
|
||||
_baseValue = _config.DefaultBaseValue;
|
||||
_isBaseValueExplicitlySet = true;
|
||||
}
|
||||
else if (type is StatType.DamagePercent or StatType.AttackSpeed)
|
||||
{
|
||||
_baseValue = 1.0f;
|
||||
}
|
||||
_isDirty = true;
|
||||
}
|
||||
|
||||
@@ -154,7 +193,7 @@ namespace SepCore.Battle
|
||||
}
|
||||
}
|
||||
|
||||
float finalValue = ((_baseValue + sumFlat) * (1f + sumPercentAdd)) * prodPercentMult;
|
||||
float finalValue = ((BaseValue + sumFlat) * (1f + sumPercentAdd)) * prodPercentMult;
|
||||
return ClampStat(finalValue);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user