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.
49 lines
1.6 KiB
49 lines
1.6 KiB
using CoreGame;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
// 击杀触发
|
|
public class Trigger_OnKillEntity : TriggerBase
|
|
{
|
|
public override void OnEvent(TriggerSpec self, int eventId, object param)
|
|
{
|
|
// 触发
|
|
OnTrigger(self, eventId, param);
|
|
}
|
|
|
|
|
|
// triggerCfg.Param1 对应 MonsterType,击杀目标是对应的类型才触发
|
|
public override bool OnPreExecuteCheck(TriggerSpec self, int eventId, object param1)
|
|
{
|
|
// 触发器可以提前装配目标,但可以别目标选择覆盖
|
|
var hurtData = (HurtData)param1;
|
|
var context = self.abilitySpec?.ctx;
|
|
if (context != null)
|
|
{
|
|
context.castTarget.Clear();
|
|
context.castTarget.Add(hurtData.dst.creationIndex);
|
|
context.castPos.Clear();
|
|
context.castPos.Add(hurtData.dst.logicTransform.position);
|
|
}
|
|
|
|
var dstMonsterType = hurtData.dst.hasMonster ? hurtData.dst.monster.monsterType : MonsterType.None;
|
|
var monsterType = (MonsterType)triggerCfg.param1;
|
|
|
|
if (monsterType != MonsterType.None && dstMonsterType != MonsterType.None &&
|
|
(triggerCfg.param1 & (1 << ((int)dstMonsterType - 1))) == 0)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
public override void Init(TriggerSpec self)
|
|
{
|
|
RegEntityEvent(self, ClientEvent.OnKillEntity);
|
|
}
|
|
|
|
public override void UnInit(TriggerSpec self)
|
|
{
|
|
UnRegEntityEvent(self, ClientEvent.OnKillEntity);
|
|
}
|
|
}
|
|
}
|