--主视角事件分发脚本 --把所有主视角的事件分发都集中在这里面,减少战斗内核代码对LogicUpdateManager._curEntity的访问 local EventSystem = require('Event/EventSystem') local FirstPersonEventDispatcher = {} function FirstPersonEventDispatcher.Player_AdjutantCoolDown(entity, ... ) --if entity == LogicUpdateManager._curEntity then --先暂时删除 EventSystem.Dispatch(EventID.Player_AdjutantCoolDown, entity, ...) --end end function FirstPersonEventDispatcher.Player_StratagemSkillCoolDown(entity, ... ) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.Player_StratagemSkillCoolDown, entity, ...) end end function FirstPersonEventDispatcher.UI_MainEntityAddSpecialViewBuff(entity, buffData, leftBuffTimer) if entity == LogicUpdateManager._curEntity and buffData.SpecialViewType > 0 then EventSystem.Dispatch(EventID.UI_MainEntityAddSpecialViewBuff,entity,buffData, leftBuffTimer) end end function FirstPersonEventDispatcher.UI_MainEntityRemoveSpecialViewBuff(entity, buffData) if buffData.SpecialViewType > 0 then local originEntity = nil -- 不要用 Entity:GetOriginEntity() local driveComp = entity.components.drive if driveComp then originEntity = driveComp:GetLastDriver() or entity else originEntity = entity end if originEntity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UI_MainEntityRemoveSpecialViewBuff,entity,buffData) end end end function FirstPersonEventDispatcher.Player_ChangeAvatar(entity, keyPosList) if entity == BattleDataGetter.GetCurSkillUIEntity() then EventSystem.Dispatch(EventID.Player_ChangeAvatar, keyPosList) end end function FirstPersonEventDispatcher.Player_BanKeyPositions(entity, keyPosList) local curUIEntity = LogicUpdateManager._curEntity if curUIEntity then local driveComp = LogicUpdateManager._curEntity.components.drive if driveComp.DriveEntity then curUIEntity = driveComp.DriveEntity end if entity == curUIEntity then EventSystem.Dispatch(EventID.Player_BanKeyPositions, keyPosList) end end end function FirstPersonEventDispatcher.Player_CancelBanKeyPosition(entity) local curUIEntity = LogicUpdateManager._curEntity if curUIEntity then local driveComp = LogicUpdateManager._curEntity.components.drive if driveComp.DriveEntity then curUIEntity = driveComp.DriveEntity end if entity == curUIEntity then EventSystem.Dispatch(EventID.Player_CancelBanKeyPosition, entity) end end end function FirstPersonEventDispatcher.Player_SetSkillList(entity) if entity == BattleDataGetter.GetCurSkillUIEntity() then EventSystem.Dispatch(EventID.Player_SetSkillList) end end function FirstPersonEventDispatcher.UIBattle_MainPlayerFightModeChanged(entity, fightMode) if entity:IsPlayerSelf() then EventSystem.Dispatch(EventID.UIBattle_MainPlayerFightModeChanged, fightMode) end end function FirstPersonEventDispatcher.UIBattle_MainPlayerAutoFightChanged(entity) if entity:IsPlayerSelf() then EventSystem.Dispatch(EventID.UIBattle_MainPlayerAutoFightChanged) end end function FirstPersonEventDispatcher.UIBattle_MainPlayerForceTargetChanged(entity, playerID, isSet) if entity:IsPlayerSelf() then if playerID then EventSystem.Dispatch(EventID.UIBattle_MainPlayerForceTargetChanged, playerID, isSet) end end end function FirstPersonEventDispatcher.Player_SkillCoolDown(entity, skillData) if entity:IsPlayerSelf() then local belongToSkillData = entity:GetSkillData(skillData.BelongTo) local updateData = entity.components.skillBase.CurUpdateDataGroup[skillData.BelongTo] if updateData then EventSystem.Dispatch(EventID.Player_SkillCoolDown, belongToSkillData.KeyPosition, updateData.CD) end end end function FirstPersonEventDispatcher.Player_InterruptSkill(entity, skillData, reason) if entity:IsPlayerSelf() then EventSystem.Dispatch(EventID.Player_InterruptSkill, skillData, reason) end end function FirstPersonEventDispatcher.OnSendSpecialCommand(entity, cmdType) if entity and entity:IsPlayerSelf() then EventSystem.Dispatch(EventID.SendSpecialCommand, cmdType) end end --这个不能搞成主视角 2022年9月19日 -- function FirstPersonEventDispatcher.OnAssistantKill(assisAimPlayerInfo) -- if assisAimPlayerInfo.playerID == LevelPlayerManager.MyPlayerIDInRoom then -- EventSystem.Dispatch(EventID.UI_WorldBoss_My_Assistant_Kill, assisAimPlayerInfo) -- end -- end function FirstPersonEventDispatcher.OnSendPositionChatLink(speakerEntity, posIndex, posX, posY) if speakerEntity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.Level_SendPositionChatLink, posIndex, posX, posY, BattleDataGetter.GetCurLevelID(), BattleDataGetter.GetBattleBranchLine()) end end function FirstPersonEventDispatcher.OnAddNewBattleProp(entity, btnIndex, battlePropData) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_AddNewBattleProp, btnIndex, battlePropData) end end function FirstPersonEventDispatcher.OnBattlePropUpToMax(entity, btnIndex) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_BattlePropUptoMax, btnIndex) end end function FirstPersonEventDispatcher.OnStartUseBattleProp(entity,btnIndex, battlePropData) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_StartUseBattleProp,btnIndex, battlePropData) end end function FirstPersonEventDispatcher.OnAbortUseBattleProp(entity, btnIndex) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_AbortUseBattleProp, btnIndex) end end function FirstPersonEventDispatcher.OnFinishUseBattleProp(entity, btnIndex) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_FinishUseBattleProp, btnIndex) end end function FirstPersonEventDispatcher.OnRefreshBattleProp(entity, btnIndex) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_RefreshBattleProp, btnIndex) end end function FirstPersonEventDispatcher.OnAddBuffSkill(entity, buffSkillUpdate) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_OnAddBuffSkill, buffSkillUpdate) end end function FirstPersonEventDispatcher.OnReplaceBuffSkill(entity, buffSkillUpdate, oldData, newData) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_OnReplaceBuffSkill, buffSkillUpdate) end end function FirstPersonEventDispatcher.OnBuffSkillCDReady(entity, buffSkillUpdate) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_OnBuffSkillCDReady, buffSkillUpdate) end end function FirstPersonEventDispatcher.OnBuffSkillEnterCD(entity, buffSkillUpdate) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_OnBuffSkillEnterCD, buffSkillUpdate) end end function FirstPersonEventDispatcher.OnSwitchGodBeastSkill(entity, buffSkillUpdate, curGoldBeastData, curGodBeastSkillIndex) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_OnSwitchGodBeastSkill, buffSkillUpdate, curGoldBeastData, curGodBeastSkillIndex) end end function FirstPersonEventDispatcher.OnBuffSkillEnegyChanged(entity, enengyInfo) if entity == LogicUpdateManager._curEntity then EventSystem.Dispatch(EventID.UIBattle_OnBuffSkillEnegyChanged, enengyInfo) end end return FirstPersonEventDispatcher