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); } } }