SetPlayerFeatureCommand.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. local SetPlayerFeatureCommand = class('SetPlayerFeatureCommand', framework.SimpleCommand)
  2. local optionsUtils = requireProxy( "optionsUtils" )
  3. function SetPlayerFeatureCommand:ctor()
  4. end
  5. function SetPlayerFeatureCommand:execute(notification)
  6. local data = notification:getBody()
  7. if not data then
  8. return false
  9. end
  10. local actor = data.actor
  11. if not actor then
  12. return false
  13. end
  14. local sex = actor:GetSexID()
  15. local job = actor:GetJobID()
  16. local actorID = actor:GetID()
  17. -- set and check actual feature
  18. local clothID = data.clothID
  19. local weaponID = data.weaponID
  20. local shieldID = data.shieldID
  21. local wingsID = data.wingsID
  22. local hairID = data.hairID
  23. local capID = data.capID
  24. local weaponEffID = data.weaponEff
  25. local mountID = data.mountID
  26. local mountEff = data.mountEff
  27. local mountCloth = data.mountCloth
  28. local shieldEffID = data.shieldEffect
  29. local leftWeaponID = data.leftWeaponID
  30. local leftWeaponEffID = data.leftWeaponEff
  31. local sceneOptionsProxy = global.Facade:retrieveProxy( global.ProxyTable.SceneOptionsProxy )
  32. local tempFeature = sceneOptionsProxy:GetTempFeatureByJob( job )
  33. if clothID then
  34. actor:SetClothID( clothID )
  35. end
  36. if tempFeature and tempFeature.clothID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_PLAYER, actor:GetClothID(), sex, actor ) then
  37. -- temp
  38. actor:SetShowClothID(tempFeature.clothID)
  39. else
  40. actor:SetShowClothID(0)
  41. end
  42. if weaponID then
  43. actor:SetWeaponID( weaponID )
  44. end
  45. if tempFeature and tempFeature.weaponID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_WEAPON, actor:GetWeaponID(), sex, actor ) then
  46. -- temp
  47. actor:SetShowWeaponID(tempFeature.weaponID)
  48. else
  49. actor:SetShowWeaponID(0)
  50. end
  51. if leftWeaponID then
  52. actor:SetLeftWeaponID( leftWeaponID )
  53. end
  54. if tempFeature and tempFeature.leftWeaponID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_WEAPON, actor:GetLeftWeaponID(), sex, actor ) then
  55. -- temp
  56. actor:SetShowLeftWeaponID(tempFeature.leftWeaponID)
  57. else
  58. actor:SetShowLeftWeaponID(0)
  59. end
  60. if shieldID then
  61. actor:SetShieldID( shieldID )
  62. end
  63. if tempFeature and tempFeature.shieldID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_SHIELD, actor:GetShieldID(), sex, actor ) then
  64. -- temp
  65. actor:SetShowShieldID( tempFeature.shieldID )
  66. else
  67. actor:SetShowShieldID( 0 )
  68. end
  69. if wingsID then
  70. actor:SetWingsID( wingsID )
  71. end
  72. if tempFeature and tempFeature.wingsID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_WINGS, actor:GetWingsID(), sex, actor ) then
  73. -- temp
  74. actor:SetShowWingsID( tempFeature.wingsID )
  75. else
  76. actor:SetShowWingsID( 0 )
  77. end
  78. if capID or hairID then
  79. actor:SetHairID( capID or hairID )
  80. end
  81. if tempFeature and tempFeature.hairID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_HAIR, actor:GetHairID(), sex, actor ) then
  82. -- temp
  83. actor:SetShowHairID( tempFeature.hairID )
  84. else
  85. actor:SetShowHairID( 0 )
  86. end
  87. actor:SetRealHairID( hairID or 0 )
  88. if weaponEffID then
  89. actor:SetWeaponEffectID( weaponEffID )
  90. end
  91. if tempFeature and tempFeature.weaponEffID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_WEAPON, actor:GetWeaponEffectID(), sex, actor ) then
  92. -- temp
  93. actor:SetShowWeaponEffectID( tempFeature.weaponEffID )
  94. else
  95. actor:SetShowWeaponEffectID( 0 )
  96. end
  97. if leftWeaponEffID then
  98. actor:SetLeftWeaponEffectID( leftWeaponEffID )
  99. end
  100. if tempFeature and tempFeature.leftWeaponEffID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_WEAPON, actor:GetLeftWeaponEffectID(), sex, actor ) then
  101. -- temp
  102. actor:SetShowLeftWeaponEffectID( tempFeature.leftWeaponEffID )
  103. else
  104. actor:SetShowLeftWeaponEffectID( 0 )
  105. end
  106. if shieldEffID then
  107. actor:SetShieldEffectID( shieldEffID )
  108. end
  109. if tempFeature and tempFeature.shieldEffID and not optionsUtils:checkFeatureEnable( global.MMO.SFANIM_TYPE_SHIELD, actor:GetShieldEffectID(), sex, actor ) then
  110. -- temp
  111. actor:SetShowShieldEffectID( tempFeature.shieldEffID )
  112. else
  113. actor:SetShowShieldEffectID( 0 )
  114. end
  115. -- 检测buff是否存在变形
  116. mountID = mountID or 0
  117. local cfgAvatar = global.BuffManager:CheckBuffAvatar(actorID)
  118. if global.BuffManager:CheckRmvBuffAvatar(actorID,cfgAvatar) then
  119. actor:SetMonsterFeatureID(0)
  120. actor:updateMonster(0)
  121. end
  122. if mountID == 0 and cfgAvatar then
  123. mountID = cfgAvatar.avatarID
  124. end
  125. if actor:IsPlayer() then
  126. actor:SetMonsterFeatureID( mountID or 0 ) --骑马
  127. actor:SetMonsterEffectID( mountEff or 0 )
  128. actor:SetMonsterClothID ( mountCloth or 0 )
  129. end
  130. global.Facade:sendNotification(global.NoticeTable.DelayDirtyFeature, {actorID = actorID, actor = actor})
  131. end
  132. return SetPlayerFeatureCommand