ActorOutOfViewCommand.lua 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. local ActorOutOfViewCommand = class('ActorOutOfViewCommand', framework.SimpleCommand)
  2. local proxyUtils = requireProxy("proxyUtils")
  3. requireProxy("actorUtils")
  4. function ActorOutOfViewCommand:ctor()
  5. end
  6. function ActorOutOfViewCommand:execute(notification)
  7. local data = notification:getBody()
  8. local actorID = data.actorID
  9. local msgID = data.msgID
  10. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  11. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  12. if inputProxy:GetTargetID() == actorID then
  13. inputProxy:ClearTarget()
  14. inputProxy:SetAttackState(false)
  15. end
  16. if inputProxy:GetAttackTargetID() == actorID then
  17. inputProxy:ClearAttackTargetID()
  18. end
  19. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  20. if mainPlayer and mainPlayer:GetHateID() == actorID then
  21. mainPlayer:SetHateID(nil)
  22. end
  23. local actor = global.actorManager:GetActor(actorID)
  24. if not actor then
  25. return nil
  26. end
  27. -- player
  28. if actor:IsPlayer() then
  29. local TradeProxy = global.Facade:retrieveProxy(global.ProxyTable.TradeProxy)
  30. TradeProxy:CheckPlayerOut(actor:GetID())
  31. local StallProxy = global.Facade:retrieveProxy(global.ProxyTable.StallProxy)
  32. StallProxy:OnStallStateDataChange({userid = actor:GetID(), status = 0})
  33. -- out of view sfx
  34. if msgID then
  35. if msgID == global.MsgType.MSG_SC_NET_PLAYER_FLY_OUT then
  36. local effectType = data.recog or 0
  37. local noShow = effectType == 1
  38. -- audio
  39. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_FLY_OUT})
  40. -- effect
  41. if not noShow then
  42. local effectId = effectType > 1 and effectType
  43. global.Facade:sendNotification(global.NoticeTable.ActorFlyOut, actor, effectId or 0)
  44. end
  45. elseif msgID == global.MsgType.MSG_SC_NET_PLAYER_FLY_OUT_2 then
  46. local effectType = data.recog or 0
  47. local noShow = effectType == 1
  48. -- audio
  49. global.Facade:sendNotification(global.NoticeTable.Audio_Play, {type = global.MMO.SND_TYPE_FLY_OUT})
  50. -- effect
  51. if not noShow then
  52. local effectId = effectType > 1 and effectType
  53. global.Facade:sendNotification(global.NoticeTable.ActorFlyOut, actor, effectId or 1)
  54. end
  55. end
  56. end
  57. actor:SetKeyValue(global.MMO.HUD_BAR_SHOW_FULL_HP, false)
  58. elseif actor:IsMonster() then
  59. actor:SetKeyValue(global.MMO.HUD_BAR_SHOW_FULL_HP, false)
  60. elseif actor:IsNPC() then
  61. -- NPC
  62. global.Facade:sendNotification( global.NoticeTable.NpcOutOfView, actor:GetTypeIndex() )
  63. elseif global.MMO.ACTOR_RACE_COLLECTION == actor:GetRace() then
  64. -- collection
  65. inputProxy:SubCollectCount()
  66. local collectCount = inputProxy:GetCollectCount()
  67. if collectCount <= 0 then
  68. global.Facade:sendNotification(global.NoticeTable.CollectVisible, false)
  69. end
  70. end
  71. global.actorInViewController:DelActor(actor)
  72. global.HUDHPManager:DelActor(actor)
  73. -- cleanup actor attr
  74. ClenupActorAttr(actor)
  75. end
  76. return ActorOutOfViewCommand