local EventSystem = require 'Event/EventSystem' ----持续Buff--- local BuffOperator_Sustained = {} local BuffManager = require "Battle/Logic/Buff/BuffManager/BuffManager" local BuffObject = require "Battle/Logic/Buff/BuffData/BuffObject" local FormulaCalculator = require "Battle/Logic/Missile/FormulaCalculator" local BattleEventSystem = BattleEventSystem local private = {} local HitFlyRandom = FP.newV1(0.1) local HitFlyRandomN = FP.newV1(-0.1) local BUFFGROUP_HIT = 10 local BUFFGROUP_DEAD = 40 local LuaConst=LuaConst local STATETYPE_DEAD = LuaConst.StateType.Dead local STATETYPE_COMMON = LuaConst.StateType.Common local STATETYPE_IDLE = LuaConst.StateType.Idle local STATETYPE_NONE = LuaConst.StateType.None local TIMESCALE_BREAK_TYPE_HITBREAK = LuaConst.TimeScaleBreakType.HitBreak local TIMESCALE_BREAK_TYPE_HITFLY = LuaConst.TimeScaleBreakType.HitFly local specialBuffs = LuaConst.SpecialBuffs local CHARACTERTYPE_HERO = LuaConst.CharacterType.Hero local FP=FP local FP_ZERO = FP.Const.Zero local FP_MAX = FP.Const.Max local FP_NEGONE = FP.Const.NegOne local VECTOR_ZERO = FP.Const.Vector2_Zero local EventID=EventID local _buffOp_Dic local TimeOverlieType = { None = 0, NewTimer = 1, AddTimer = 2, KeepTimer = 3, NewTimerAddAndDelete = 4, } local EffectOverlieType = { None = 0, DoNothing = 1, AddLayer = 2, Excute = 3, ExcuteAndLayer = 4, -- 加层且执行 } local func_CheckExclusive = DataSheetUtil.CheckBuffExclusive function BuffOperator_Sustained.SetBuffOpDic(dic) _buffOp_Dic = dic end local _recoverWhenExclusiveOffBuffDatas function BuffOperator_Sustained.SetRecoverWhenExclusiveOffBuffDatas(datas) _recoverWhenExclusiveOffBuffDatas = datas end function BuffOperator_Sustained.Add(buffData, targetEntity, sourceEntity, missile, ctrlParam, index) --buff对应的动画可能为N个动画间随机 --先根据Buff改变当前动画,再根据当前动画获取Buff时间 BuffOperator_Sustained.ChangeStateOnAddBuff(buffData, targetEntity, sourceEntity ,missile) --这句调用必须在最前面,因为updateData的正确创建依赖于这句调用 local updateData = BuffOperator_Sustained.CreateBuffUpdateData(buffData, sourceEntity, targetEntity, ctrlParam,missile) local buffObject = targetEntity.components.buff.CurBuffObjectDic[buffData.BuffID] if buffObject then buffObject:SetData(updateData,index) buffObject:ResumeListener() else buffObject = BuffObject:new(buffData) buffObject:SetHost(targetEntity) buffObject:SetData(updateData) targetEntity.components.buff:SetBuffObject(buffObject) end targetEntity.components.buff:OnBuffSetData(buffObject, updateData, index) if buffData.BuffType ~= LuaConst.BuffType.DotBuff and buffData.BuffType ~= LuaConst.BuffType.HaloBuff or buffData.IsEffectOnStart then -- IsEffectOnStart 只针对有频率性的buff -dot和halo local buffOperator = _buffOp_Dic[buffData.BuffType] buffOperator.Execute(buffData, targetEntity, sourceEntity, updateData) end BuffOperator_Sustained.AddHandles(buffData, targetEntity, sourceEntity, ctrlParam) return updateData end function BuffOperator_Sustained.Refresh(buffData,targetEntity,sourceEntity, missile,ctrlParam,index) BuffOperator_Sustained.ChangeStateOnAddBuff(buffData, targetEntity, sourceEntity,missile) local buffObject = targetEntity.components.buff.CurBuffObjectDic[buffData.BuffID] local updateData = buffObject:GetUpdateData(index) BuffOperator_Sustained.HandleOverlie(buffData, updateData, targetEntity, sourceEntity, ctrlParam) buffObject:OnRefresh(updateData ,index) return updateData end function BuffOperator_Sustained.Delete(buffData, entity, updateData, addList, forceLayerZero) BuffOperator_Sustained.ExecuteDelete(buffData, entity, updateData, addList, forceLayerZero) if updateData.BuffLayer == 0 then --移除Buff时会尝试处理一些需要加回来的buff的互斥逻辑(这里其实有点问题,如果一开始没有添加A Buff,也会在B Buff删除时添加A Buff) if entity.components.attr:IsAlive() then local buffID,buffGroupID = buffData.BuffID, buffData.BuffGroup local exclusiveRecoverBuffDatas = nil --for i,buffData in ipairs(entity.components.buff:GetRecoverWhenExclusiveOffBuffDatas()) do --另一种恢复机制的代码,更科学,但是因为现在策划不太好用表来描述Buff之间的恢复传递,所以注掉了。(恢复传递异常: A互斥Buff M,添加A时顶掉M。A结束时添加Buff B。Buff B免疫M。B结束时,如果B没有配置互斥M,则M不会被加回来。并且策划很多情况下不能配置B互斥M) for i,buffData in ipairs(_recoverWhenExclusiveOffBuffDatas) do if func_CheckExclusive(buffData.BuffID,buffData.BuffGroup,buffID,buffGroupID) then exclusiveRecoverBuffDatas = exclusiveRecoverBuffDatas or {} BuffManager.TryAddBuff(buffData.BuffID, entity, entity, addList and RuntimeDataManager.New_BuffCtrl(), addList) exclusiveRecoverBuffDatas[#exclusiveRecoverBuffDatas + 1] = buffData end end --↓ 另一种恢复机制的代码,更科学,但是因为现在策划不太好用表来描述Buff之间的恢复传递,所以注掉了。(恢复传递异常: A互斥Buff M,添加A时顶掉M。A结束时添加Buff B。Buff B免疫M。B结束时,如果B没有配置互斥M,则M不会被加回来。并且策划很多情况下不能配置B互斥M) -- if exclusiveRecoverBuffDatas then -- for i,recoverBuffData in ipairs(exclusiveRecoverBuffDatas) do -- entity.components.buff:OnExclusiveRecover(recoverBuffData) -- end -- end --↑ end end end --因为互斥被删除-- function BuffOperator_Sustained.ExclusiveDelete(buffData, entity, addBuffID, addBuffGroup, updateData) BuffOperator_Sustained.ExecuteDelete(buffData, entity, updateData, nil, true) --entity.components.buff:OnExclusiveDelete(buffData) --另一种恢复机制的代码,更科学,但是因为现在策划不太好用表来描述Buff之间的恢复传递,所以注掉了。(恢复传递异常: A互斥Buff M,添加A时顶掉M。A结束时添加Buff B。Buff B免疫M。B结束时,如果B没有配置互斥M,则M不会被加回来。并且策划很多情况下不能配置B互斥M) --移除Buff时会尝试处理标志类型特殊buff的互斥逻辑 if entity.components.attr:IsAlive() then local buffID,buffGroupID = buffData.BuffID, buffData.BuffGroup for flagID = specialBuffs.CanRotate, specialBuffs.CanRide do --标志BUFF的起止 if func_CheckExclusive(flagID,2,buffID,buffGroupID) and not func_CheckExclusive(flagID,2,addBuffID,addBuffGroup) then BuffManager.TryAddBuff(flagID, entity, entity) end end end end function BuffOperator_Sustained.OnUpdate(buffData, updateData,entity, deltaTime, addList) if updateData.BuffTimer ~= FP_MAX then updateData.BuffTimer:Sub(deltaTime) end return updateData end --外部调用end--- ---- 执行部分-----【添加buff时】 function BuffOperator_Sustained.Execute(buffData, targetEntity, sourceEntity, updateData ,hpChangeType) FormulaCalculator.CalculateResult( buffData,updateData,targetEntity,sourceEntity ,1 ,hpChangeType) end function BuffOperator_Sustained.ExecuteDelete(buffData, entity,updateData, addList , exclusive, forceLayerZero) if updateData.BuffLayer == 0 then return end local layerBeforeDelete = updateData.BuffLayer updateData.BuffLayer = 0 if not forceLayerZero and buffData.TimeOverlieType == TimeOverlieType.NewTimerAddAndDelete then if not exclusive then if layerBeforeDelete > 1 then updateData.BuffLayer = layerBeforeDelete - 1 updateData.BuffTimer:Reset(buffData.BuffDuration):Div(1000) end end end if updateData.BuffLayer == 0 then BuffOperator_Sustained.ChangeStateOnDeleteBuff(buffData, entity, addList ,exclusive) end --需要进行公示计算的或者由子弹释放的再去刷新属性 if buffData.BuffFormula ~= "" or updateData.BuffOverRideFomula then local sid = -1 if updateData.SourceEntity and buffData.IsRecordSource then sid = updateData.SourceEntity._logicInitData.EntityID end SystemManager.DeleteBuffUpdateAttr(entity, buffData.BuffID, sid, updateData.BuffLayer) end if exclusive then --self:ExclusiveDeleteHandles(buffData, entity) --old 老代码会无意义地调用 ExclusiveDeleteHandles -> DeleteHandles ,多调一层 ExclusiveDeleteHandles 没有必要 BuffOperator_Sustained.DeleteHandles(buffData, entity) --new 新代码直接调 DeleteHandles ,优化性能 else BuffOperator_Sustained.DeleteHandles(buffData, entity) end if updateData.BuffLayer == 0 then local buffObject = entity.components.buff.CurBuffObjectDic[buffData.BuffID] buffObject:OnDeleteBuff(updateData) BattleEventSystem.OnEntityDeleteBuff(entity,buffData.BuffID,updateData,layerBeforeDelete) if entity._logicInitData.IsPlayerSelf then --EventSystem.Dispatch(EventID.UI_UpdateBuff_Self,entity) EventSystem.Dispatch(EventID.UI_UpdateBuff_Self,entity,buffData,0,0,updateData.SourceEntity and updateData.SourceEntity.EntityID or -1) elseif entity.components.base.CurMonsterFeature.ShowBossUI then EventSystem.Dispatch(EventID.UI_UpdateBuff_Boss,buffData,0,0,updateData.SourceEntity and updateData.SourceEntity.EntityID or -1, entity.EntityID) elseif entity.isHero then EventSystem.Dispatch(EventID.UI_UpdateBuff_OtherHero,entity,buffData,updateData.BuffTimer,updateData.BuffLayer,updateData.SourceEntity and updateData.SourceEntity.EntityID or -1) end else if entity._logicInitData.IsPlayerSelf then --EventSystem.Dispatch(EventID.UI_UpdateBuff_Self,entity) EventSystem.Dispatch(EventID.UI_UpdateBuff_Self, entity, buffData, updateData.BuffTimer, updateData.BuffLayer, updateData.SourceEntity and updateData.SourceEntity.EntityID or -1) elseif entity.components.base.CurMonsterFeature.ShowBossUI then EventSystem.Dispatch(EventID.UI_UpdateBuff_Boss, buffData, updateData.BuffTimer, updateData.BuffLayer, updateData.SourceEntity and updateData.SourceEntity.EntityID or -1, entity.EntityID) elseif entity.isHero then EventSystem.Dispatch(EventID.UI_UpdateBuff_OtherHero, entity, buffData, updateData.BuffTimer, updateData.BuffLayer, updateData.SourceEntity and updateData.SourceEntity.EntityID or -1) end end end ---- 执行部分-----【添加buff后】 function BuffOperator_Sustained.AddHandles(buffData, targetEntity, sourceEntity, ctrlParam) if buffData.BuffGroup == BUFFGROUP_HIT or buffData.BuffGroup == BUFFGROUP_DEAD then SystemManager.OnBreakTimeScale(targetEntity, true, TIMESCALE_BREAK_TYPE_HITBREAK) if buffData.BuffID == specialBuffs.InHitUp or buffData.BuffID == specialBuffs.InFlyFlyingMonster then -- or buffData.BuffID == specialBuffs.InHitFlyMonster SystemManager.OnHitFly(targetEntity) end if buffData.BuffGroup == BUFFGROUP_DEAD then --这里特殊处理死亡。 --所有配置了IsDeadDelete的buff,都在这里删除 -- old↓ 使用list的copy遍历,gc比较大 -- _sortedBuffsCopy = targetEntity.components.buff:GetBuffObjectListCopy(_sortedBuffsCopy) -- for i,buffObject in ipairs(_sortedBuffsCopy) do -- local _buffData = buffObject:GetData() -- if _buffData.IsDeadDelete then -- local buffUpdateData = buffObject.BuffUpdateData -- local buffUpdateList = buffObject.BuffUpdateList -- local buffOperator = BuffManager.GetBuffOperator(_buffData.BuffType) -- if buffUpdateData then -- if buffUpdateData.BuffLayer >0 then -- buffOperator.Delete(_buffData, targetEntity, buffUpdateData,nil) -- end -- end -- if buffUpdateList then -- for i, updateData in ipairs(buffUpdateList) do -- if updateData.BuffLayer >0 then -- buffOperator.Delete(_buffData, targetEntity, updateData,nil) -- end -- end -- end -- end -- end -- for i=1,#_sortedBuffsCopy do -- _sortedBuffsCopy[i] = nil -- end -- old↑ local buffObject = targetEntity.components.buff.CurBuffObjectLinkedListHead local count = 0 while buffObject do local _buffData = buffObject:GetData() if _buffData.IsDeadDelete then local buffUpdateData = buffObject.BuffUpdateData local buffUpdateList = buffObject.BuffUpdateList local buffOperator = _buffOp_Dic[_buffData.BuffType] if buffUpdateData then if buffUpdateData.BuffLayer >0 then buffOperator.Delete(_buffData, targetEntity, buffUpdateData,nil) end end if buffUpdateList then for i, updateData in ipairs(buffUpdateList) do if updateData.BuffLayer >0 then buffOperator.Delete(_buffData, targetEntity, updateData,nil) end end end end buffObject = buffObject.nextBuffObject count = count + 1 if count > 999 then logging.error(LTAG.ERROR, "HYW : 代码哪写错了,无限循环了! @BuffOperator_Sustained.AddHandles") break end end end end if buffData.BuffGroup == BUFFGROUP_DEAD then if not targetEntity.components.anim.CurAnimMoveData then targetEntity.components.record.IsUnload = true end end targetEntity.components.buff.CurrentBuffStates:Set(buffData.BuffID,true) if buffData.BuffID == specialBuffs.ForceShovePriority then SystemManager.OnChangeShovePriority(targetEntity, LuaConst.ForcedShovePriority) end if buffData.BuffID == specialBuffs.CantBeTrigger then SystemManager.OnEnterCantBeTrigger(targetEntity) end end function BuffOperator_Sustained.DeleteHandles(buffData, targetEntity) if buffData.BuffGroup == BUFFGROUP_HIT or buffData.BuffGroup == BUFFGROUP_DEAD then SystemManager.OnBreakTimeScale(targetEntity, false, TIMESCALE_BREAK_TYPE_HITBREAK) if buffData.BuffID == specialBuffs.InHitUp or buffData.BuffID == specialBuffs.InFlyFlyingMonster then -- or buffData.BuffID == specialBuffs.InHitFlyMonster SystemManager.OnBreakTimeScale(targetEntity, true, TIMESCALE_BREAK_TYPE_HITFLY) end end if buffData.BuffID == specialBuffs.InStanding or buffData.BuffID == specialBuffs.InHeroStanding or buffData.BuffID == specialBuffs.InHitPush then targetEntity.components.move.LockExpRotate = false end targetEntity.components.buff.CurrentBuffStates:Set(buffData.BuffID, false) if buffData.BuffID == specialBuffs.InHitPush then targetEntity.components.buff.CurrentBuffHitType = LuaConst.BuffHitType.None elseif buffData.BuffID == specialBuffs.ForceShovePriority then SystemManager.OnChangeShovePriority(targetEntity) elseif buffData.BuffID == specialBuffs.InSkilling then -- 中断和禁止释放技能 if not targetEntity.components.skillBase.CanSwitchAll then --CanSwitchAll的生命周期跟specialBuffs.InSkilling并不完全一致,正常释放技能的情况下大多会先CanSwitchAll,然后过一段事件才specialBuffs.InSkilling。只有在别的buff打断技能的情况下,才会同时出现CanSwitchAll变为true和specialBuffs.InSkilling被删除 SystemManager.ChangeToSwitchAll(targetEntity, false, LuaConst.SkillInterruptType.BreakEffect) end elseif buffData.BuffID == specialBuffs.CanSkill then targetEntity.components.skillBase:ClearCurSkillCacheInfo() end end function BuffOperator_Sustained.ExclusiveDeleteHandles(buffData, targetEntity) BuffOperator_Sustained.DeleteHandles(buffData,targetEntity) end ---执行部分 end--- ---数据刷新 start -- function BuffOperator_Sustained.CreateBuffUpdateData(buffData, sourceEntity, targetEntity,ctrlParam,missile) local buffTimer = private.GetBuffTimer(buffData, targetEntity, ctrlParam ,missile) local updateData = RuntimeDataManager.New_BuffUpdate() updateData.MissileHurtID = ctrlParam.MissileHurtID updateData.IsTracker = ctrlParam.IsTracker updateData.BuffOverRideFomula = ctrlParam.BuffOverRideFomula if missile then updateData.MissileHitCount = missile.CurFrameHitEntityCount end updateData.SourceEntity = sourceEntity updateData.BuffLayer = 1 updateData.BuffTimer = buffTimer return updateData end function private.GetBuffTimer(buffData, targetEntity, ctrlParam , missile) local buffTimer = FP.newV1(0) local comp_Anim = targetEntity.components.anim if ctrlParam.ForceDuration > FP_ZERO then buffTimer:Reset(ctrlParam.ForceDuration) elseif buffData.UseAnimTime and comp_Anim.CurAnimMoveData then --buff对应的动画可能为N个动画间随机 --先根据Buff改变当前动画,再根据当前动画获取Buff时间 buffTimer:Reset(comp_Anim.CurAnimDataCount-1):Mul(LuaConst.TimeSpan) else if buffData.BuffDuration == FP_NEGONE then buffTimer:Reset(FP_MAX) if buffData.BuffID ~= 100008 and buffData.BuffID ~= 100007 then if buffData.UseAnimTime and not comp_Anim.CurAnimMoveData then local missileID = missile and missile.MissileData.ID or -1 -- logging.error(LTAG.ERROR, "HYW : 致命错误!UseAnimTime的Buff不存在动画位移信息且BuffDuration为-1(可能导致Buff无法被删除)! 出错的BuffID : " -- , buffData.BuffID, ",子弹ID:" ,missileID ," BuffAnimation为 : ", buffData.BuffAnimation -- , " ------characterID : ", targetEntity:GetCharacterID(), "characterType : " -- , targetEntity:GetCharacterType(), " LevelID : ", LevelManager.GetCurLevelID() -- , " battleId : ", LevelManager.IsSyncLevel() and MultiplayManager.GetBattleID() or " not sync level ") --新增容错机制↓ 配置了一些buff在丢失动画时的默认持续时间,防止在错误情况删不掉buff而卡住玩家 if LuaConst.BuffUseAnimTimeDefaultDurationInSec[buffData.BuffID] then buffTimer:Reset(LuaConst.BuffUseAnimTimeDefaultDurationInSec[buffData.BuffID]) end --↑ end end else buffTimer:Reset(buffData.BuffDuration):Div(1000) end end return buffTimer end --叠加处理 function BuffOperator_Sustained.HandleOverlie(buffData,updateData, targetEntity, sourceEntity, ctrlParam) --叠加 计时 local timer = updateData.BuffTimer if buffData.TimeOverlieType == TimeOverlieType.NewTimer or buffData.TimeOverlieType == TimeOverlieType.NewTimerAddAndDelete then timer = private.GetBuffTimer(buffData, targetEntity, ctrlParam) elseif buffData.TimeOverlieType == TimeOverlieType.AddTimer then timer = timer + private.GetBuffTimer(buffData, targetEntity, ctrlParam) timer = FP.Math.Min(timer, buffData.TimeOverlieLimit / 1000); end updateData.BuffTimer = timer --叠加 效果 EffectOverlieLimit 只限制buff层数 local layer = updateData.BuffLayer if buffData.EffectOverlieType == EffectOverlieType.AddLayer then layer = layer + 1 if (buffData.EffectOverlieLimit > 0) then layer = math.min(layer, buffData.EffectOverlieLimit) end elseif buffData.EffectOverlieType == EffectOverlieType.Excute then local buffOperator = _buffOp_Dic[buffData.BuffType] buffOperator.Execute(buffData, targetEntity, sourceEntity, updateData) layer = 1 elseif buffData.EffectOverlieType == EffectOverlieType.ExcuteAndLayer then if buffData.EffectOverlieLimit == -1 or buffData.EffectOverlieLimit > layer then local buffOperator = _buffOp_Dic[buffData.BuffType] buffOperator.Execute(buffData, targetEntity, sourceEntity, updateData) layer = layer + 1 end end updateData.BuffLayer = layer return updateData end ---数据刷新 end--- -- 状态改变 start----------【添加buff前】 function BuffOperator_Sustained.ChangeStateOnAddBuff(buffData, entity, sourceEntity,missile) local animNames = buffData.BuffAnimation if (#animNames == 0) then return end local ani = "" if (#animNames > 1) then local random = LogicRandom.GetIntegerValue(nil, 1, #animNames ,13) ani = animNames[random] else ani = animNames[1] end local buffid = buffData.BuffID if buffid == specialBuffs.InDying or buffid == specialBuffs.InDyingWithSuperArmor then SystemManager.SetNextState(STATETYPE_DEAD, entity, -1, ani, nil) else local hitFlyRate = 0 local hitFlyRandom = nil if entity:IsMonster() then hitFlyRate = missile and missile.MissileData.HitFlyRate or 0 -- 这两个字段只对非玩家生效 hitFlyRandom = missile and missile.MissileData.HitFlyRandomRange -- end SystemManager.SetNextState(STATETYPE_COMMON, entity, -1, ani, nil , buffid, sourceEntity ,hitFlyRate ,hitFlyRandom) --for debug deleteme now↓ 这里纯为了米欧展示做的,展示完毕需要删掉 if LogicUpdateManager.CheatAliveHitFlyDistance then if buffid == specialBuffs.InHitFlyMonster then local randomDis = LogicRandom.GetRangeValue(entity ,-LogicUpdateManager.CheatRandomDistance ,LogicUpdateManager.CheatRandomDistance ,97404) if entity.components.attr:IsAlive() then if LogicUpdateManager.isRecordHitFlyCount then LogicUpdateManager.aliveHitFlyCount = LogicUpdateManager.aliveHitFlyCount + 1 end entity.components.anim.AnimDisPercent:Reset(LogicUpdateManager.CheatAliveHitFlyDistance):Add(randomDis) else if LogicUpdateManager.isRecordHitFlyCount then LogicUpdateManager.deadHitFlyCount = LogicUpdateManager.deadHitFlyCount + 1 end entity.components.anim.AnimDisPercent:Reset(LogicUpdateManager.CheatDeadHitFlyDistance):Add(randomDis) end end --for debug deleteme now↑ else --- 正式使用的代码 if buffid == specialBuffs.InHitFlyMonster then local randomDis = LogicRandom.GetRangeValue(entity ,HitFlyRandomN ,HitFlyRandom ,97416) if entity.components.attr:IsAlive() then entity.components.anim.AnimDisPercent:Reset(0.5):Add(randomDis) else entity.components.anim.AnimDisPercent:Reset(0.8):Add(randomDis) end elseif buffid == specialBuffs.BigHurt then entity.components.anim.AnimDisPercent:Reset(0.3) end end end end function BuffOperator_Sustained.ChangeStateOnDeleteBuff(buffData, entity ,addList ,isByExclusive) --尸体Buff和击飞Buff可能会同时存在 local animNames = buffData.BuffAnimation if (#animNames == 0) then return end if isByExclusive then -- 被互斥掉的动作buff,改变状态 entity.components.aiBase.CommonStateByBuff = nil SystemManager.SetNextState(STATETYPE_IDLE, entity) return end local caster = entity --这里有值得商榷的地方,就是这个buff的添加者应该是entity(就是自身), 还是这个要删除buff的SourceEntity。目前都是自身。这个东西在播声音的时候比较敏感,其他地方暂时都无所谓。 local buffid = buffData.BuffID if buffid == specialBuffs.InHitFlyPlayer or buffid == specialBuffs.InHitUp or buffid == specialBuffs.InFlyFlyingMonster then BuffManager.TryAddBuff(specialBuffs.InGrounding,entity, caster, addList and RuntimeDataManager.New_BuffCtrl(), addList) elseif buffid == specialBuffs.InGrounding or buffid == specialBuffs.InHitFlyMonster or buffid == specialBuffs.InHitDown then if entity.components.attr:IsAlive() then if entity._logicInitData.CharacterType == CHARACTERTYPE_HERO then BuffManager.TryAddBuff(specialBuffs.InHeroStanding,entity, caster, addList and RuntimeDataManager.New_BuffCtrl(), addList) else BuffManager.TryAddBuff(specialBuffs.InStanding,entity, caster, addList and RuntimeDataManager.New_BuffCtrl(), addList) end else if entity.components.base.CurCharacterData.DeadNotHide or (LevelManager.CurLevelFunc.isSyncLevel and entity._logicInitData.IsPlayer )then local ctrlParam = RuntimeDataManager.New_BuffCtrl() ctrlParam.ForceDuration:Reset(entity.components.base.CurCharacterData.DeadBodyReserveTime) BuffManager.TryAddBuff(specialBuffs.InDeadBody, entity, caster, ctrlParam, addList) else entity.components.record.IsUnload = true end end elseif buffid == specialBuffs.InHitDrag or buffid == specialBuffs.InWeakHit then if not entity.components.attr:IsAlive() then BuffManager.TryAddBuff(specialBuffs.InDying, entity, caster, addList and RuntimeDataManager.New_BuffCtrl(), addList) end elseif buffid == specialBuffs.InDying or buffid == specialBuffs.InHitDying or buffid == specialBuffs.InDyingWithSuperArmor then if entity.components.base.CurCharacterData.DeadNotHide or (LevelManager.CurLevelFunc.isSyncLevel and entity._logicInitData.IsPlayer )then local ctrlParam = RuntimeDataManager.New_BuffCtrl() ctrlParam.ForceDuration:Reset(entity.components.base.CurCharacterData.DeadBodyReserveTime) BuffManager.TryAddBuff(specialBuffs.InDeadBody, entity, caster, ctrlParam, addList) else entity.components.record.IsUnload = true end elseif buffid == specialBuffs.InDeadBody or buffid == specialBuffs.InDeadBodyWithSuperArmor then if not LevelManager.CurLevelFunc.isSyncLevel or not entity._logicInitData.IsPlayer then entity.components.record.IsUnload = true end elseif buffid == specialBuffs.RideStopShow then if not entity.components.move.LogicMoveDir == VECTOR_ZERO then SystemManager.SetNextState(STATETYPE_NONE, entity) else SystemManager.SetNextState(STATETYPE_IDLE, entity) end else entity.components.aiBase.CommonStateByBuff = nil if buffData.IsAnimCircle then SystemManager.SetNextState(STATETYPE_IDLE, entity) end end end ---- 状态改变 end--- function BuffOperator_Sustained.OnBuffAdded(entity,buffId,updateData) --如果是组合骑兵,需要强制修改下骑兵的骑马属性 if buffId == specialBuffs.InRiding and entity._logicInitData.HorseModelData == nil then SystemManager.ChangeRideHorseMonsterAttr(entity) end end function BuffOperator_Sustained.OnBuffChanged(buffData,updateData,sourceEntity,targetEntity) if targetEntity._logicInitData.IsPlayerSelf then --EventSystem.Dispatch(EventID.UI_UpdateBuff_Self,targetEntity) EventSystem.Dispatch(EventID.UI_UpdateBuff_Self,targetEntity,buffData,updateData.BuffTimer,updateData.BuffLayer,sourceEntity and sourceEntity.EntityID or -1) elseif targetEntity.components.base.CurMonsterFeature.ShowBossUI then EventSystem.Dispatch(EventID.UI_UpdateBuff_Boss,buffData,updateData.BuffTimer,updateData.BuffLayer,sourceEntity and sourceEntity.EntityID or -1, targetEntity.EntityID) elseif targetEntity.isHero then EventSystem.Dispatch(EventID.UI_UpdateBuff_OtherHero,targetEntity,buffData,updateData.BuffTimer,updateData.BuffLayer,sourceEntity and sourceEntity.EntityID or -1) end end return BuffOperator_Sustained