--指令管理器 local FirstPersonEventDispatcher = require"Battle/Logic/Event/FirstPersonEventDispatcher" local BattleEffect = require("Battle/Logic/BattleEffect/BattleEffect") local SystemManager = {} --加载需要的模块 local SpeedSystem = require "Battle/Logic/Entity/System/SpeedSystem" local MoveSystem = require "Battle/Logic/Entity/System/MoveSystem" local RotateSystem = require "Battle/Logic/Entity/System/RotateSystem" local AnimSystem = require "Battle/Logic/Entity/System/AnimSystem" local AttrSystem = require "Battle/Logic/Entity/System/AttrSystem" local SkillBaseSystem = require "Battle/Logic/Entity/System/SkillBaseSystem" local SkillTimeSystem = require "Battle/Logic/Entity/System/SkillTimeSystem" local SkillActionSystem = require "Battle/Logic/Entity/System/SkillActionSystem" local SkillMissileSystem = require "Battle/Logic/Entity/System/SkillMissileSystem" local AdjutantSystem = require "Battle/Logic/Entity/System/AdjutantSystem" local StratagemSkillSystem = require "Battle/Logic/Entity/System/StratagemSkillSystem" local BattlePropSystem = require "Battle/Logic/Entity/System/BattlePropSystem" local TimeScaleSystem = require "Battle/Logic/Entity/System/TimeScaleSystem" local DeadSystem = require "Battle/Logic/Entity/System/DeadSystem" local BuffSystem = require "Battle/Logic/Entity/System/BuffSystem" local HitSystem = require "Battle/Logic/Entity/System/HitSystem" local DecisionSystem = require "Battle/Logic/Entity/System/DecisionSystem" local TargetSystem = require "Battle/Logic/Entity/System/TargetSystem" local ChangeAvatarSystem = require "Battle/Logic/Entity/System/ChangeAvatarSystem" local CastSystem = require "Battle/Logic/Entity/System/CastSystem" local GroupSystem = require "Battle/Logic/Entity/System/GroupSystem" local PathSystem = require "Battle/Logic/Entity/System/PathSystem" local SwitchTimeSystem = require "Battle/Logic/Entity/System/SwitchTimeSystem" local ReviveSystem = require "Battle/Logic/Entity/System/ReviveSystem" local StateSystem = require "Battle/Logic/Entity/System/StateSystem" local DriveSystem = require "Battle/Logic/Entity/System/DriveSystem" local InteractSystem = require "Battle/Logic/Entity/System/InteractSystem" local ReplaceSystem = require "Battle/Logic/Entity/System/ReplaceSystem" local VisualFieldSystem = require "Battle/Logic/Entity/System/VisualFieldSystem" local BuffSkillSystem = require"Battle/Logic/Entity/System/BuffSkillSystem" local MoveMissileSystem = require "Battle/Logic/Missile/MissileSystem/MoveMissileSystem" local FireNextMissileSystem = require "Battle/Logic/Missile/MissileSystem/FireNextMissileSystem" local TriggerMissileSystem = require "Battle/Logic/Missile/MissileSystem/TriggerMissileSystem" local RetinueSystem = require"Battle/Logic/Entity/System/RetinueSystem" local PetSystem = require "Battle/Logic/Entity/System/PetSystem" local WeaponSoulSystem = require "Battle/Logic/Entity/System/WeaponSoulSystem" local RuntimeDataManager_New_BuffCtrl = RuntimeDataManager.New_BuffCtrl local RuntimeDataManager_Free_BuffCtrl = RuntimeDataManager.Free_BuffCtrl --local BattleEventSystem = require"Battle/Logic/Event/BattleEventSystem" --事件系统 local EventSystem = require('Event/EventSystem') --跨场景寻路传送点 local _targetConveyList = {} --local _targetNode = nil --local _targetCallback = nil local _tempTargetData = nil --根据位置寻路的目标位置,避免重复创建 local FP=FP local LuaConst=LuaConst local string_isNilOrEmpty=string.isNilOrEmpty local EventID=EventID local table=table local ipairs=ipairs local pairs=pairs local type=type --local ZeroV1 = FP.newV1(0) --[[出生( 首次active)]]-- function SystemManager.OnBorn(entity) if not entity:CheckType(LuaConst.CharacterType.NPC) then if not entity.isPickupItem then BuffSystem.AddBornBuffs(entity,false) DriveSystem.OnBorn(entity) end end LevelManager.OnEntityBorn(entity) BattleEventSystem.AfterEntityBorn(entity) end --[[ 激活 ,needOnHorse 只有在关卡第一次 activeType : 激活类型,描述是因为什么激活,比如下载具激活、切将激活、出生激活等等 --]] function SystemManager.Active(entity, needOnHorse, activeType) if entity.components.base.IsActive then-- 只有在switchhero的时候这个是active的 logging.error(LTAG.ERROR, "GWS : entity是active状态,又active一遍 :") end if not entity.isPickupItem then StateSystem.Active(entity, activeType) -- 如果是首次active ,则会执行 SystemManager.OnBorn(主要工作就是加buff) DecisionSystem.OnActive(entity, activeType) end InteractSystem.OnActive(entity, activeType) ExpSystemManager.OnActive(entity.ExpEntity, activeType) if needOnHorse and entity:IsHero() then SystemManager.ExecuteRideHorse(entity, true, nil, activeType) end LevelManager.CurLevelFunc:OnEntityActive(entity, activeType) end --[[ 死亡 ]]-- --DeadQuit跟OnDead在单位死亡时只会调用其中一个 function SystemManager.OnDead(entity, missileID) BattleEventSystem.BeforeEntityDead(entity, missileID) DeadSystem.OnDead(entity,nil,nil,missileID) if not entity:CheckType(LuaConst.CharacterType.NPC) then if entity.isPickupItem then AttrSystem.OnDead(entity) else DriveSystem.OnDead(entity) --这个要先调,必须比Buff早 AttrSystem.OnDead(entity) BuffSystem.OnDead(entity) --Buff的要放在最后,因为Buff要监听前面的所有事件 end end MoveSystem.OnDead(entity) if not entity.isPickupItem then TargetSystem.OnDead(entity) end InteractSystem.OnDead(entity) ExpSystemManager.OnDead(entity.ExpEntity) --尝试杀死其需要一起死亡的人 if not entity.isPickupItem then DeadSystem.FollowDead(entity) end if not entity:CheckType(LuaConst.CharacterType.NPC) and not entity.isPickupItem then ReviveSystem.AfterDead(entity) end if entity:IsHero() then EventSystem.Dispatch(EventID.After_Hero_Dead, entity) end end --[[ 实体卸载 ]]-- function SystemManager.OnUnload(entity, unloadImmediate) if entity.hasUnload then logging.error(LTAG.ERROR, "【LSH】 Unexpected Situation --- Repeat Unload Entity:", entity.EntityID, "LevelID:", LevelManager.GetCurLevelID()) return end entity.hasUnload = true if entity:HasBuffComponent() then BuffSystem.OnDeadQuit(entity) end CampManager.OnEntityUnload(entity) --现在死亡这块3个接口,OnDead、OnUnload、DeadQuit,非常混乱,没有固定的流程,所以这里只能冗余调用来确保引用能清除 if not entity.isPickupItem then entity.components.aiBase:Dispose() if not entity:CheckType(LuaConst.CharacterType.NPC) then DriveSystem.OnDead(entity) --现在死亡这块3个接口,OnDead、OnUnload、DeadQuit,非常混乱,没有固定的流程,所以这里只能冗余调用来确保引用能清除 end StateSystem.DisActive(entity) TargetSystem.OnUnload(entity) if entity.components.move.ShovePriority > 50 then LuaShoveManager.ReSetGridDataOfEntity(entity,true) end end InteractSystem.OnDead(entity) -- 其实在ondead的时候已经处理了 ,但是ondead 有时候走不到 ,所以先加上这个代码,没啥坏处 LogicUpdateManager.RemoveEntity(entity) ExpSystemManager.OnUnload(entity.ExpEntity, unloadImmediate) end --[[ 直接死亡 ]] --DeadQuit跟OnDead在单位死亡时只会调用其中一个 function SystemManager.DeadQuit(entity, levelConditionIgnoreCount, deadParams) BattleEventSystem.BeforeEntityDead(entity) if not entity.isPickupItem then entity.components.aiBase:Dispose() StateSystem.DisActive(entity) end InteractSystem.OnDead(entity) DeadSystem.OnDead(entity, levelConditionIgnoreCount, deadParams) CampManager.OnEntityDead(entity)--现在死亡这块3个接口,OnDead、OnUnload、DeadQuit,非常混乱,没有固定的流程,所以这里只能冗余调用来确保引用能清除 if not entity:CheckType(LuaConst.CharacterType.NPC) and not entity.isPickupItem then BuffSystem.OnDeadQuit(entity) AttrSystem.OnDead(entity) DriveSystem.OnDead(entity) end MoveSystem.OnDead(entity) if not entity.isPickupItem then TargetSystem.OnDeadQuit(entity) end LogicUpdateManager.RemoveEntity(entity) ExpSystemManager.OnDead(entity.ExpEntity) ExpSystemManager.OnUnload(entity.ExpEntity, true) --尝试杀死其需要一起死亡的人 DeadSystem.FollowDeadQuit(entity) if not entity:CheckType(LuaConst.CharacterType.NPC) and not entity.isPickupItem then ReviveSystem.AfterDead(entity) end end --[[ 复活 --]] function SystemManager.OnRevive(entity, isInBornPoint ,skipExp, isNearestBornPoint) CampManager.OnEntityRevive(entity) ReviveSystem.OnRevive(entity) ChangeAvatarSystem.OnRevive(entity) -- 防止复活的时候是变身 AttrSystem.OnRevive(entity) BuffSystem.OnRevive(entity) TargetSystem.OnRevive(entity) SkillBaseSystem.OnRevive(entity) MoveSystem.OnRevive(entity, isInBornPoint, isNearestBornPoint) RotateSystem.OnRevive(entity, isInBornPoint) SwitchTimeSystem.OnRevive(entity) PetSystem.OnRevive(entity) if not skipExp then ExpSystemManager.OnRevive(entity.ExpEntity) end BattleEventSystem.OnEntityAfterRevive(entity) end --回到出生点 function SystemManager.BackToBornPoint(entity) MoveSystem.BackToBornPoint(entity) RotateSystem.BackToBornPoint(entity) PetSystem.BackToBornPoint(entity) entity.ExpEntity:ApplyExpTrans() entity.ExpEntity:ApplyPetExpTrans(true) end --[[ 召唤出怪物,属性被继承 ]]-- function SystemManager.OnAdopted(entity,fatherEntity ,independent ,hpInherit, inheritAttrType) fatherEntity.components.base:OnAdopt(entity) entity.components.base:OnAdopted(fatherEntity) AttrSystem.OnAdopted(entity, fatherEntity, independent, hpInherit, inheritAttrType) end --[[ 召唤物 被 绑定死亡 ;父死子死 --]] function SystemManager.BindDead(sonEntity,fatherEntity) DeadSystem.BindDead(fatherEntity,sonEntity) end --每帧1次的全局Update, 不跟Entity的Update绑定 function SystemManager.OnLogicUpdateGlobal() end --[[ Tick 514components--]] local function OnLogicUpdateNotNil(entity) BattleEventSystem.BeforeLogicUpdate(entity) -- SkillBaseSystem,TimeScaleSystem 需要在 SkillTimeSystem 之前 ReviveSystem.OnLogicUpdate(entity) ChangeAvatarSystem.OnLogicUpdate(entity) --Buff系统的更新间隔处理 if LogicUpdateManager._clientHandleFrame % LuaConst.BuffUpdate_Frequency == 1 then local deltaTime = LuaConst.BuffUpdate_deltaTime BuffSystem.OnLogicUpdate(entity, deltaTime) end SkillTimeSystem.OnLogicUpdate(entity)-- 技能更新↓ 从技能释放的那一帧,作为第0帧。 SkillBaseSystem.OnLogicUpdate(entity) TimeScaleSystem.OnLogicUpdate(entity) SkillActionSystem.OnLogicUpdate(entity) SkillBaseSystem.OnAfterSkillLogicUpdate(entity)-- 技能更新↑ TargetSystem.OnLogicUpdate(entity) GroupSystem.OnLogicUpdate(entity) HitSystem.OnLogicUpdate(entity) AdjutantSystem.OnLogicUpdate(entity) StratagemSkillSystem.OnLogicUpdate(entity) BuffSkillSystem.OnLogicUpdate(entity) AnimSystem.OnLogicUpdate(entity) RotateSystem.OnLogicUpdate(entity) MoveSystem.OnLogicUpdate(entity) DriveSystem.OnLogicUpdate(entity) BuffSystem.OnMove(entity) DeadSystem.OnLogicUpdate(entity) PetSystem.OnLogicUpdate(entity) BattlePropSystem.OnLogicUpdate(entity) WeaponSoulSystem.OnLogicUpdate(entity) SwitchTimeSystem.OnLogicUpdate(entity) entity.components.record:OnLogicUpdate() end SystemManager.OnLogicUpdate = OnLogicUpdateNotNil --region OnLogicUpdate的重定向 local function OnLogicUpdateNil() end function SystemManager.SetLogicUpdateNil() SystemManager.OnLogicUpdate = OnLogicUpdateNil end function SystemManager.SetLogicUpdateNotNil() SystemManager.OnLogicUpdate = OnLogicUpdateNotNil end function SystemManager.LogicUpdateIsNil() return SystemManager.OnLogicUpdate == OnLogicUpdateNil end --endregion OnLogicUpdate的重定向 function SystemManager.OnLogicUpdate_NPC(entity) TimeScaleSystem.OnLogicUpdate(entity) AnimSystem.OnLogicUpdate_NPC(entity) RotateSystem.OnLogicUpdate_NPC(entity) MoveSystem.OnLogicUpdate_NPC(entity) DeadSystem.OnLogicUpdate(entity) end function SystemManager.OnDeActiveUpdate(entity) SkillTimeSystem.OnLogicUpdate(entity) AdjutantSystem.OnLogicUpdate(entity) BuffSkillSystem.OnLogicUpdate(entity) end -- 快速播放结束(追帧结束) function SystemManager.OnFastPlayOver() LevelManager.SetLoadingLevelEnd() ExpSystemManager.OnFastPlayOver() end --buffId:这个SetNextState是被哪个buffId引发的,可以为空,代表不是buff引发的 --sourceEntity:这个SetNextState如果是被buff引发时,代表buff的释放者。可以为空 function SystemManager.SetNextState(stateType, entity, skillID, animName, command, buffId, sourceEntity, hitFlyRate,hitFlyRandom) StateSystem.SetNextState(stateType, entity, skillID, animName, command, buffId) ExpSystemManager.OnNextStateIn(stateType, entity.ExpEntity, sourceEntity, hitFlyRate ,hitFlyRandom) end function SystemManager.ForbidMoveJoystick(entity) MoveSystem.ForbidMoveJoystick(entity) end function SystemManager.CancelForbidMoveJoystick(entity) MoveSystem.CancelForbidMoveJoystick(entity) end --region 技能 --[[ 过滤层 - 攻击 --]] function SystemManager.OnFilterAttack(entity, command) return SkillBaseSystem.OnFilterAttack(entity, command) end --减少指定ID技能的CD function SystemManager.ReduceSkillCurrentCD(entity,skillID,time) SkillTimeSystem.ReduceSkillCurrentCD(entity, skillID, time) end --减少单位所有技能的CD function SystemManager.ReduceCurrentCDOfAllSkill(entity, time) SkillTimeSystem.ReduceCurrentCDOfAllSkill(entity, time) end --百分比减少CD function SystemManager.ReduceSkillCurrentCDByPercent(entity, skillID, percent) SkillTimeSystem.ReduceSkillCurrentCDByPercent(entity, skillID, percent) end --百分比减少单位所有技能的CD function SystemManager.ReduceCurrentCDOfAllSkillByPercent(entity, percent) SkillTimeSystem.ReduceCurrentCDOfAllSkillByPercent(entity, percent) end --百分比减少单位宠物技能的CD function SystemManager.ReducePetSkillCDByPercent(entity, percent) PetSystem.ReducePetSkillCDByPercent(entity, percent) end function SystemManager.ReducePetNormalOrSkillCD(entity, type, subCD) PetSystem.ReducePetNormalOrSkillCD(entity, type, subCD) end function SystemManager.InterruptSkill(entity, reason, notEnterCD) local curSkillData = entity.components.skillBase:GetCurSkillData() if curSkillData then if not notEnterCD then SkillTimeSystem.OnInterruptSkill(entity, curSkillData) end SystemManager.DeleteBuff(entity, LuaConst.SpecialBuffs.InSkilling, nil) --SystemManager.ChangeToSwitchAll(entity) --这里不需要 ChangeToSwitchAll,因为上面删除buff就会导致调用 ChangeToSwitchAll。 这里调用还会引起bug,比如技能特效不被移除 ExpSystemManager.OnInterruptSkill(entity.ExpEntity) FirstPersonEventDispatcher.Player_SkillCoolDown(entity, curSkillData) FirstPersonEventDispatcher.Player_InterruptSkill(entity, curSkillData, reason) end end function SystemManager.IgnoreEnemyOfMonsterType(entity,monsterTypes) TargetManager.IgnoreEnemyOfMonsterType(entity,monsterTypes) end function SystemManager.IgnoreEnemyOfCharacterType(entity,charTypes) TargetManager.IgnoreEnemyOfCharacterType(entity,charTypes) end function SystemManager.OnSkillInterCut(entity ,skillData) --已经和策划说了,这里目前不涉及同步,所以用先CallBack做了,如果后面需要同步玩法也有插播,需要策划配时长,与表现分离开 local interCutCallBack = function() if not entity.hasUnload then LevelManager.PauseLevel(false) SystemManager.OnAttackEnter(entity, skillData, false) CameraController.Instance:ReactiveCamera() end end SystemManager.OffHorse(entity) LevelManager.PauseLevel(true) SystemManager.ResetTransform(entity) local blackRoomPath = entity.components.replace:GetReplaceBlackRoomEffect(skillData.BlackRoom) if not SystemManager.ShowBlackRoomEffect(entity, blackRoomPath, interCutCallBack) then interCutCallBack() end end --是否要播无双技能演出(小黑屋) function SystemManager.ShoulPlayMusouShow(entity) return LevelManager.CurLevelFunc:IsMusouShowOpen(entity) end --[[ 攻击进入 --]] function SystemManager.OnAttackEnter(entity, skillData, batchEffect) SkillBaseSystem.OnAttackEnter(entity) SkillTimeSystem.OnAttackEnter(entity) RotateSystem.OnAttackEnter(entity) BuffSystem.OnAttackEnter(entity) -- 有处理下马 SpeedSystem.OnAttackEnter(entity) AttrSystem.OnAttackEnter(entity, skillData) MoveSystem.OnAttackEnter(entity ,skillData) BattlePropSystem.OnAttackEnter(entity) ExpSystemManager.OnAttackEnter(entity.ExpEntity ,skillData, batchEffect) BattleEventSystem.OnEntitySkillStart(entity,skillData) SkillBaseSystem.AfterAttackEnter(entity, skillData) end --[[ 攻击切入后摇 switchall --]] function SystemManager.ChangeToSwitchAll(entity ,timeIsUpSwitch, interruptType) SkillBaseSystem.ChangeToSwitchAll(entity,timeIsUpSwitch, interruptType) BuffSystem.OnInToSwitchAll(entity) -- SkillBaseSystem.ChangeToSwitchAllFinish(entity,timeIsUpSwitch) end --[[ 攻击动作结束 退出 --]] function SystemManager.OnAttackQuit(entity) SkillBaseSystem.OnOnAttackQuit(entity) SpeedSystem.OnAttackQuit(entity) MoveSystem.OnAttackQuit(entity) BuffSystem.OnAttackQuit(entity) TargetSystem.OnAttackQuit(entity) ExpSystemManager.OnAttackQuit(entity.ExpEntity) EventSystem.Dispatch(EventID.Entity_AfterAttackQuit, entity) end function SystemManager.ForceEnterCDBySkillData(entity, skillData) local comp_SkillBase = entity.components.skillBase local curSkill = comp_SkillBase:GetCurSkillData() SkillTimeSystem.ForceEnterCDBySkillData(entity, skillData) if curSkill and curSkill.BelongTo == skillData.BelongTo then --如果当前技能就是此技能,则需中断(防止后续的SkillSwitch添加进去) comp_SkillBase:ClearCurSkillCacheInfo() SystemManager.DeleteBuff(entity, LuaConst.SpecialBuffs.InSkilling, nil) end end function SystemManager.ForceEnterCD(entity, skillIndex) SystemManager.ForceEnterCDBySkillData(entity, entity.components.skillBase:GetSkillDataBySkillIndex(skillIndex)) end function SystemManager.ForceEnterCDByKeyPos(entity, keyPos) SystemManager.ForceEnterCDBySkillData(entity, entity.components.skillBase:GetSkillDataByKeyPosition(keyPos)) end function SystemManager.GetSkillIndexByKeyPosition(entity,keyPos) return entity.components.skillBase:GetSkillIndexByKeyPosition(keyPos) end function SystemManager.GetSkillKeyPositionBySkillIndex(entity,skillIndex) return entity.components.skillBase:GetSkillKeyPositionBySkillIndex(skillIndex) end function SystemManager.IsNormalAttackBySkillIndex(entity,skillIndex) return SkillBaseSystem.IsNormalAttackBySkillIndex(entity,skillIndex) end function SystemManager.IsNormalAttack(skillData) return SkillBaseSystem.IsNormalAttack(skillData) end --[[ 释放副将技 --]] function SystemManager.OnReleaseAdjutantSkill(entity, skillJoystickPosX, skillJoystickPosZ) AdjutantSystem.OnReleaseAdjutantSkill(entity, skillJoystickPosX, skillJoystickPosZ) end --[[ 释放计略技 --]] function SystemManager.ReleaseStratagemSkill(entity) StratagemSkillSystem.ReleaseStratagemSkill(entity) end function SystemManager.ReleaseBuffSkill(entity, keyPosition) BuffSkillSystem.ReleaseBuffSkill(entity, keyPosition) end --[[ 触发技能事件 --]] function SystemManager.OnTriggerAction(entity, skillEvent ,skillData) local eventType = skillEvent.EventType if eventType == LuaConst.SkillEventType.CallBullet then SkillMissileSystem.OnTriggerAction_Call(entity, skillEvent,skillData) elseif eventType == LuaConst.SkillEventType.ChangeAngleSpeed then SpeedSystem.OnTriggerAction(entity, skillEvent) elseif eventType == LuaConst.SkillEventType.ChangeAvatar or eventType == LuaConst.SkillEventType.ChangeAvatarInheritSkillCD then ChangeAvatarSystem.OnTriggerAction(entity, skillEvent,false) elseif eventType == LuaConst.SkillEventType.ChangeModel then ChangeAvatarSystem.OnTriggerAction(entity, skillEvent,true) elseif eventType == LuaConst.SkillEventType.AddBuff then local ctrlParam = nil if skillEvent.EventParam > FP.Const.Zero then ctrlParam = RuntimeDataManager_New_BuffCtrl() ctrlParam.ForceDuration:Reset(skillEvent.EventParam):Div(1000) end SystemManager.AddBuff(entity,skillEvent.EventIntParam,entity,nil,ctrlParam) elseif eventType == LuaConst.SkillEventType.DeleteBuff then SystemManager.DeleteBuff(entity, skillEvent.EventIntParam, entity) elseif eventType == LuaConst.SkillEventType.BattleEffect then BattleEffect.ExecuteByEffectId(skillEvent.EventIntParam, nil, entity, entity) end end --endregion 技能 --region 子弹 --[[ 召唤子弹 -- 在 子弹更新中给人家buff,buff触发加子弹(如果发射者当帧死亡,下帧不更新它,导致子弹也发射不出来),所以必须update一下 --]] function SystemManager.TryToDoCall(entity, callBullentId ,skillData, reasonType) SkillMissileSystem.TryToDoCall(entity, callBullentId ,skillData, nil, nil, nil, nil, nil, reasonType) end function SystemManager.TryToDoCallByWeaponSoul(entity, callBulletId , skillData , effForward, forceFireDir, forcePos, trackerTarget, forceTarget, reasonType, forceOffsetY) SkillMissileSystem.TryToDoCall(entity, callBulletId , skillData , effForward, forceFireDir, forcePos, trackerTarget, forceTarget, reasonType, forceOffsetY) end --[[ 召唤二次子弹 -- 目前只是为二次子弹使用 --]] function SystemManager.CallNextBullet(missile, nextInfo ,callType) FireNextMissileSystem.CallNextBullet(missile, nextInfo ,callType) end function SystemManager.CallNextBounceBullet(entity, missile, bounceInfo, hitEntity, callId) FireNextMissileSystem.CallNextBounceBullet(entity, missile, bounceInfo, hitEntity, callId) end --[[ 召唤二次子弹 -- 目前只是为二次子弹使用 --]] function SystemManager.AddNewCall(callBulletInfo) SkillMissileSystem.AddCall(callBulletInfo) end function SystemManager.TryCallWeaponSoulBullet(entity) WeaponSoulSystem.TryCallWeaponSoulBullet(entity) end --[[ 子弹:子弹发射 --]] function SystemManager.OnMissileFire(missile, paramData) MoveMissileSystem.OnMissileFire(missile, paramData) TriggerMissileSystem.OnMissileFire(missile, paramData) if missile.ExpMissileList then local renderPosList = missile.Attacker.ExpEntity:GetSubRenderEntityOffsetList() for i,expM in ipairs(missile.ExpMissileList) do local offsetx = renderPosList[i*2-1] local offsetz = renderPosList[i*2] ExpSystemManager.OnMissileFire(expM, paramData, offsetx, offsetz) end else ExpSystemManager.OnMissileFire(missile.ExpMissile, paramData) end end --[[ 子弹Tick --]] function SystemManager.OnMissileUpdate(missile) MoveMissileSystem.OnMissileUpdate(missile) TriggerMissileSystem.OnMissileUpdate(missile) end --endregion 子弹 --region 属性 --[[ 更新属性 buffLayer是删除后剩余的层数,如果不传则为0,认为是删除了全部的层数 ]]-- function SystemManager.DeleteBuffUpdateAttr(entity, buffId, sourceEntityId, buffLayer) AttrSystem.DeleteBuffUpdateAttr(entity, buffId, sourceEntityId, nil, buffLayer) end function SystemManager.SetEntityUIDamageType(entity,uiDamageType) ExpSystemManager.SetEntityUIDamageType(entity.ExpEntity,uiDamageType) end --[[ 只要是有血量改变意图,即便最终血量没有任何改变,也会调用该方法 并非血量变化,而是伤害值7非0就会走这个生命周期。函数命名有问题,之后需要统一修改一下 。伤害值7用于伤害冒字,跟实际血量改变可能不一致,因为策划需求是伤害冒字跟实际血量改变需要不一致 delta:FP类型,伤害值7,即没有应用最终伤害重载值时的伤害值(非绝对值) ※“伤害值7”和“最终伤害重载值”是术语,具有明确定义,具体定义参考文档:threekingdom\document\战斗公式\伤害计算流程.xlsx realDelta:FP类型,伤害值7(非绝对值) value:FP类型,应用伤害值7后的值 batch:伤害冒字合批显示的批次,nil表示不合批 ]]-- function SystemManager.OnHPChange(entity, caster, delta, realDelta, value, op, hpChangeType, batch, missileData) local leftHp = FP.tonumberV1(entity:GetHp()) if leftHp <= 0 then BattleEventSystem.OnEntityGetFatalHPLoss(entity,caster,delta) end if realDelta < FP.Const.Zero and caster.components.target:IsEnemy(entity) then caster.components.record:SetLastHurtEnemy(entity) entity.components.record:SetLastHurtMeEnemy(caster) end AttrSystem.OnHPChange(entity, realDelta, value, op, hpChangeType, missileData) InteractSystem.OnHpChange(entity, realDelta, hpChangeType) BattlePropSystem.OnHpChange(entity, realDelta, hpChangeType) EventSystem.Dispatch(entity.Event_EntityHPChanged, entity, realDelta, value)-- 关卡 EventSystem.Dispatch(EventID.Level_HPChange, entity, caster, delta, op) --统计 EventSystem.Dispatch(entity.Event_EntityIDHPChanged, entity, realDelta, value)--自身 if entity.components.base.CurMonsterFeature.HPToBILog then EventSystem.Dispatch(EventID.BI_LevelHigh,BIManager.BIType.BossHPStage,entity) end LevelManager.CurLevelFunc:OnHpChange(entity ,caster, delta,op, realDelta) --这里以前是传的realDelta,以真实对boss造成的伤害计算得分,现在按照策划的需求改为了delta(伤害值7)。但是有一定可能还会反复修改,因为现在这个做法有不合理之处 ExpSystemManager.OnHPChange(entity.ExpEntity, caster, delta, value, op ,hpChangeType,batch) end --[[ 无双值变化delta:变化值,value:最终值 ]]-- function SystemManager.OnSAChange(entity,delta,value) EventSystem.Dispatch(entity.Event_EntitySAChanged, entity, delta, value) ExpSystemManager.OnSAChange(entity.ExpEntity,delta,value) end --[[ 霸体变化delta:变化值,value:最终值 ]]-- function SystemManager.OnAMChange(entity,delta,value) BuffSystem.OnAMChange(entity,value) EventSystem.Dispatch(entity.Event_EntityAMChanged, entity, delta, value) ExpSystemManager.OnAMChange(entity.ExpEntity, delta, value) end --[[ 直接打破霸体 ]]-- function SystemManager.OnBreakAM(entity) local delta,value = AttrSystem.OnBreakAm(entity) if not value then return end BuffSystem.OnAMChange(entity,value) EventSystem.Dispatch(entity.Event_EntityAMChanged, entity, delta, value) ExpSystemManager.OnAMChange(entity.ExpEntity, delta, value) end --[[ buff 添加护盾 --]] function SystemManager.OnAddPCAttr(entity, buffId , addValue ,sourceEntityId) AttrSystem.OnAddPCAttr(entity, buffId , addValue ,sourceEntityId) ExpSystemManager.OnAddPCBuff(entity.ExpEntity , addValue) end --[[ 护盾的减少 limitBuffId: 指定扣除哪些buff的护盾值 --]] function SystemManager.OnSubPCAttr(entity, opEntity, delta ,justExp ,needShowHurtNum, limitBuffId) if not justExp then AttrSystem.OnSubPCAttr(entity,delta, limitBuffId) end ExpSystemManager.OnSubPCAttr(entity.ExpEntity, opEntity, delta ,justExp ,needShowHurtNum, limitBuffId) end --[[ 护盾的总值减少(分母) --]] function SystemManager.OnSubExpTotalPCAttr(entity,delta) ExpSystemManager.OnSubTotalPCAttr(entity.ExpEntity ,delta) end --endregion 属性 --region 受击 --[[ 表现击飞 ]]-- function SystemManager.OnHitFly(entity) HitSystem.OnHitFly(entity) ExpSystemManager.OnExpHitFly(entity.ExpEntity) end --[[ 逻辑击退 ]]-- function SystemManager.OnHitPush(entity, sourceEntity, missile, moveDuration, horizontalDistance,hitMoveDir,hitMoveDirOffsetAngle) HitSystem.OnHitPush(entity, sourceEntity, missile, moveDuration, horizontalDistance,hitMoveDir,hitMoveDirOffsetAngle) end --[[ 逻辑击拽 圈 ]]-- function SystemManager.OnHitDragRange(entity, sourceEntity, missile, moveDuration, dragParam) HitSystem.OnHitDragRange(entity, sourceEntity, missile, moveDuration, dragParam) end --[[ 逻辑击拽 线]]-- function SystemManager.OnHitDragDistance(entity, sourceEntity, missile, moveDuration, dragParam) HitSystem.OnHitDragDistance(entity, sourceEntity, missile, moveDuration, dragParam) end --[[逻辑 拽 到 某点]]-- function SystemManager.AddHitMoveToPosBySpd(entity, targetPos, moveSpd) HitSystem.HitMoveToPosBySpd(entity, targetPos, moveSpd) end --[[逻辑 拽 到 某点 - 固定时间]]-- function SystemManager.AddHitMoveToPosOnTime(entity, targetPos, time) HitSystem.HitMoveToPosOnTime(entity, targetPos, time) end --[[ 受击位移表现 ]]-- function SystemManager.OnHitEnter(entity,hitAddPos) ExpSystemManager.OnHitEnter(entity,hitAddPos) end function SystemManager.OnEnterCliff(entity) entity.ExpEntity:SetUseG(true) end --endregion 受击 --region Buff --[[ 添加buff 这里传入的buffId,不一定是最终添加的buff,因为buffId可能被重定向BuffSystem.AddBuff ]]-- function SystemManager.AddBuff(entity,buffId,sourceEntity,missile,buffCtrlParam) sourceEntity = sourceEntity or entity buffCtrlParam = buffCtrlParam or RuntimeDataManager_New_BuffCtrl() local buffData = BuffSystem.AddBuff(entity,buffId,sourceEntity,missile,buffCtrlParam) if buffData and buffCtrlParam.MissileHitMoveID then -- 只有是子弹表中,给被打击者加受击动作时才旋转 RotateSystem.OnAddMissileHitBuff(entity,buffId,missile) end RuntimeDataManager_Free_BuffCtrl(buffCtrlParam) -- 需要知道添加buff是成功还是失败 return buffData ~= nil end function SystemManager.OnEventTriggeredBuff(buff,buffUpdateData,buffTriggerData,eventSubject,params) BuffManager.ExecuteBuffEventTriggerAction(buff,buff:GetData(),buffTriggerData,eventSubject,buffUpdateData,params) end --[[ 删除buff ]]-- function SystemManager.DeleteBuff(entity, buffId, sourceEntity) sourceEntity = sourceEntity or entity BuffSystem.DeleteBuff(entity,buffId,sourceEntity) end function SystemManager.DeleteBuffAnySourceEntity(entity, buffId) BuffSystem.DeleteBuff(entity,buffId,nil, true) end function SystemManager.RemoveParentEquipment(entity) --↓ 这块要跟 ExpEntity:RemoveParentEquipment 代码匹配 local CurModelData = entity.components.replace:GetCurExpModelData() local equipData = DataSheetManager.EquipPartsData:GetDataByID(CurModelData.EquipmentID) local unslotAnimsRandomIndex for i,equipPart in ipairs(equipData.EquipPart_Table) do if equipPart.IsParent then if equipPart.UnslotAnims and #equipPart.UnslotAnims > 0 then unslotAnimsRandomIndex = unslotAnimsRandomIndex or {} table.insert(unslotAnimsRandomIndex, LogicRandom.GetIntegerValue(nil, 1, #equipPart.UnslotAnims ,2001)) end end end --↑ 这块要跟 ExpEntity:RemoveParentEquipment 代码匹配 ExpSystemManager.RemoveParentEquipment(entity.ExpEntity, unslotAnimsRandomIndex) end function SystemManager.OnNotifyBuff(id) --跟策划约定的规则,关卡行为配置的id从1开始,而关卡事件需要加____LEVEL_NOTIFY_START____ id = id + LuaConst.EBattleEventId.____LEVEL_NOTIFY_START____ BattleEventSystem.OnNotifyBuff(id) end function SystemManager.ActiveServerPlayerBuff(entity) local buffInfo = LevelPlayerManager.DequeuePlayerBuff() if buffInfo then local entities = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(entity:GetPlayerID()) for i,entity in ipairs(entities) do LevelManager.CurLevelFunc:AddBuffByServerBuffInfo(entity, buffInfo) end else logging.error(LTAG.ERROR, "HYW : 警告!队列为空时试图ActiveServerPlayerBuff,肯定哪里写错了!!") end end --endregion Buff --region AI --[[ 决策层 ]]-- function SystemManager.HandleDecision(entity, command) DecisionSystem.HandleDecision(entity, command) end --[[ 过滤层 - 特殊决策 ]]-- function SystemManager.FilterDecision(entity, command, isOnce, stateType, animName) return DecisionSystem.FilterDecision(entity, command, isOnce, stateType, animName) end function SystemManager.FilterDecision_NPC(entity, command, stateType, animName) return DecisionSystem.FilterDecision_NPC(entity, command, stateType, animName) end --[[ 群组 --]] function SystemManager.OnGroupAddEntity(groupID, groupEntity, entity) GroupSystem.OnAddEntity(groupID, groupEntity, entity) end function SystemManager.OnGroupRemoveEntity(groupEntity, entity) GroupSystem.OnRemoveEntity(groupEntity, entity) end --[[ 寻路 priorityWall: 不忽略优先级墙,优先级墙是高priority的单位占的格子 --]] function SystemManager.FindPath(entity, endPos, needSmooth, priorityWall) PathSystem.FindPath(entity, endPos, needSmooth, priorityWall) end --[[ 寻路 2 - 给表现使用 priorityWall: 不忽略优先级墙,优先级墙是高priority的单位占的格子 --]] function SystemManager.FindPath2(entity, endPos, needSmooth, priorityWall) PathSystem.FindPath2(entity, endPos, needSmooth, priorityWall) end --[[ AI相关 ]]-- function SystemManager.OnNotifyAI(entity, id) --entity.components.levelMessage:SetLevelMessageID(id) --改到了aibase里去了 entity.components.aiBase:SetLevelMessageID(id) LevelManager.CurLevelFunc:OnNotifyAI(entity, id) end function SystemManager.OnLockAI(entity, lock) if lock then DecisionSystem.DisActiveAI(entity) else DecisionSystem.ActiveAI(entity) end end function SystemManager.SetCanEnterCliff(entity,value) entity.components.move:SetCanEnterCliff(value) end function SystemManager.SetMaterialByType(target ,type1) ExpSystemManager.SetMaterialByType(target ,type1) end function SystemManager.ResetMaterial(target) ExpSystemManager.ResetMaterial(target) end function SystemManager.SetKeepFallDown(target,bol) ExpSystemManager.SetKeepFallDown(target.ExpEntity,bol) end --[[ 设置技能的 摇杆位置 --记录摇杆的位置 ]]-- function SystemManager.SetSkillJoystickPos(entity,pos) SkillBaseSystem.SetSkillJoystickPos(entity,pos) end --[[ 进入技能决策,设置技能的目标位置 ]]-- function SystemManager.OnSetSkillAimPos(entity,pos) SkillBaseSystem.OnSetSkillAimPos(entity,pos) end --[[ 设置技能的 所有子弹的出生点 ]]-- function SystemManager.SetSkillMissilePos(entity,pos) SkillBaseSystem.SetSkillMissilePos(entity,pos) end --设置技能旋转后的朝向 (旋转后的朝向 = 目标朝向 + 缩放结束后的后续旋转角度);dir 可以不归一化 function SystemManager.SetSkillRSAimDir(entity,dir, offsetAngle) SkillBaseSystem.SetSkillRSAimDir(entity,dir, offsetAngle) end --endregion AI --region 时间缩放 --[[ BreakTimeScale ]]-- function SystemManager.OnBreakTimeScale(entity, istoBreak, breakType) TimeScaleSystem.OnBreakTimeScale(entity, istoBreak, breakType) end --[[ 添加时间缩放 ]]-- function SystemManager.OnAddTimeScale(entity, id, scale, time, breakType,timeScaleChannel) TimeScaleSystem.AddTimeScale(entity, id, scale, time, breakType,timeScaleChannel) end --[[ 删除时间缩放 ]]-- function SystemManager.OnDeleteTimeScale(entity, id, scale) TimeScaleSystem.DeleteTimeScale(entity, id, scale) end function SystemManager.DeleteAllTimeScale(entity) TimeScaleSystem.DeleteAllTimeScale(entity) end --[[ 刷新时间缩放, 会刷新所有channel -- ]] function SystemManager.OnRefreshTimeScale(comp_TimeScale, entity, ignoreSound, timeScaleChannel) TimeScaleSystem.ExecuteChangeTimeScale(comp_TimeScale) ExpSystemManager.OnTimeScaleChange(entity.ExpEntity, ignoreSound, timeScaleChannel) end --[[ 设置 奔跑的动作 动画播放速度 battleEffect 调用]] -- speedState : 0 正常 ,1 慢 , 2 快 function SystemManager.ChangeMoveAnimationPlaySpeed(entity, speedState) AnimSystem.ChangeMoveAnimationPlaySpeedState(entity,speedState) ExpSystemManager.ChangeMoveAnimationPlaySpeed(entity.ExpEntity, speedState==1 and LuaConst.RunAnimSlowSpeed or 1) end --[[ 刷新动作缩放 -- state_move自身调用]] function SystemManager.RefreshMoveExpAnimSpeed(entity, speed) ExpSystemManager.ChangeMoveAnimationPlaySpeed(entity.ExpEntity, speed) end --endregion 时间缩放 --[[ 位置有变化 ]]-- function SystemManager.OnMove(entity) InteractSystem.OnMove(entity) DeadSystem.OnMove(entity) end --[[ 传送位置 ]]-- function SystemManager.OnConvey(entity,pos,forward,dontReset,camAngle,ignoreBlock,dontBreakAi) LuaShoveManager.ReSetGridDataOfEntity(entity, true) if entity:IsAlive() then AnimSystem.OnBreak(entity) end SkillBaseSystem.OnBreak(entity) if not dontBreakAi then DecisionSystem.OnBreak(entity,dontReset) end if forward then RotateSystem.OnConvey(entity, forward) end MoveSystem.OnConvey(entity, pos, ignoreBlock) ChangeAvatarSystem.ResetOriginalModel(entity) AdjutantSystem.OnConvey(entity) if entity:IsAlive() then --2022年3月7日 仅当单位存活时,才切idle。不然如果单位死亡了趴在地上,一旦convey就会站起来 SystemManager.SetNextState(LuaConst.StateType.Idle, entity) --传送后强行置为idle状态,主要是为了清空StateType.Attack状态的数据,避免再释放残留的AutoNextID的技能 end PetSystem.OnConvey(entity) SystemManager.ResetTransform(entity) ExpSystemManager.OnConvey(entity.ExpEntity, camAngle) EventSystem.Dispatch(EventID.Convey, entity) if entity.retinueList then if forward then RetinueSystem.OnConvey(entity, pos, forward) end end end function SystemManager.BreakState(entity) AnimSystem.OnBreak(entity) SkillBaseSystem.OnBreak(entity) DecisionSystem.OnBreak(entity) end function SystemManager.OnWinBattle(entity,pos,forward,winEffect) if not LevelManager.ShouldKeepSyncLevel() and not LevelManager.IsGoldHeroCooperate() then NotSyncBattleSetter.SetPveAutoFightState(false) end RotateSystem.OnConvey(entity, forward) MoveSystem.OnConvey(entity, pos) ChangeAvatarSystem.OnWinBattle(entity) AdjutantSystem.OnConvey(entity) SystemManager.OffHorse(entity)-- 下马 BuffSystem.OnWinBattle(entity) ExpSystemManager.OnWinBattle(entity.ExpEntity,winEffect) entity.components.anim:InvalidateSetAnim() --禁用entity的动画设置,这样victoryPose动画就再也不会被修改了 end --[[ 改变挤压优先级 ]]-- function SystemManager.OnChangeShovePriority(entity, priority) if entity:IsAdjutant() then -- 副将不能改变优先级,副将不会和任何东西碰撞的,副将也不能改变地形的阻挡 return end if priority then MoveSystem.OnSetShovePriority(entity,priority) else MoveSystem.OnResetShovePriority(entity) end end --[[ 根据资源设置目标 ]] --只会选择资源没有满的英雄 --优先距离近的 function SystemManager.ChangeTargetByResource(entity, disSqr) TargetSystem.ChangeTargetByResource(entity, disSqr) end function SystemManager.OnSetTarget(entity, target, oldTarget) ExpSystemManager.OnSetTarget(entity, target, oldTarget) end --[[ 根据令旗数量设置目标(逐鹿中原(大乱斗)玩法使用) ]] --只会选择令旗没有满的英雄 --优先距离近的 function SystemManager.ChangeTargetByFlagAmount(entity, disSqr) TargetSystem.ChangeTargetByFlagAmount(entity, disSqr) end --[[ 寻找目标 ]]-- -- camp: 1=敌人, 2=友方不包括自己, 3=自己, 4=友方包括自己 -- searchType : ESearchTargetInListSearchType枚举值 -- monsterType : ESearchTargetCharacterType枚举值 -- ignoreCanNotBeTargetBuff : 会选择身上挂有100047(不可被AI选为Target)Buff的目标 -- noInvincible : 不选择无敌的敌人 -- targetTypeSort : targetTypePriorityGetter为空的情况下按照BOSS>精英>小怪的优先顺序选择, 否则按照在targetTypePriorityGetter返回的priority进行优先顺序选择。 -- targetTypePriorityGetter : 自定义优先级查询器,接收entity作为参数,返回一个 1-3 的整数作为优先级(目前最多只支持3档)。优先级越大越优先被选为目标。 function SystemManager.OnSearchTarget(entity, camp, disSqr, searchType, monsterType, ignoreCanNotBeTargetBuff, noInvincible, targetTypeSort, targetTypePriorityGetter) TargetSystem.OnSearchTarget(entity, camp, disSqr, searchType, monsterType, ignoreCanNotBeTargetBuff, noInvincible, targetTypeSort, targetTypePriorityGetter) end function SystemManager.SearchEnemyMonsterOfLevelItem(entity, itemID, center, radius, length, width, dir) TargetSystem.SearchEnemyMonsterOfLevelItem(entity, itemID, center, radius, length, width, dir) end --radius传FP -- ignoreCanNotBeTargetBuff : 会选择身上挂有100047(不可被AI选为Target)Buff的目标 -- noInvincible : 不选择无敌的敌人 -- ignoreBeSkillTargetBuff : 为true时会选择身上没有100046(技能自动索敌能被锁到)Buff的目标 function SystemManager.SearchTargetInCircle(entity, center, radius, ignoreCanNotBeTargetBuff, noInvincible, ignoreBeSkillTargetBuff) TargetSystem.SearchTargetInCircle(entity, center, radius, ignoreCanNotBeTargetBuff, noInvincible, ignoreBeSkillTargetBuff) end --width、height传FP -- ignoreCanNotBeTargetBuff : 会选择身上挂有100047(不可被AI选为Target)Buff的目标 -- noInvincible : 不选择无敌的敌人 function SystemManager.SearchTargetInRect(entity, center, length, width, dir, ignoreCanNotBeTargetBuff, noInvincible) TargetSystem.SearchTargetInRect(entity,center, length, width, dir, ignoreCanNotBeTargetBuff, noInvincible) end --在圆形范围内寻找指定CharacterID和CharacterType的敌人 function SystemManager.SearchEnemyCharAsTargetInCircle(entity, center, radius, characterID, characterType) TargetSystem.SearchEnemyCharAsTargetInCircle(entity, center, radius, characterID, characterType) end --在矩形范围内寻找指定CharacterID和CharacterType的敌人 function SystemManager.SearchEnemyCharAsTargetInRect(entity, center, length, width, dir, characterID, characterType) TargetSystem.SearchEnemyCharAsTargetInRect(entity, center, length, width, dir, characterID, characterType) end --[[ 寻找跟随目标 ]]-- -- monsterType : ESearchTargetCharacterType枚举值 -- ignoreCanNotBeTargetBuff : 会选择身上挂有100047(不可被AI选为Target)Buff的目标 -- noInvincible : 不选择无敌的敌人 -- targetTypeSort : targetTypePriorityGetter为空的情况下按照BOSS>精英>小怪的优先顺序选择, 否则按照在targetTypePriorityGetter返回的priority进行优先顺序选择。 -- targetTypePriorityGetter : 自定义优先级查询器,接收entity作为参数,返回一个 1-3 的整数作为优先级(目前最多只支持3档)。优先级越大越优先被选为目标。 function SystemManager.OnSearchFollowTarget(entity, camp, disSqr, searchType, monsterType, ignoreCanNotBeTargetBuff, noInvincible, targetTypeSort, targetTypePriorityGetter) TargetSystem.OnSearchFollowTarget(entity, camp, disSqr, searchType, monsterType, ignoreCanNotBeTargetBuff, noInvincible, targetTypeSort, targetTypePriorityGetter) end --[[ 寻找entity的友方 ]]-- function SystemManager.OnGetFriendList(entity) return TargetSystem.Get2DFriendList(entity) end --[[ 寻找entity的敌方 ]]-- function SystemManager.OnGetEnemyList(entity) return TargetSystem.Get2DEnemyList(entity) end function SystemManager.OnSearchTargetBySkill(entity, skillID) TargetSystem.OnSearchTargetBySkill(entity, skillID) end function SystemManager.SearchPetSkillTarget(entity) local targetComp = entity.components.target local target = targetComp.Target local petComp = entity.components.pet if target and targetComp.ToTargetDisSqr <= petComp.searchRadiusSqr then -- 玩家的target只有在释放技能时才设置,技能释放完毕后target不清理。所以宠物加上范围限制。 return target end target = TargetSystem.SearchPetSkillTargetInCircle(entity, petComp.searchRadius) return target end -- buffSkill的索敌(buffSkill 没有动画,故都是子弹的位置) function SystemManager.SearchTargetByBuffSkill(entity, buffSkillData) return TargetSystem.SearchTargetByBuffSkill(entity, buffSkillData) end function SystemManager.CreateMonster(monsterID, posX, posZ, forwardX, forwardZ, bornItemID, skipFindFinalPos) if monsterID and monsterID > 0 then if posX and posZ then forwardX = forwardX or 1 forwardZ = forwardZ or 0 local posV2 = FP.newV2(posX, posZ) local dirV2 = FP.newV2(forwardX, forwardZ) EntityFactory.SetType_ID(LuaConst.CharacterType.Monster, monsterID) EntityFactory.SetPos_Dir(posV2, dirV2) EntityFactory.SetParams("BornItemID", bornItemID) if skipFindFinalPos == true then EntityFactory.SetParams("SkipFindFinalPos", true) end local entity = EntityFactory.DoCreateEntity() local priority = entity.components.move.ShovePriority if priority > 50 then LuaShoveManager.SetGridDataByPriorityOfEntity(entity, priority, true, true) end LevelItemManager.Global:Notify_MonsterBorn(entity) return entity else logging.error(LTAG.ERROR, "HYW : 错误的位置 @SystemManager.CreateMonster : posX : ", posX, " posZ : ", posZ) end else logging.error(LTAG.ERROR, "HYW : 错误的monsterID @SystemManager.CreateMonster : ", monsterID) end end function SystemManager.SetTarget(entity, target) TargetSystem.SetTarget(entity, target) if entity.components.base.CurMonsterFeature.IsLookIK then SystemManager.LookToEntity(entity, target) end end function SystemManager.SetCurEntity(entity) if entity ~= LogicUpdateManager._curEntity then local oldEntity = LogicUpdateManager._curEntity LogicUpdateManager.SetCurEntity(entity) EventSystem.Dispatch(EventID.Set_CurEntity) LevelManager.OnSetCurEntity(entity,oldEntity) end ExpSystemManager.SetCurEntity(entity.ExpEntity) end function SystemManager.SetFollowTarget(entity, target) TargetSystem.SetFollowTarget(entity, target) ExpSystemManager.OnSetFollowTarget(entity.ExpEntity, target) end function SystemManager.SwtichForceTargetByIndex(entity, index, reason) local id, isSet = LevelManager.SwtichForceTargetByIndex(entity, index) if isSet and entity:GetFightMode() == LuaConst.EFightMode.PEACE then SystemManager.SwitchFightMode(entity:GetPlayerID(), reason) end FirstPersonEventDispatcher.UIBattle_MainPlayerForceTargetChanged(entity, id, isSet) end --天命:背后的特效 function SystemManager.ShowWeaponSoulPsEffect(entity, isShow) if entity and entity.ExpEntity then entity.ExpEntity:ShowWeaponHaloLightBallEffect(isShow) end SystemManager.ShowPSEffect(entity, ConstAssetPathConfig.RelativeEffect.Func_ForgeSou_Relative) end --[[ 播放PS特效 ]]-- -- Play Ps Effect Directly -- needRecord: 需要进行记录,用于模型剔除恢复时显示用 function SystemManager.ShowPSEffect(entity, effect, needRecord) if string_isNilOrEmpty(effect) then return end return ExpSystemManager.ShowPSEffect(entity, effect, needRecord) end function SystemManager.ShowBlackRoomEffect(entity, effect, callback) if string_isNilOrEmpty(effect) then return end return ExpSystemManager.ShowBlackRoomEffect(entity, effect, FP.Const.One, nil, LuaConst.Layer.BlackRoom, callback) end -- Cache Ps Effect and Batch Play Later, For Optimize function SystemManager.OnReceivePsEffect(entity, effect, isCountEffect) if string_isNilOrEmpty(effect) then return end entity.ExpEntity:ReceivePsEffect(effect, isCountEffect, entity) end function SystemManager.ReceiveHitEffect(entity, effect, timeScale, duration, fx, fz, hitSoundLevel, isNotPlayHitSound) if string_isNilOrEmpty(effect) then return end entity.ExpEntity:ReceiveHitEffect(effect, timeScale, duration, fx, fz, hitSoundLevel, isNotPlayHitSound) end --[[ 停止特效]] function SystemManager.StopPSEffect(entity, effect) if not entity or string_isNilOrEmpty(effect) then return end entity.ExpEntity:StopPsEffect(effect) end --[[ 中断特效]] function SystemManager.OnBreakPSEffect(entity, effect, isCountEffect) if not entity or string_isNilOrEmpty(effect) then return end entity.ExpEntity:BreakPsEffect(effect, isCountEffect, entity) end function SystemManager.OnBreakPSEffectAll(entity) if not entity then return end entity.ExpEntity:BreakPsEffectAll() end --[[ 播放普通特效 ]]-- function SystemManager.OnShowEffect(entity, effect, show, doWhenfastPlay) if not doWhenfastPlay and LogicUpdateManager.IsInReconnectFastPlay() then return end if not entity then return end if string_isNilOrEmpty(effect) then return end if show then entity.ExpEntity:PlayEffectByType(effect) else entity.ExpEntity:StopEffectByType(effect) end end function SystemManager.OnShowObject(entity, show, path) ExpSystemManager.OnShowObject(entity.ExpEntity, show, path) end local EMPTY_TIMELINE_CALLBACK_PLACEHOLDER = "$%^&*(%^&*" --空的callback,用这个变量占位,为的是代码能写得稍微好看点 -- sourceFlag:哪个系统调过来的,用来做同步调用Check。不要随便填值,不知道填就空着! function SystemManager.PlayTimeline(path, pauseLevel, autoPassTime, callback, sourceFlag, duration, isStandaloneMode, adsorbType, adsorbParam) local record = nil if LevelManager.IsNeedCheckNotSyncLevel() then -- 单机校验的关卡都没timeline callback(path, 0, false) return end if LevelManager.IsSyncLevel() and not isStandaloneMode then if sourceFlag ~= LuaConst.ETimelinePlayReqSourceFlag.LEVEL_ITEM_GLOBAL and sourceFlag ~= LuaConst.ETimelinePlayReqSourceFlag.DECISION_TIMELINE and sourceFlag ~= LuaConst.ETimelinePlayReqSourceFlag.TEAMPVPFINISH then logging.error(LTAG.ERROR, "HYW : 联机玩法从非法的地方调用了播timeline,这是不允许的!目前联机玩法只允许用关卡行为和AI决策播!!") return end if not pauseLevel then pauseLevel = true logging.log(LTAG.ERROR, "HYW : 联机玩法播放timeline时必须暂停!!!强制设为暂停!!") end --联机玩法中要劫持callback存起来,不让视图层直接调, 因为callback通常包含逻辑,不能让视图层直接调用,否则会不一致 --callback会被command驱动的代码调用,这样才能帧同步 record = {} record.callback = callback or EMPTY_TIMELINE_CALLBACK_PLACEHOLDER record.path = path record.pauseLevel = pauseLevel record.duration = duration or 15 --这里以前是180秒,太长了,直接改为15秒,免得玩家等太久 record.autoPassTime = autoPassTime record.isStandaloneMode = isStandaloneMode record.adsorbType = adsorbType record.adsorbParam = adsorbParam record.battleRoomID = BattleDataGetter.GetBattleRoomID() if not duration then logging.error(LTAG.ERROR, "HYW : 警告!联机玩法播放timeline没有设置超时时间! 关卡ID : ", LevelManager.GetCurLevelID(), " timeline path : ", path) end SystemManager.syncTimelineRecordList[#SystemManager.syncTimelineRecordList + 1] = record SystemManager.lastTimelineRecord = record callback = nil LevelManager.CurLevelFunc:OnPlaySyncTimeline() end ExpSystemManager.PlayTimeline(path, pauseLevel, autoPassTime, callback, record, isStandaloneMode, adsorbType, adsorbParam) end --由c#调过来,在每段Timeline开始时时都会调用 function SystemManager.OnTimelineStart(timelinePath, pauseLevel, adsorbType, adsorbParam) EventSystem.Dispatch(EventID.Timeline_OnStart, timelinePath) if pauseLevel then LevelManager.PauseLevel(true) end if adsorbType == 1 then --吸附到怪物实体 for i,entity in LogicUpdateManager.ValidMonsterEntityIter() do if entity:GetCharacterID() == adsorbParam then local posX, posZ = FP.tonumberV2(entity.components.move.LogicPos) local dirX, dirZ = FP.tonumberV2(entity.components.move.LogicRotateDir) return true, posX, posZ, dirX, dirZ end end elseif adsorbType == 2 then --吸附到元素 local levelItemData = LevelItemManager.GetItemDataByID(adsorbParam) local posX, posZ = FP.tonumberV2(levelItemData.ItemPos) local dirX, dirZ = FP.tonumberV2(levelItemData.ItemDir) return true, posX, posZ, dirX, dirZ end return false end --由c#调过来,在每段Timeline结束时都会调用 -- pauseLevel:结束的这个Timeline是否在开始时暂停了Update -- queueLeftCount:队列里剩余几段Timeline function SystemManager.OnTimelineFinish(pauseLevel, queueLeftCount, idStr, qteLevel, isReward) EventSystem.Dispatch(EventID.Timeline_OnFinish) if LevelManager.IsSyncLevel() then -- Check↓ 可以删除。 因为目前联机玩法不支持qte和timeline奖励,所以这里做个check,如果策划配了qte或者奖励,就提醒一下 -- 如果需要支持qte或者timeline奖励,需要用适合帧同步的方式管理参数,不能直接从这里把idStr, qteLevel, isReward 这些传给战斗逻辑层。并且需要支持Lua直接读取timeline数据。 if qteLevel ~= 0 then logging.error(LTAG.ERROR, "HYW : 联机玩法的timeline暂不支持qte,如果有需求一定要支持,请联系战斗程序! qteLevel:", qteLevel) end if isReward then logging.error(LTAG.ERROR, "HYW : 联机玩法的timeline暂不支持timeline发奖励,如果有需求一定要支持,请联系战斗程序!") end -- Check↑ if LevelPlayerManager.IsMainPlayerTeamLeader() or LevelPlayerManager.IsMainPlayerFirstOnlinePlayer() then --主视角safe if queueLeftCount == 0 then LevelManager.PauseLevel(false, SystemManager.lastTimelineRecord and SystemManager.lastTimelineRecord.battleRoomID or nil) --安全的调用,LevelManager.PauseLevel做过特殊处理,同步玩法中LevelManager.PauseLevel不会执行逻辑代码 end end else if pauseLevel then NotSyncBattleSetter.PauseLevel(false) end end return 1 end function SystemManager.OnCmdAllTimelineFinish() if LevelManager.IsSyncLevel() then LevelManager.isPlayingTimeline = false for i,record in ipairs(SystemManager.syncTimelineRecordList) do if record.callback ~= EMPTY_TIMELINE_CALLBACK_PLACEHOLDER then record.callback(record.path, 0, false) end end SystemManager.syncTimelineRecordList = {} ExpSystemManager.OnCmdAllTimelineFinish() end end --播放PS特效 --必须传的参数:effectPath全路径 --duration:持续时间,对于loop的PsInstance有效,时间一过会丢到PsInstance的池子里 --parent是特效的父节点,可以传Entity,也可以传UI节点,不传则在场景里的PsRoot下 --屏幕特效可不传Entity,会自动挂在主相机上;layer不传则取Entity身上的layer,无Entity则取自己的layer --需要挂载在Entity的,挂点在特效上已经设置好 --callBack是PsRoot下所有Action全部播放的回调 --特效正常播完会回收到池子,如果挂在UI上在关闭界面时需要调用AuxUtil.StopDynamicObject回收 function SystemManager.PlayPsEffect(effectPath, parent) -- 给renderEntity播放特效的战斗代码禁止使用 return ExpSystemManager.PlayPsEffect(effectPath, parent) end function SystemManager.PlayBuffEffect(entity, effect, showChance) return ExpSystemManager.PlayBuffEffect(entity.ExpEntity, effect, showChance) end function SystemManager.StopBuffEffect(entity, playID, breakEffect) return ExpSystemManager.StopBuffEffect(entity.ExpEntity, playID, breakEffect) end -- 进入到队列播放中 --宝物使用 function SystemManager.AddQueueEffect(entity, effect) ExpSystemManager.AddQueueEffect(entity.ExpEntity, effect) end --[[ 追击 --]] function SystemManager.OnCheckNeedCastWhenAttack(entity, command, skillID) return CastSystem.OnCheckNeedCastWhenAttack(entity, command, skillID) end function SystemManager.BeforeChangeAvatar(entity, recover) BattleEventSystem.BeforeChangeAvatar(entity, recover) if entity.components.move.ShovePriority > 50 then LuaShoveManager.ReSetGridDataOfEntity(entity,true) end end --[[ 大变身 isFree : 自由变身(非预定的变身) --]] function SystemManager.OnChangeAvatar(entity, recover, withBornSkill, stopRideHorse, withMagicWeapon, isFree, isInheritSkillCD, inheritSkillKeyPosList) AnimSystem.OnChangeModel(entity) SkillBaseSystem.OnChangeAvatar(entity,recover, withBornSkill, isFree, isInheritSkillCD, inheritSkillKeyPosList) BuffSystem.OnChangeAvatar(entity,recover) DecisionSystem.OnChangeAvatar(entity) MoveSystem.OnResetShovePriority(entity) BuffSystem.OnChangeModel(entity, not stopRideHorse) BattleEventSystem.AfterChangeAvatar(entity, recover) ExpSystemManager.OnChangeAvatar(entity.ExpEntity, withMagicWeapon) if recover then EventSystem.Dispatch(EventID.Entity_RecoverModel, entity) end end function SystemManager.SetVisual(entity, level, group) if entity.components.visualField then entity.components.visualField:SetVisual(level, group) end end function SystemManager.SetVisibility(entity, level, group) if entity.components.visualField then entity.components.visualField:SetVisibility(level, group) end end --视野发生变化,只要视野等级或视野组任意发生变化,就会走这个方法 function SystemManager.OnVisualFieldChanged(entity, oldLv, oldGroup) VisualFieldSystem.OnVisualFieldChanged(entity.components.visualField, oldLv, oldGroup) LevelManager.CurLevelFunc:OnVisualFieldChanged(entity, oldLv, oldGroup) ExpSystemManager.OnVisualFieldChanged(entity.ExpEntity, oldLv, oldGroup) end function SystemManager.OnVisiblityChanged(entity, oldLv, oldGroup) VisualFieldSystem.OnVisiblityChanged(entity.components.visualField, oldLv, oldGroup) LevelManager.CurLevelFunc:OnVisiblityChanged(entity, oldLv, oldGroup) ExpSystemManager.OnVisiblityChanged(entity.ExpEntity, oldLv, oldGroup) end --[[ 换皮 - 修改模型外观(和小变身类似,但是不改变逻辑相关数值) replaceModelID = 0 ,则表示还原为最初的模型外观 --]] function SystemManager.ReplaceModelSkin(entity,replaceModelID) ReplaceSystem.ReplaceModel(entity, replaceModelID) ExpSystemManager.OnChangeModel(entity.ExpEntity, true) end --[[ 换皮 - 特效 --]] function SystemManager.AddReplaceBattlePSSkin(entity,skinReplaceID) ReplaceSystem.AddReplaceBattlePSSkin(entity, skinReplaceID) end --时装换外显数据 function SystemManager.ReplaceModel_ByHeroAppearance(entity, heroAppearanceId) ReplaceSystem.ReplaceModel_ByHeroAppearance(entity, heroAppearanceId) end function SystemManager.SetSkillListByCharacterID(entity,characterID) SkillBaseSystem.SetSkillListByCharacterID(entity,characterID) end function SystemManager.RevertToOriginSkillList(entity) SkillBaseSystem.RevertToOriginSkillList(entity) end function SystemManager.ReplaceNormalSkillBySkillID(entity, newSkillID) SkillBaseSystem.ReplaceNormalSkillBySkillID(entity, newSkillID) end function SystemManager.AddSkillDecorator(entity, skillID, skillDecoratorType, ...) SkillBaseSystem.AddSkillDecorator(entity, skillID, skillDecoratorType, ...) end function SystemManager.DeleteSkillDecorator(entity, skillID, skillDecoratorType) SkillBaseSystem.RemoveSkillDecoratorByType(entity, skillID, skillDecoratorType) end function SystemManager.GetSkillDecoratorByType(type) return SkillBaseSystem.GetSkillDecoratorByType(type) end --禁用技能键位 function SystemManager.BanKeyPositions(entity,sourceEntity,keyPosList) SkillBaseSystem.BanKeyPositions(entity,sourceEntity,keyPosList) end function SystemManager.CancelBanKeyPosition(entity, sourceEntity) SkillBaseSystem.CancelBanKeyPosition(entity, sourceEntity) end function SystemManager.JustChangeExpAnim(entity,animation) entity.ExpEntity:PlayAnimation(animation, 0) end function SystemManager.SetAnimIDOverride(entity, originID, overrideToID) AnimSystem.SetAnimIDOverride(entity, originID, overrideToID) ExpSystemManager.OnSetAnimIDOverride(entity.ExpEntity, originID, overrideToID) end --[[ 小变身 --]] function SystemManager.ChangeModel(entity,modelID, keepAnim ,canRideHorse, withMagicWeapon) ChangeAvatarSystem.ChangeModel(entity, modelID, keepAnim, canRideHorse, withMagicWeapon) end function SystemManager.OnChangeModel(entity, keepAnim ,canRideHorse, withMagicWeapon) SkillBaseSystem.OnChangeModel(entity) AnimSystem.OnChangeModel(entity,keepAnim) BuffSystem.OnChangeModel(entity,canRideHorse) ExpSystemManager.OnChangeModel(entity.ExpEntity, withMagicWeapon) if entity._logicInitData._modelData == entity.components.base.CurModelData then EventSystem.Dispatch(EventID.Entity_RecoverModel, entity) end end --LevelManager的private.InitLevel调用第一行 function SystemManager.BeforeLevelInit() SystemManager.syncTimelineRecordList = {} BuffManager.BeforeLevelInit() BattleEffect.BeforeLevelInit() require("Battle/Logic/Level/ColliderManager").Clear() end --LevelManager的private.InitLevel调用结束 --※注意此时 CurLevelFunc 还没有调用InitLevel function SystemManager.OnLevelInited() ExpSystemManager.OnLevelInited() BuffManager.OnLevelInited() end function SystemManager.ExitLevel() BuffManager.ExitLevel() end --[[ 换人 --]] function SystemManager.OnSwitchHero(fromEntity, toEntity) BattleEventSystem.OnBeforeSwitchHero(fromEntity) local dontBackground = LevelManager.CurLevelFunc:IsAllHeroJoinBattle() ChangeAvatarSystem.OnSwitchHero(fromEntity, toEntity, dontBackground) RotateSystem.OnSwitchHero(fromEntity, toEntity, dontBackground) MoveSystem.OnSwitchHero(fromEntity, toEntity, dontBackground) BuffSystem.OnSwitchHero(fromEntity, toEntity, dontBackground) BuffSkillSystem.OnSwitchHero(fromEntity, toEntity, dontBackground) AttrSystem.OnSwitchHero(fromEntity, toEntity) StratagemSkillSystem.OnSwitchHero(fromEntity, toEntity) SwitchTimeSystem.OnSwitchHero(fromEntity, toEntity) SkillBaseSystem.OnSwitchHero(toEntity, fromEntity, dontBackground) StateSystem.OnSwitchHero(fromEntity, toEntity, dontBackground)--修改逻辑标记:是否active DecisionSystem.OnSwitchHero(fromEntity, toEntity, dontBackground) InteractSystem.OnSwitchHero(fromEntity, toEntity, dontBackground) BattlePropSystem.OnSwitchHero(fromEntity, toEntity) PetSystem.OnSwitchHero(toEntity) ExpSystemManager.OnSwitchHero(fromEntity.ExpEntity, toEntity.ExpEntity, dontBackground)--表现:显示模型、UI等 LevelManager.OnSwitchHero(fromEntity, toEntity, dontBackground) BattleEventSystem.OnAfterSwitchToEntity(toEntity, fromEntity) end function SystemManager.AfterSwitchHero(fromEntity, toEntity) local dontBackground = LevelManager.CurLevelFunc:IsAllHeroJoinBattle() LevelManager.AfterSwitchHero(fromEntity, toEntity, dontBackground) DecisionSystem.AfterSwitchHero(fromEntity, toEntity, dontBackground) end --[[ 切换AI --]] function SystemManager.SetAIByID(entity , aiID) DecisionSystem.SetAIByID(entity, aiID) end --[[ 退场 ]]-- function SystemManager.Background(entity) ExpSystemManager.OnBackground(entity.ExpEntity) BuffSystem.OnBackground(entity) DecisionSystem.OnBackground(entity) StateSystem.OnBackground(entity) TargetSystem.OnBackground(entity) InteractSystem.OnDisActive(entity) LevelManager.CurLevelFunc:OnBackground(entity) end -- 隐藏一个entity ;和Background 很类似 ,但是少执行一些代码 function SystemManager.DisActive(entity ,hidingNeedUpdate) StateSystem.DisActive(entity , hidingNeedUpdate) DecisionSystem.DisActiveAI(entity) InteractSystem.OnDisActive(entity) TargetSystem.OnDisActive(entity) ExpSystemManager.OnDisActive(entity.ExpEntity, not hidingNeedUpdate) end function SystemManager.OnSearchTrackerTarget(missile) return TargetSystem.OnSearchTrackerTarget(missile) end function SystemManager.SetCameraTarget(entity, removeEntity) if LevelManager.IsReplayBattle() then -- 回放时,不显示相机锁定。原因:1、来回切人,导致一些问题;2、观看者不能自由移动相机 return end ExpSystemManager.SetCameraTarget(entity.ExpEntity, removeEntity) end --region 自动寻路 function SystemManager.AutoFindPathInTown(entity, pos, radius, callback, townFindPathType) --都得判空,因为这些调用都可能是被服务器发来的消息驱动的,entity可能不存在 if entity then if entity:IsPlayerSelf() then --主城方法可以有主视角代码 CTL.Level.TryBreakConveyProgress(townFindPathType) end entity.components.autoFight:SetAutoFindPath(pos, radius, callback) EventSystem.Dispatch(EventID.UI_Auto_Tips, LuaConst.AutoType.AutoFindPath) -- 显隐自动寻路提示 end end function SystemManager.StartAutoFindPathInTown(entity) --都得判空,因为这些调用都可能是被服务器发来的消息驱动的,entity可能不存在 if entity then entity.components.autoFight:StartAutoFindPath() EventSystem.Dispatch(EventID.UI_Auto_Tips, LuaConst.AutoType.AutoFindPath) -- 显隐自动寻路提示 end end function SystemManager.StopAutoFightPathInTown(entity, townFindPathType) --都得判空,因为这些调用都可能是被服务器发来的消息驱动的,entity可能不存在 if entity then entity.components.autoFight:StopAutoFindPath(townFindPathType) end end -- 获取自动寻路状态 function SystemManager.GetAutoFindPathInTownState(entity) --都得判空,因为这些调用都可能是被服务器发来的消息驱动的,entity可能不存在 if entity then return entity.components.autoFight:IsAuto() end return false end --endregion function SystemManager.SwitchFightMode(playerID, reason) if reason == LuaConst.ESwitchFightModeReason.DEFAULT or reason == LuaConst.ESwitchFightModeReason.MANUAL and LevelManager.CurLevelFunc:CanSwitchFightModeManually() then local entityTable = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) for i,_entity in ipairs(entityTable) do local fightMode = _entity.components.target:SwitchFightMode() SystemManager.OnFightModeChanged(_entity,fightMode) end end end function SystemManager.SetFightMode(playerID,fightMode,forceRefresh) local entityTable = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) for i,entity in ipairs(entityTable) do local changed = entity.components.target:SetFightMode(fightMode, forceRefresh) if changed or forceRefresh then SystemManager.OnFightModeChanged(entity,fightMode) end end end function SystemManager.SetFightModeOfAllPlayer(fightMode) for playerID,heroEntityList in ipairs(LevelPlayerManager.GetHeroEntities()) do SystemManager.SetFightMode(playerID, fightMode, false) end end function SystemManager.OnFightModeChanged(entity,fightMode) LevelManager:OnFightModeChanged(entity, fightMode) ExpSystemManager.OnFightModeChanged(entity, fightMode) FirstPersonEventDispatcher.UIBattle_MainPlayerFightModeChanged(entity, fightMode) end function SystemManager.RunToPosByIndex(entity, index) LevelManager.CurLevelFunc:RunToPosByIndex(entity, index) end function SystemManager.SwitchAutoFight(entity) LevelManager.SwitchAutoFight(entity) end function SystemManager.StartAutoFight(entity, isSystemLevel) LevelManager.StartAutoFight(entity, isSystemLevel) end function SystemManager.StopAutoFight(entity) LevelManager.StopAutoFight(entity) end function SystemManager.SwitchRightGodBeastSkillOfPlayer(playerID) local entityList = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) if entityList then for i,entity in ipairs(entityList) do SystemManager.SwitchRightGodBeastSkillOfEntity(entity) end end end function SystemManager.SwitchLeftGodBeastSkillOfPlayer(playerID) local entityList = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) if entityList then for i,entity in ipairs(entityList) do SystemManager.SwitchLeftGodBeastSkillOfEntity(entity) end end end function SystemManager.SwitchRightGodBeastSkillOfEntity(entity) BuffSkillSystem.SwitchRightGodBeastSkillOfEntity(entity) end function SystemManager.SwitchLeftGodBeastSkillOfEntity(entity) BuffSkillSystem.SwitchLeftGodBeastSkillOfEntity(entity) end --TODO 不用command,可直接调用的上马接口,后面卫松会整理 function SystemManager.ExecuteRideHorse(entity, dontShowEff, notSendHorseState) if entity:CanRideHorse() then SystemManager.RideHorse(entity, dontShowEff, notSendHorseState) SystemManager.SetNextState(LuaConst.StateType.Idle, entity, 0)--不加这句话的话,人的动作不会刷新 end end --上马 :必须使用LuaInputManager.SpecialCommand = LuaConst.SpecialCommandType.Ride 才能保持同步一致 function SystemManager.RideHorse(entity ,dontShowEff , notSendHorseState) local horseModelData = entity._logicInitData.HorseModelData if horseModelData then local addSuccess = BuffSystem.OnRideHorse(entity) if addSuccess then -- 这个也可以做成和下马一样添加buff成功后的一个battleEffect ,但是没啥必要 MoveSystem.OnRideHorse(entity) ExpSystemManager.OnRideHorse(entity.ExpEntity ,horseModelData ,entity._logicInitData.HorseMoveData ,dontShowEff , notSendHorseState) BattleEventSystem.OnRideHorse(entity) end end end -- 直接让人下马,不同步,同步的话需要:luainputmanager.spcialcmd = luaconst.specmd.ride function SystemManager.OffHorse(entity) if entity.components.buff:CheckHasBuffState(LuaConst.SpecialBuffs.InRiding) then BuffSystem.DeleteBuff(entity,LuaConst.SpecialBuffs.InRiding,entity) BattleEventSystem.OnOffHorse(entity) end end --下马响应 ;必须使用LuaInputManager.SpecialCommand = LuaConst.SpecialCommandType.Ride 才能保持同步一致 function SystemManager.OnOffHorse(entity) --SystemManager.SetNextState(LuaConst.StateType.Idle, entity) MoveSystem.OnOffHorse(entity) StateSystem.OnOffHorse(entity) if entity.components.autoFight.IsAutoFindPath then local decisionRecordDic = entity.components.aiBase:GetDecisionRecordDic(entity.components.aiBase.CurDecisionData) if decisionRecordDic then decisionRecordDic.dontAutoRide = true end end ExpSystemManager.OnOffHorse(entity.ExpEntity) end --上载具 function SystemManager.Drive(entity, carEntity, interactIndex) if carEntity == nil then carEntity = entity.components.interact:GetCmdOpInteractEntity() end SystemManager.ForceDrive(entity,carEntity, interactIndex) end function SystemManager.ForceDrive(driver,beDrivedEntity, interactIndex, becomeOne) if beDrivedEntity.components.drive.BeDrived then -- 如果已被驾驶 ,则不能再被其他人驾驶 ExpSystemManager.OnDriveFailed(driver) return end --设定驾驶关系 DriveSystem.DriveEntity(driver ,beDrivedEntity) --设置司机的位置 if becomeOne == nil then -- 驾驶默认的是人车合一,如有特殊可传参数false becomeOne = true end MoveSystem.OnDrive(driver, beDrivedEntity, becomeOne) -- 设置攻击前是否先索敌 SkillBaseSystem.OnDrive(driver,beDrivedEntity) -- 停止自动战斗 SystemManager.StopAutoFight(driver) -- 添加标记buff SystemManager.AddBuff(driver, LuaConst.SpecialBuffs.InDriving, driver) SystemManager.SetNextState(LuaConst.StateType.Idle,driver) -- 不加这句话会引起 玩家跑动(有跑停)或者技能中点上车后,位置不对。 LevelManager.CurLevelFunc:OnDrive(driver, beDrivedEntity) -- 换UI ,换镜头等 ExpSystemManager.OnDriveEntity(driver.ExpEntity , beDrivedEntity, interactIndex) BattleEventSystem.AfterEntityDrived(beDrivedEntity, driver) end --下载具 ,entity 是driver function SystemManager.OffDrive(entity, force) if entity == nil then logging.error(LTAG.ERROR, "GWS : 让司机下载具 ,居然司机是nil -可能是玩家没在载具上,但是点了载具按钮 (只报错不阻挡)") return end if force or not entity:HasBuff(LuaConst.SpecialBuffs.CantOffDrive) then local carEntity = entity.components.drive.DriveEntity if carEntity == nil then logging.error(LTAG.ERROR, "GWS : 让司机下载具 ,居然载具是nil -可能是玩家没在载具上,但是点了载具按钮 (只报错不阻挡)") return end DriveSystem.OffDriveEntity(entity) -- 解除驾驶和被驾驶关系 --删除标记buff SystemManager.DeleteBuff(entity, LuaConst.SpecialBuffs.CantBeTrigger) SkillBaseSystem.OnOffDrive(entity,carEntity) MoveSystem.OnOffDrive(entity, carEntity) -- 下车后一定会让司机显示出来 ,所以没有做成battleEffect 拆分出来 if not entity:IsActive() then SystemManager.Active(entity, nil, LuaConst.EActiveType.OFF_DRIVE) else ExpSystemManager.OnSetVisible(entity.ExpEntity, true) end LevelManager.CurLevelFunc:OnOffDrive(entity, carEntity) ExpSystemManager.OnOffDriveEntity(entity.ExpEntity,carEntity) -- 完全下车后 ,司机动画切位idle SystemManager.SetNextState(LuaConst.StateType.Idle,entity) BattleEventSystem.AfterEntityOffDrived(carEntity, entity) end end function SystemManager.ShowBubbleDialogue(entity,dialogueID) ExpSystemManager.ShowBubbleDialogue(entity.ExpEntity, dialogueID) end function SystemManager.StartConfrontation(entity, againstEntity) AnimSystem.OnBreak(entity) SkillBaseSystem.OnBreak(entity) DecisionSystem.OnBreak(entity) entity.components.base:SetActive(false) againstEntity.components.base:SetActive(false) local callback = function(id,level,isReward) entity.components.base:SetActive(true) againstEntity.components.base:SetActive(true) if level >= LuaConst.QTE_CHECK_LEVEL then SystemManager.OnBreakAM(againstEntity) else SystemManager.AddBuff(entity,LuaConst.SpecialBuffs.InHitPush, entity, nil, nil) end end ExpSystemManager.StartConfrontation(entity.ExpEntity, againstEntity.ExpEntity, callback) end function SystemManager.StartGrab(entity, target, nodeEnum, x ,y, z, rotX, rotY, rotZ, buffId) entity.ExpEntity:AppendExpEntity(target.ExpEntity, nodeEnum, x, y, z, rotX, rotY, rotZ) entity.components.base:AfterGrabOther(target) entity.components.buff:AfterGrabOther(target, buffId) target.components.base:AfterBeGrabbed(entity) end function SystemManager.StopGrab(entity, target, buffId) entity.ExpEntity:CancelAppendExpEntity(target.ExpEntity) entity.components.base.AfterRealseGrabOther(target) entity.components.buff:AfterRealseGrabOther(target, buffId) target.components.base:AfterFreeFromGrab(entity) end function SystemManager.LookToEntity(entity,toEntity) ExpSystemManager.LookToEntity(entity.ExpEntity, toEntity) end function SystemManager.RotateToEntity(entity,toEntity) local comp_Move = entity.components.move local comp_MainMove = toEntity.components.move local wantRotateDir = comp_MainMove.LogicPos:cloneV2() wantRotateDir:Sub(comp_Move.LogicPos) wantRotateDir:Normalize() comp_Move:SetWantRotateDir(wantRotateDir) end function SystemManager.RotateToDir(entity,dir) local comp_Move = entity.components.move comp_Move:SetWantRotateDir(dir) end function SystemManager.SetEntityRotateDir(entity, dir) local moveComponent = entity.components.move moveComponent.LastLogicRotateDir:Reset(moveComponent.LogicRotateDir) dir = dir:cloneV2() dir:Normalize() moveComponent:SetLogicRotateDir(dir) end function SystemManager.SetSkillHighestPriorityTarget(playerID, target) local entityList = LevelPlayerManager.GetPlayerEntitysByPlayerIDInRoom(playerID) for i,entity in ipairs(entityList) do local targetComp = entity.components.target targetComp:SetSkillHighestPriorityTarget(target) end end function SystemManager.ChangeEntityName(entity, name) ExpSystemManager.ChangeEntityName(entity, name) end function SystemManager.ChangeEntityGuildEscort(entity, quality) ExpSystemManager.ChangeEntityGuildEscort(entity, quality) end --修改称号显示,titleId为0表示卸下 function SystemManager.ChangeEntityTitle(entity, titleId) ExpSystemManager.ChangeEntityTitle(entity, titleId) end --称号层级最高显示 function SystemManager.TopEntityTitle(entity) ExpSystemManager.TopEntityTitle(entity) end -- 换马 (通过马id) function SystemManager.ChangeHorse(entity ,horseID, horseAppearanceID) entity:SetHorseData(horseID, horseAppearanceID) ExpSystemManager.ChangeHorse(entity.ExpEntity, entity._logicInitData.HorseModelData.HorseModel, entity._logicInitData.HorseModelData.HorseShowEffect, entity._logicInitData.HorseModelData.Scale) end -- 换马(通过horseModelID) function SystemManager.ChangeHorse_ByModelID(entity ,horseModelID) entity:SetHorseModelData(horseModelID) ExpSystemManager.ChangeHorse(entity.ExpEntity, entity._logicInitData.HorseModelData.HorseModel, entity._logicInitData.HorseModelData.HorseShowEffect, entity._logicInitData.HorseModelData.Scale) end -- 武将换武器(神兵) 只换外观 (如果想换非武将的武器,新写个方法,别用这个) function SystemManager.OnChangeMagicWeaponID(entity) ExpSystemManager.OnChangedMagicWeapon(entity.ExpEntity) end --更换宠物 function SystemManager.ChangePet(entity, petId, petStage, petName, petSkill, isLineUp, aptitudeSum, runeSkillLevelSum) local oldPetID, oldPetStage = entity:GetPetIDAndStage() local justName = isLineUp == entity._logicInitData.PetIsLineUp and aptitudeSum ==entity._logicInitData.PetAptitudeSum and runeSkillLevelSum == entity._logicInitData.PetRuneSkillLevelSum entity:SetPetData(petId, petStage, petName, petSkill, isLineUp, aptitudeSum, runeSkillLevelSum) justName = justName and oldPetID == petId and oldPetStage == petStage ExpSystemManager.ChangePet(entity.ExpEntity, petId, petStage, petName, justName) end -- 宠物攻击: function SystemManager.PausePetAttack(entity, isPause) if entity.components.pet then entity.components.pet:SetPauseAttack(isPause) end end --修改entity头顶势力信息显示 function SystemManager.UpdateEntityHeadGuildShow(entity) ExpSystemManager.UpdateEntityHeadGuildShow(entity) end function SystemManager.ResetTransform(entity) ExpSystemManager.ResetTransform(entity.ExpEntity) end --只在召唤的时候使用,其他时候最好不要用 function SystemManager.SetCallEntityY(entity, logicY) entity.components.move.LogicPosY:Reset(logicY) if entity.ExpEntity then entity.ExpEntity:ApplyExpTransY() end end -- 组合骑兵的骑马属性现在先写死 ,策划有需求的话,那就再excel中加字段。(以下的加速度都是瞬时的) function SystemManager.ChangeRideHorseMonsterAttr(entity) entity:SetAttrBaseValue(LuaConst.AttrType.ridespd,12) entity:SetAttrBaseValue(LuaConst.AttrType.rideangvel,360) entity:SetAttrBaseValue(LuaConst.AttrType.ridespdacc,20) entity:SetAttrBaseValue(LuaConst.AttrType.ridespddec,20) entity:SetAttrBaseValue(LuaConst.AttrType.ridegear,1) entity:SetAttrBaseValue(LuaConst.AttrType.rideangacc,20) entity:SetAttrBaseValue(LuaConst.AttrType.rideheadacc,20) entity:SetAttrBaseValue(LuaConst.AttrType.rideheaddec,20) end function SystemManager.AddInteract(entity, interactID, pos) -- pos为nil则默认是entity位置 InteractSystem.AddInteract(entity, interactID, pos) end function SystemManager.DeleteInteract(entity, interactID) InteractSystem.DeleteInteract(entity, interactID) end function SystemManager.InteractStarted(entity, interactData, interactIndex) InteractSystem.InteractStarted(entity, interactData, interactIndex) ExpSystemManager.OnInteractStart(entity, interactIndex) end function SystemManager.DisableInteract(entity) InteractSystem.DisableInteract(entity) end function SystemManager.ResetInteractColliderState(entity) InteractSystem.ResetInteractColliderState(entity) end --entity 和其碰撞到interactentity 做交互行为 function SystemManager.InteractSucceed(entity, interactData, interactIndex) InteractSystem.InteractSucceed(entity, interactData) ExpSystemManager.OnInteractSucceed(entity, interactData) BattleEventSystem.OnEntityInteractSucceed(entity, interactData, interactIndex) EventSystem.Dispatch(entity.Event_EntityInteracted, entity, interactData) InteractSystem.InteractAfterSucceed(entity, interactData) end --entity 和其碰撞到interactentity 做中断交互过程 -- abortReason : 中断原因 function SystemManager.InteractAbort(entity , interactEntity, abortReason) SystemManager.SetNextState(LuaConst.StateType.Idle, entity) --这句话是真正的中断,切换state后,采集state会取消 InteractSystem.OnInteractAbort(entity, interactEntity, abortReason) end -- 显隐特殊光效 isShow :true 增加 ,false 删除 (目前策划只要求主城使用) function SystemManager.ShowOrHideLightEffect(entity, lightEffectID, isShow) ExpSystemManager.ShowOrHideLightEffect(entity.ExpEntity, lightEffectID, isShow) end function SystemManager.OnEnterCantBeTrigger(entity) BuffSystem.OnEntityEnterCantBeTriggerState(entity) end function SystemManager.GetInHaloBuffCount(checkEntity, haloBuffId, buffCaster) return BuffSystem.GetInHaloBuffCount(checkEntity, haloBuffId, buffCaster) end function SystemManager.GetInHaloBuffGroupCount(checkEntity, haloBuffGroupId, buffCaster) return BuffSystem.GetInHaloBuffGroupCount(checkEntity, haloBuffGroupId, buffCaster) end function SystemManager.StratagemEnterCD(entity) StratagemSkillSystem.StratagemEnterCD(entity) end function SystemManager.ClearStratagemCD(entity) StratagemSkillSystem.ClearStratagemCD(entity) end function SystemManager.AddBuffSkillById(entity, buffSkillId) BuffSkillSystem.AddBuffSkillById(entity, buffSkillId) end function SystemManager.ChangeBuffSkillCd(entity, buffSkillId, delta) BuffSkillSystem.ChangeBuffSkillCd(entity, buffSkillId, delta) end -- 添加战斗道具: UnlimitedUse 表示可用无限多次(但是计数还是算1个) function SystemManager.AddBattleProp(entity, battlePropID, unlimitedUse) BattlePropSystem.AddBattleProp(entity, battlePropID, unlimitedUse) end function SystemManager.DeleteBattlePropsByID(entity, battlePropID, count) -- count 删除几个,0表示全部 BattlePropSystem.DeleteBattlePropsByID(entity, battlePropID, count) end function SystemManager.UseBattleProp(entity, btnIndex) BattlePropSystem.TryStartUseBattleProp(entity, btnIndex) end -- 中断所有正在使用中的道具 function SystemManager.AbortUseBattleProp(entity) BattlePropSystem.AbortUseBattleProp(entity) end -- 是否可用战斗道具的某个按钮 function SystemManager.CanUseBattlePropBtnIndex(entity, btnIndex) local canUse = BattlePropSystem.CanUseBattlePropBntIndex(entity, btnIndex) return canUse end -- 是否可以使用战斗道具ID function SystemManager.CanUseBattlePropID(entity, battlePropID) return BattlePropSystem.CanUseBattlePropID(entity, battlePropID) end function SystemManager.EntityCopy(entity, targetEntity) BuffSystem.EntityCopy(entity, targetEntity) AttrSystem.EntityCopyPCInfo(entity, targetEntity) end return SystemManager