using CommonAI.Zone.Instance; using CommonAI.Zone.Formula; using XmdsCommon.Plugin; using XmdsCommonServer.Plugin; using XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills; using CommonAI.Zone; using CommonAI.Data; namespace XmdsCommonSkill.Plugin.Buffs { /// /// 监听打到别人. /// public class XmdsBuff_Event_OnHitOther : XmdsBuffBase { private int mHandleUUID = 0; public XmdsCommonServer.Plugin.XmdsSkillTemplate.Skills.IOnHit OnHitOtherEvent; public override int GetAbilityID() { return (int)XmdsBuffProperties.XmdsBuffAbility.Event_OnHitOther; } protected override void OnBindTemplate(ref BuffTemplate buffTemplate) { //关联性BUFF必须在施放者死亡后清除. buffTemplate.IsRemoveOnSenderRemoved = true; base.OnBindTemplate(ref buffTemplate); } protected override void OnBuffBegin(XmdsCommonServer.Plugin.XmdsVirtual hitter, XmdsCommonServer.Plugin.XmdsVirtual attacker, InstanceUnit.BuffState state) { //注册监听. mHandleUUID = hitter.RegistOnHitOther(OnHandleHitOther, null); XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】增加OnHitOther事件监听.", hitter.mProp.ServerData.BaseInfo.name); } protected override void OnBuffEnd(XmdsCommonServer.Plugin.XmdsVirtual hitter, InstanceUnit.BuffState state, bool replace) { //取消监听. hitter.UnRegistOnHitOther(mHandleUUID); XmdsVirtual.FormatLog("BuffBegin : 单位【{0}】去除OnHitOther事件监听.", hitter.mProp.ServerData.BaseInfo.name); } private float OnHandleHitOther(float damage, XmdsVirtual hitted, XmdsVirtual attacker, AttackSource source, ref XmdsVirtual.AtkResult result, DamageType damageType, GameSkill skill, ref bool isEndDispatch) { if(OnHitOtherEvent != null) { OnHitOtherEvent.Invoke(damage, hitted, attacker, source, ref result, damageType, skill, ref isEndDispatch); } return damage; } protected override void OnDispose() { OnHitOtherEvent = null; base.OnDispose(); } public override void CopyTo(UnitBuff other) { var ret = other as XmdsBuff_Event_OnHitOther; ret.OnHitOtherEvent = this.OnHitOtherEvent; base.CopyTo(other); } } }