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.
56 lines
1.6 KiB
56 lines
1.6 KiB
1 month ago
|
using CoreGame;
|
||
|
|
||
|
namespace CoreGame.Render
|
||
|
{
|
||
|
// 承受伤害
|
||
|
public class Trigger_OnTakeDamage : TriggerBase
|
||
|
{
|
||
|
public override void OnEvent(TriggerSpec self, int eventId, object param1)
|
||
|
{
|
||
|
if (triggerCfg.param2 != 0)
|
||
|
{
|
||
|
var hurtData = (HurtData)param1;
|
||
|
var currHp = hurtData.dst.property.GetProperty_Long(PropertyDef.CurHp);
|
||
|
var ret = 2; // 未击杀
|
||
|
if (currHp <= 0)
|
||
|
ret = 1; // 击杀
|
||
|
|
||
|
if ((triggerCfg.param2 & (1 << (ret - 1))) == 0)
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
// OnTrigger(self, eventId, param1);
|
||
|
var cntAcc = triggerCfg.param1; // 累计
|
||
|
self.param1.intVal += 1; // 累计
|
||
|
if (self.param1.intVal < cntAcc)
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var isSucc = OnTrigger(self, eventId, param1);
|
||
|
if (isSucc)
|
||
|
{
|
||
|
self.param1.intVal = 0;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override bool OnPreExecuteCheck(TriggerSpec self, int eventId, object param1)
|
||
|
{
|
||
|
if (triggerCfg.param4 != 0)
|
||
|
{
|
||
|
TriggerSrv.AssembleTriggerAbilitySpecCtx(self, (HurtData)param1, true);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public override void Init(TriggerSpec self)
|
||
|
{
|
||
|
RegEntityEvent(self, ClientEvent.OnTakeDamage);
|
||
|
}
|
||
|
|
||
|
public override void UnInit(TriggerSpec self)
|
||
|
{
|
||
|
UnRegEntityEvent(self, ClientEvent.OnTakeDamage);
|
||
|
}
|
||
|
}
|
||
|
}
|