SetPlayerFeatureEXCommand.lua 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. local SetPlayerFeatureEXCommand = class('SetPlayerFeatureEXCommand', framework.SimpleCommand)
  2. local optionsUtils = requireProxy("optionsUtils")
  3. function SetPlayerFeatureEXCommand:ctor()
  4. end
  5. function SetPlayerFeatureEXCommand: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 showClothID = data.showClothID
  15. local showWeaponID = data.showWeaponID
  16. local showShieldID = data.showShieldID
  17. local showWingsID = data.showWingsID
  18. local showHairID = data.showHairID
  19. local showWeaponEffID = data.showWeaponEffID
  20. local showShieldEffID = data.showShieldEffID
  21. local showLeftWeaponID = data.showLeftWeaponID
  22. local showLeftWeaponEffID = data.showLeftWeaponEffID
  23. local checkDirty = false
  24. local actorID = actor:GetID()
  25. local sex = actor:GetSexID()
  26. if actor.SetShowClothID and showClothID then
  27. checkDirty = self:SetCloth(showClothID, sex, actor) or checkDirty
  28. end
  29. if actor.SetShowWeaponID and showWeaponID then
  30. checkDirty = self:SetWeapon(showWeaponID, sex, actor) or checkDirty
  31. end
  32. if actor.SetShowShieldID and showShieldID then
  33. checkDirty = self:SetShield(showShieldID, sex, actor) or checkDirty
  34. end
  35. if actor.SetShowWingsID and showWingsID then
  36. checkDirty = self:SetWings(showWingsID, sex, actor) or checkDirty
  37. end
  38. if actor.SetShowHairID and showHairID then
  39. checkDirty = self:SetHair(showHairID, sex, actor) or checkDirty
  40. end
  41. if actor.SetShowWeaponEffectID and showWeaponEffID then
  42. checkDirty = self:SetWeaponEff(showWeaponEffID, sex, actor) or checkDirty
  43. end
  44. if actor.SetShowShieldEffectID and showShieldEffID then
  45. checkDirty = self:SetShieldEff(showShieldEffID, sex, actor) or checkDirty
  46. end
  47. if actor.SetShowLeftWeaponID and showLeftWeaponID then
  48. checkDirty = self:SetLeftWeapon(showLeftWeaponID, sex, actor) or checkDirty
  49. end
  50. if actor.SetShowLeftWeaponEffectID and showLeftWeaponEffID then
  51. checkDirty = self:SetLeftWeaponEff(showLeftWeaponEffID, sex, actor) or checkDirty
  52. end
  53. if checkDirty then
  54. global.Facade:sendNotification(global.NoticeTable.DelayDirtyFeature, {actorID = actorID, actor = actor})
  55. end
  56. end
  57. function SetPlayerFeatureEXCommand:SetCloth(showID, sex, actor)
  58. if showID < 1 then -- cleanup show
  59. local clothID = actor:GetClothID()
  60. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_PLAYER, clothID, sex, actor) then
  61. actor:SetShowClothID(0)
  62. return true
  63. end
  64. else -- show
  65. actor:SetShowClothID(showID)
  66. return true
  67. end
  68. return false
  69. end
  70. function SetPlayerFeatureEXCommand:SetWeapon(showID, sex, actor)
  71. if showID < 1 then -- cleanup show
  72. local weaponID = actor:GetWeaponID()
  73. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_WEAPON, weaponID, sex, actor) then
  74. actor:SetShowWeaponID(0)
  75. return true
  76. end
  77. else -- show
  78. actor:SetShowWeaponID(showID)
  79. return true
  80. end
  81. return false
  82. end
  83. function SetPlayerFeatureEXCommand:SetLeftWeapon(showID, sex, actor)
  84. if showID < 1 then -- cleanup show
  85. local LeftWeaponID = actor:GetLeftWeaponID()
  86. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_WEAPON, LeftWeaponID, sex, actor) then
  87. actor:SetShowLeftWeaponID(0)
  88. return true
  89. end
  90. else -- show
  91. actor:SetShowLeftWeaponID(showID)
  92. return true
  93. end
  94. return false
  95. end
  96. function SetPlayerFeatureEXCommand:SetShield(showID, sex, actor)
  97. if showID < 1 then -- cleanup show
  98. local shieldID = actor:GetShieldID()
  99. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_SHIELD, shieldID, sex, actor) then
  100. actor:SetShowShieldID(0)
  101. return true
  102. end
  103. else -- show
  104. actor:SetShowShieldID(showID)
  105. return true
  106. end
  107. return false
  108. end
  109. function SetPlayerFeatureEXCommand:SetWings(showID, sex, actor)
  110. if showID < 1 then -- cleanup show
  111. local wingsID = actor:GetWingsID()
  112. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_WINGS, wingsID, sex, actor) then
  113. actor:SetShowWingsID(0)
  114. return true
  115. end
  116. else -- show
  117. actor:SetShowWingsID(showID)
  118. return true
  119. end
  120. return false
  121. end
  122. function SetPlayerFeatureEXCommand:SetHair(showID, sex, actor)
  123. if showID < 1 then -- cleanup show
  124. local hairID = actor:GetHairID()
  125. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_HAIR, hairID, sex, actor) then
  126. actor:SetShowHairID(0)
  127. return true
  128. end
  129. else -- show
  130. actor:SetShowHairID(showID)
  131. return true
  132. end
  133. return false
  134. end
  135. function SetPlayerFeatureEXCommand:SetWeaponEff(showID, sex, actor)
  136. if showID < 1 then -- cleanup show
  137. local weaponEff = actor:GetWeaponEffectID()
  138. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_WEAPON, weaponEff, sex, actor) then
  139. actor:SetShowWeaponEffectID(0)
  140. return true
  141. end
  142. else -- show
  143. actor:SetShowWeaponEffectID(showID)
  144. return true
  145. end
  146. return false
  147. end
  148. function SetPlayerFeatureEXCommand:SetLeftWeaponEff(showID, sex, actor)
  149. if showID < 1 then -- cleanup show
  150. local leftWeaponEff = actor:GetLeftWeaponEffectID()
  151. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_WEAPON, leftWeaponEff, sex, actor) then
  152. actor:SetShowLeftWeaponEffectID(0)
  153. return true
  154. end
  155. else -- show
  156. actor:SetShowLeftWeaponEffectID(showID)
  157. return true
  158. end
  159. return false
  160. end
  161. function SetPlayerFeatureEXCommand:SetShieldEff(showID, sex, actor)
  162. if showID < 1 then -- cleanup show
  163. local shieldEff = actor:GetShieldEffectID()
  164. if optionsUtils:checkFeatureEnable(global.MMO.SFANIM_TYPE_SHIELD, shieldEff, sex, actor) then
  165. actor:SetShowShieldEffectID(0)
  166. return true
  167. end
  168. else -- show
  169. actor:SetShowShieldEffectID(showID)
  170. return true
  171. end
  172. return false
  173. end
  174. return SetPlayerFeatureEXCommand