--移动组件 local ExpAnimSystem = {} local private = {} local LuaConst=LuaConst local FP=FP function ExpAnimSystem.OnExpUpdate(expEntity) end function ExpAnimSystem.TryUpdateHorseAnim(entity, rideSpeedRate, horseExpAngle, wantRotateDir) -- 骑马攻击时,摇杆变化要改变马的动画 local speed = FP.tonumberV1(rideSpeedRate) local angSpeed = FP.tonumberV1(horseExpAngle) local horseNotSyncAnim = entity:CheckHasBuffState(LuaConst.SpecialBuffs.HorseUpdateSelfAnim) -- 马受到摇杆的控制 (人和马动作分离) if horseNotSyncAnim then entity.ExpEntity:PlayHorseRunAnimation(speed, angSpeed) end end function ExpAnimSystem.PlayAnimationDirectly(expEntity, animID) expEntity:PlayAnimationDirectly(animID) end function ExpAnimSystem.OnAttackEnter(expEntity) private.ChangeAnimation(expEntity) end --causer :谁造成的状态切换,可以为空,是一个Entity function ExpAnimSystem.OnNextStateIn(stateType, expEntity, causer, hitFlyRate) if stateType == LuaConst.StateType.None then return end private.ChangeAnimation(expEntity, causer, hitFlyRate) end function ExpAnimSystem.OnFastPlayOver(expEntity) private.ChangeAnimation(expEntity,nil, 0) end function ExpAnimSystem.OnSetAnimIDOverride(expEntity, originID, overrideToID) local logicAnim = expEntity.Entity.components.anim.CurAnimID if overrideToID then if expEntity.components.anim ~= logicAnim and logicAnim == overrideToID then private.ChangeAnimation(expEntity) end else if expEntity.components.anim ~= logicAnim and logicAnim == originID then private.ChangeAnimation(expEntity) end end end function ExpAnimSystem.OnHPChange(expEntity,op ,hpChangeType ,isAboutMe) if not isAboutMe then return end if hpChangeType == LuaConst.EHpChangeType.DOT or hpChangeType == LuaConst.EHpChangeType.DAMAGE_RETURN then return end if op == "sub" then --and (expEntity.Entity:CheckType(LuaConst.CharacterType.Hero) or expEntity.Entity.components.buff.CurrentBuffStates:Get(LuaConst.SpecialBuffs.InSuperArmor) ) then expEntity:InsertHurtAnim() end end --causer :谁造成的动画改变切换,可以为空,是一个Entity function private.ChangeAnimation(expEntity, causer ,hitFlyRate) if expEntity.animInvalid then return end local expAnimComp = expEntity.components.anim expAnimComp.CurExpAnimID = expEntity.Entity.components.anim.CurAnimID if expAnimComp.CurExpAnimID then if string.find(expAnimComp.CurExpAnimID ,"fly") then expEntity:PlayAnimation(expAnimComp.CurExpAnimID , hitFlyRate) else expEntity:PlayAnimation(expAnimComp.CurExpAnimID , 0) end private.ChangeSound(expEntity, causer) end end --causer :谁造成的状态切换,可以为空,是一个Entity function private.ChangeSound(expEntity, causer) local playAnimName = expEntity.Entity.components.anim.AnimConditionDic[expEntity.components.anim.CurExpAnimID] if expEntity.Entity.components.buff and expEntity.Entity.components.buff:CheckHasBuffState(LuaConst.SpecialBuffs.InRiding) then if expEntity.components.anim.CurExpAnimID == LuaConst.Animation_horseRun then -- TODO: 目前只有一个马,逻辑临时写死,后期策划一定会对马提出修改,那个时候再做正式逻辑 playAnimName = expEntity.Entity._logicInitData.HorseModelData.HorseRunAudio elseif expEntity.components.anim.CurExpAnimID == LuaConst.Animation_horseStop then playAnimName = "Hero_BaiLong_ride_stop" elseif expEntity.components.anim.CurExpAnimID == LuaConst.Animation_horseShowPos then playAnimName = expEntity.Entity._logicInitData.HorseModelData.HorseIdleShowAudio end end ExpSystemManager.PlayAinmSound(expEntity,playAnimName, causer) end function ExpAnimSystem.ChangeMoveAnimationSpeed(expEntity, speed) if expEntity.Entity.components.aiBase.CurStateType == LuaConst.StateType.Move then expEntity:RefreshTimeScale(true, LuaConst.ETimeScaleChannel.SKILL_ANIM_SOUND_ENTITY_POS_ROT, speed) end end return ExpAnimSystem