RefreshActorSafeZoneCommand.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. local RefreshActorSafeZoneCommand = class('RefreshActorSafeZoneCommand', framework.SimpleCommand)
  2. function RefreshActorSafeZoneCommand:ctor()
  3. end
  4. function RefreshActorSafeZoneCommand:execute(notification)
  5. local actorID = notification:getBody()
  6. if not actorID then
  7. return nil
  8. end
  9. local actor = global.actorManager:GetActor(actorID)
  10. if not actor then
  11. return nil
  12. end
  13. local MapProxy = global.Facade:retrieveProxy( global.ProxyTable.Map )
  14. -- 计算状态
  15. local lastSafeZone = actor:GetInSafeZone()
  16. local inSafeZone = MapProxy:GetInSafeArea(actor:GetMapX(), actor:GetMapY() )
  17. actor:SetInSafeZone(inSafeZone)
  18. -- 与上次不同,通知刷新
  19. if inSafeZone ~= lastSafeZone then
  20. global.Facade:sendNotification(global.NoticeTable.ActorSafeZoneChange, {actorID = actorID, actor = actor})
  21. if actorID == global.gamePlayerController:GetMainPlayerID() then
  22. SLBridge:onLUAEvent(LUA_EVENT_PLAYER_IN_SAFEZONE_CHANGE)
  23. else
  24. SLBridge:onLUAEvent(LUA_EVENT_NET_PLAYER_IN_SAFEZONE_CHANGE, {id = actorID})
  25. end
  26. local GuildProxy = global.Facade:retrieveProxy(global.ProxyTable.GuildProxy)
  27. if GuildProxy:IsGuildWar() then
  28. global.Facade:sendNotification(global.NoticeTable.RefreshGuildActorColor)
  29. end
  30. end
  31. end
  32. return RefreshActorSafeZoneCommand