You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
281 lines
11 KiB
281 lines
11 KiB
using System.Collections.Generic;
|
|
using System.Text;
|
|
using CoreGame;
|
|
using GAS.Runtime;
|
|
using ProtoCSClass;
|
|
using Sog;
|
|
using xFrame;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public static class PropertySrv
|
|
{
|
|
public static GameplayEffectCalc[] s_GEC = new GameplayEffectCalc[(int)GECType.Size];
|
|
public static Dictionary<string, BaseCustomModifer> s_CustomModifer = new(20);
|
|
|
|
private static bool s_Inited = false;
|
|
|
|
public static void Init()
|
|
{
|
|
if (s_Inited)
|
|
return;
|
|
|
|
s_Inited = true;
|
|
s_GEC[(int)GECType.UniformPropertyChange] = new UniformPropertyChange();
|
|
s_GEC[(int)GECType.Bullet] = new BulletDmgCalc();
|
|
s_GEC[(int)GECType.Dot] = new DotDmgCalc();
|
|
s_GEC[(int)GECType.DotBoom] = new DotBoomDmgCalc();
|
|
s_GEC[(int)GECType.Spell] = new SpellDmgCalc();
|
|
s_GEC[(int)GECType.HangMagnitude] = new HangMagnitudeCalc();
|
|
s_CustomModifer.Add("BossShield", new CustomModifer_BossShield());
|
|
}
|
|
|
|
public static Fixed64 GetModifierSrcValue(GameplayEffectModifier modifer, GameplayEffectSpec spec)
|
|
{
|
|
if (modifer.Cfg.srcAttributeFrom == AttributeFrom.CustomCalculationClass)
|
|
{
|
|
if (s_CustomModifer.TryGetValue(modifer.Cfg.magnitude, out var customModifer) == false)
|
|
{
|
|
XLog.LogWarning($"GetModifierSrcValue CustomModifer not found: {modifer.Cfg.magnitude}");
|
|
return 0;
|
|
}
|
|
|
|
return customModifer.GetCalculationClassMagnitude(modifer.Cfg, spec);
|
|
}
|
|
|
|
var owner = spec.Source.owner;
|
|
var data = modifer.Cfg;
|
|
var caster = TargetSelectSrv.GetCaster(owner) ?? owner;
|
|
|
|
// 从目标持有的枪中获取
|
|
if (modifer.Cfg.srcAttributeFrom == AttributeFrom.Gun)
|
|
{
|
|
if (caster.IsValid() == false)
|
|
{
|
|
XLog.LogWarning($"GetModifierSrcValue Source not found: {modifer.modiferId}");
|
|
return 0;
|
|
}
|
|
var gun = caster.equips.GetMainGunEntity();
|
|
if (gun == null)
|
|
{
|
|
XLog.LogWarning($"GetModifierSrcValue MainGun not found: {modifer.modiferId}");
|
|
return 0;
|
|
}
|
|
|
|
var calcVal = ExpressionEvaluator.CalcVal_WithPropAndGaCfg(data.magnitude, gun.property.container,
|
|
spec.Level, spec.effectParams.gaInitCfg, 0);
|
|
|
|
calcVal *= spec.stackCount;
|
|
return calcVal;
|
|
}
|
|
|
|
// 从后台枪中获取
|
|
if (modifer.Cfg.srcAttributeFrom == AttributeFrom.Support)
|
|
{
|
|
if (caster.IsValid() == false)
|
|
{
|
|
XLog.LogWarning($"GetModifierSrcValue Source not found: {modifer.modiferId}");
|
|
return 0;
|
|
}
|
|
var gun = caster?.equips.GetSupportGunEntity();
|
|
if (gun == null)
|
|
{
|
|
XLog.LogWarning($"GetModifierSrcValue SupportGun not found: {modifer.modiferId}");
|
|
return 0;
|
|
}
|
|
|
|
var calcVal = ExpressionEvaluator.CalcVal_WithPropAndGaCfg(data.magnitude, gun.property.container,
|
|
spec.Level, spec.effectParams.gaInitCfg, 0);
|
|
|
|
calcVal *= spec.stackCount;
|
|
return calcVal;
|
|
}
|
|
|
|
return modifer.CalculateMagnitude(spec);
|
|
}
|
|
|
|
public static void RevertModifier(GameplayEffectModifier modifer, GameplayEffectSpec spec)
|
|
{
|
|
var geModiferDesc = GEModiferDescMgr.Instance.GetConfig(modifer.modiferId);
|
|
var calc = s_GEC[(int)geModiferDesc.gecType];
|
|
calc.Revert(modifer, spec);
|
|
}
|
|
|
|
public static void DoModifier(GameplayEffectModifier modifer, GameplayEffectSpec spec)
|
|
{
|
|
var geModiferDesc = GEModiferDescMgr.Instance.GetConfig(modifer.modiferId);
|
|
if (geModiferDesc == null)
|
|
{
|
|
XLog.LogWarning($"DoModifier GEModiferDesc not found: {modifer.modiferId} !!!!");
|
|
return;
|
|
}
|
|
var calc = s_GEC[(int)geModiferDesc.gecType];
|
|
calc.Execute(modifer, spec);
|
|
}
|
|
|
|
public static void GetHeroBasePropValue(CombatEntity ce)
|
|
{
|
|
var heroPropViewOne = CoreUIBridge.BattleInfoParams.heroPropView;
|
|
var cacheProps = CoreUIBridge.BattleInfoParams.cacheHeroProps;
|
|
var level = CoreUIBridge.BattleInfoParams.heroCommunityInfo.lvl;
|
|
GetBasePropValue(ce, heroPropViewOne, cacheProps, level);
|
|
}
|
|
|
|
public static void GetBasePropValue(CombatEntity ce, HeroPropViewOne propViewOne, List<ID32Value64> cacheProps,
|
|
int level)
|
|
{
|
|
ce.AddProperty();
|
|
if (propViewOne != null)
|
|
{
|
|
Reset_HeroBaseProps(ce, propViewOne, cacheProps);
|
|
if (ce.property.GetProperty_Long(PropertyDef.CurHp) == 0)
|
|
{
|
|
ce.property.PushModifer(PropertyDef.CurHp, ce.property.TotalHp, -(int)PropertyDef.CurHp);
|
|
}
|
|
}
|
|
ce.property.SetProperty(PropertyDef.Level, level, true);
|
|
}
|
|
|
|
|
|
public static void Reset_GunProps(CombatEntity ce, List<ID32Value64> atts)
|
|
{
|
|
if (ce == null)
|
|
{
|
|
XLog.LogWarning($"ResetProps DoHandle entity is null");
|
|
return;
|
|
}
|
|
|
|
var prop = ce.property;
|
|
if (prop == null)
|
|
{
|
|
XLog.LogWarning($"ResetProps DoHandle entity {ce.Name} property is null");
|
|
return;
|
|
}
|
|
|
|
if (atts != null)
|
|
{
|
|
var propertyComponent = ce.property;
|
|
for (int i = 0; i < (int)PropertyDef.Size; i++)
|
|
propertyComponent.PopModifer((PropertyDef)i, -i, true);
|
|
#if UNITY_EDITOR
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("战斗Gun属性数据: ");
|
|
sb.Append(ce.creationIndex);
|
|
sb.Append(" ");
|
|
sb.Append(ce.Name);
|
|
sb.Append(" ");
|
|
#endif
|
|
for (int i = 0; i < atts.Count; i++)
|
|
{
|
|
var propVal = atts[i];
|
|
#if UNITY_EDITOR
|
|
sb.Append($"{(PropertyDef)propVal.Id} : {propVal.Value} , ");
|
|
#endif
|
|
propertyComponent.PushModifer_TenThousand((PropertyDef)propVal.Id, propVal.Value, -(propVal.Id));
|
|
}
|
|
#if UNITY_EDITOR
|
|
XLog.LogDebug(sb.ToString());
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public static void Reset_HeroBaseProps(CombatEntity ce, HeroPropViewOne heroPropViewOne,
|
|
List<ID32Value64> cacheProps)
|
|
{
|
|
if (ce == null)
|
|
{
|
|
XLog.LogWarning($"ResetProps DoHandle entity is null");
|
|
return;
|
|
}
|
|
|
|
var prop = ce.property;
|
|
if (prop == null)
|
|
{
|
|
XLog.LogWarning($"ResetProps DoHandle entity {ce.Name} property is null");
|
|
return;
|
|
}
|
|
|
|
if (heroPropViewOne != null)
|
|
{
|
|
var propertyComponent = ce.property;
|
|
#if UNITY_EDITOR
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.Append("战斗Hero属性数据: ");
|
|
sb.Append(ce.creationIndex);
|
|
sb.Append(" ");
|
|
sb.Append(ce.Name);
|
|
sb.Append(" ");
|
|
#endif
|
|
if (propertyComponent.HasModifer())
|
|
{
|
|
for (int i = 0; i < cacheProps.Count; i++)
|
|
{
|
|
propertyComponent.PopModifer((PropertyDef)cacheProps[i].Id, -cacheProps[i].Id);
|
|
}
|
|
}
|
|
|
|
cacheProps.Clear();
|
|
for (int i = 0; i < heroPropViewOne.PropVal.Count; i++)
|
|
{
|
|
var propVal = heroPropViewOne.PropVal[i];
|
|
#if UNITY_EDITOR
|
|
sb.Append($"{(PropertyDef)propVal.Id} : {propVal.Value} , ");
|
|
#endif
|
|
cacheProps.Add(propVal);
|
|
propertyComponent.PushModifer_TenThousand((PropertyDef)propVal.Id, propVal.Value, -propVal.Id);
|
|
}
|
|
#if UNITY_EDITOR
|
|
XLog.LogDebug(sb.ToString());
|
|
#endif
|
|
}
|
|
}
|
|
|
|
public static void GetMonsterPropValue(CombatEntity ce, int monsterId)
|
|
{
|
|
ce.AddProperty();
|
|
var tbMonster = MonsterPropDescMgr.Instance.GetConfig(monsterId);
|
|
if (tbMonster == null)
|
|
{
|
|
BattleLogger.LogInfo("MonsterProp cfg not found: " + monsterId);
|
|
return;
|
|
}
|
|
|
|
var pc = ce.property;
|
|
pc.PushModifer_TenThousand(PropertyDef.AtkFixedIncrease, tbMonster.Atk, -(int)PropertyDef.AtkFixedIncrease);
|
|
pc.PushModifer_TenThousand(PropertyDef.DefFixedIncrease, tbMonster.Def, -(int)PropertyDef.DefFixedIncrease);
|
|
pc.PushModifer_TenThousand(PropertyDef.HpFixedIncrease, tbMonster.HP, -(int)PropertyDef.HpFixedIncrease);
|
|
pc.PushModifer_TenThousand(PropertyDef.SpeedFixedIncrease, tbMonster.MoveSpeed,
|
|
-(int)PropertyDef.SpeedFixedIncrease);
|
|
pc.PushModifer_TenThousand(PropertyDef.DamageRate, tbMonster.HurtRate, -(int)PropertyDef.DamageRate);
|
|
pc.PushModifer_TenThousand(PropertyDef.DamageResistance, tbMonster.UnHurtRate,
|
|
-(int)PropertyDef.DamageResistance);
|
|
pc.PushModifer_TenThousand(PropertyDef.CriticalRate, tbMonster.CritRate, -(int)PropertyDef.CriticalRate);
|
|
pc.PushModifer_TenThousand(PropertyDef.CriticalResistance, tbMonster.UnCritRate,
|
|
-(int)PropertyDef.CriticalResistance);
|
|
pc.PushModifer_TenThousand(PropertyDef.CriticalDamageIncrease, tbMonster.CritDamage,
|
|
-(int)PropertyDef.CriticalDamageIncrease);
|
|
pc.PushModifer_TenThousand(PropertyDef.Dodge1, tbMonster.EvadeRate, -(int)PropertyDef.Dodge1);
|
|
pc.PushModifer_TenThousand(PropertyDef.HealingIncrease, tbMonster.HealRate,
|
|
-(int)PropertyDef.HealingIncrease);
|
|
pc.PushModifer_TenThousand(PropertyDef.StunRate, tbMonster.StunRate, -(int)PropertyDef.StunRate);
|
|
pc.PushModifer_TenThousand(PropertyDef.StunResistance, tbMonster.UnStunRate,
|
|
-(int)PropertyDef.StunResistance);
|
|
pc.PushModifer_TenThousand(PropertyDef.HS_Rate, tbMonster.HS_Rate, -(int)PropertyDef.HS_Rate);
|
|
pc.PushModifer_TenThousand(PropertyDef.HS_Resistance, tbMonster.HS_Resistance,
|
|
-(int)PropertyDef.HS_Resistance);
|
|
pc.PushModifer_TenThousand(PropertyDef.HS_DamageIncrease, tbMonster.HS_DamageIncrease,
|
|
-(int)PropertyDef.HS_DamageIncrease);
|
|
pc.PushModifer_TenThousand(PropertyDef.MagicPatch01, tbMonster.MonsterParam1,
|
|
-(int)PropertyDef.MagicPatch01);
|
|
pc.SetProperty_TenThousand(PropertyDef.CurHp, tbMonster.HP);
|
|
pc.SetProperty_TenThousand(PropertyDef.LastLostHp, 0);
|
|
}
|
|
|
|
public static void AddProperty(this CombatEntity e)
|
|
{
|
|
e.AddProperty(e, null);
|
|
SptPool<PropertyContainer>.Malloc(ref e.property.container);
|
|
e.property.container.Awake();
|
|
}
|
|
}
|
|
}
|