ActorDieCommand.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. local ActorDieCommand = class('ActorDieCommand', framework.SimpleCommand)
  2. local optionsUtils = requireProxy("optionsUtils")
  3. function ActorDieCommand:ctor()
  4. end
  5. function ActorDieCommand:execute(notification)
  6. local data = notification:getBody()
  7. local actor = data.actor
  8. if not actor then
  9. return false
  10. end
  11. local inputProxy = global.Facade:retrieveProxy(global.ProxyTable.PlayerInputProxy)
  12. local autoProxy = global.Facade:retrieveProxy(global.ProxyTable.Auto)
  13. local actorID = actor:GetID()
  14. if inputProxy:GetTargetID() == actorID then
  15. inputProxy:ClearTarget()
  16. -- 挂机时目标死亡,标记一定时间
  17. if autoProxy:IsAFKState() or autoProxy:IsAutoFightState() then
  18. autoProxy:SetAFKTargetDeath(true)
  19. end
  20. end
  21. if inputProxy:GetAttackTargetID() == actorID then
  22. inputProxy:ClearAttackTargetID()
  23. end
  24. if inputProxy:GetMouseOverTargetID() == actorID then
  25. inputProxy:GetMouseOverTargetID(nil)
  26. end
  27. actor:SetKeyValue(global.MMO.HUD_PC_MOUSE_SHOW, false)
  28. local mainPlayer = global.gamePlayerController:GetMainPlayer()
  29. if mainPlayer and mainPlayer:GetHateID() == actorID then
  30. mainPlayer:SetHateID(nil)
  31. end
  32. global.actorInViewController:DelActor(actor)
  33. global.HUDHPManager:DelActor(actor, true)
  34. global.Facade:sendNotification(global.NoticeTable.RefreshActorSceneOptions, actor)
  35. if actor:IsMonster() or actor:IsHumanoid() then
  36. global.Facade:sendNotification(global.NoticeTable.RefreshBuffVisible, actor)
  37. end
  38. end
  39. return ActorDieCommand