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.
 
 
 
 
 
 

88 lines
2.7 KiB

using CoreGame;
using GAS.Runtime;
using Sog;
namespace CoreGame.Render
{
public class CueRefreshedHpShield : GameplayCueDurational
{
// public ClientEvent eventId = ClientEvent.OnRefreshedHpShield;
public override GameplayCueDurationalSpec CreateSpec(in GameplayCueParameters param)
{
var spec = SptPool<CueRefreshedHpShieldSpec>.Malloc();
spec.Awake(param);
return spec;
}
public override void FreeSpec(ref GameplayCueDurationalSpec spec)
{
var cueRefreshedHpShieldSpec = spec as CueRefreshedHpShieldSpec;
SptPool<CueRefreshedHpShieldSpec>.Free(ref cueRefreshedHpShieldSpec);
spec = null;
}
}
public class CueRefreshedHpShieldSpec : GameplayCueDurationalSpec<CueRefreshedHpShield>
{
private readonly float m_TimeSpan = 0.1f;
private float timeAcc;
private HpShieldData data = new();
public override void OnAdd()
{
if (ownerEnt.IsValid() == false)
return;
if (ownerEnt.hasMonster == false)
return;
data.mosterId = ownerEnt.blackboard.unitCfgId;
data.shieldRate = 1;
EventSrv.DispatchLogicEvent(ClientEvent.OnRefreshedHpShield, data);
}
public override void OnRemove()
{
if (ownerEnt.IsValid() == false)
return;
if (ownerEnt.hasMonster == false)
return;
data.mosterId = ownerEnt.blackboard.unitCfgId;
data.shieldRate = 0;
EventSrv.DispatchLogicEvent(ClientEvent.OnRefreshedHpShield, data);
}
public override void OnGameplayEffectActivate()
{
}
public override void OnGameplayEffectDeactivate()
{
}
public override void OnTick(Fixed64 dt)
{
timeAcc += dt;
if (timeAcc < m_TimeSpan)
{
return;
}
timeAcc -= m_TimeSpan;
data.mosterId = ownerEnt.blackboard.unitCfgId;
var monsterPropDesc = MonsterPropDescMgr.Instance.GetConfig(data.mosterId);
var rate = ownerEnt.property.GetProperty(PropertyDef.Calc_HpShield) /
( monsterPropDesc.ShieldValue * BattleConst.TenThousandReverse);
data.shieldRate = (float)rate;
EventSrv.DispatchLogicEvent(ClientEvent.OnRefreshedHpShield, data);
}
public override void Awake(in GameplayCueParameters param)
{
base.Awake(param);
timeAcc = 0;
}
}
}