BuffEntityIce.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. local BuffEntityAnim = require("buff/BuffEntityAnim")
  2. local BuffEntityIce = class("BuffEntityIce", BuffEntityAnim)
  3. function BuffEntityIce:ctor(data)
  4. BuffEntityIce.super.ctor(self, data)
  5. end
  6. function BuffEntityIce:OnEnter()
  7. BuffEntityIce.super.OnEnter(self)
  8. local actor = global.actorManager:GetActor(self._actorID)
  9. if not actor then
  10. self:disable()
  11. return false
  12. end
  13. if not (actor:IsPlayer() or actor:IsMonster()) then
  14. self:disable()
  15. return false
  16. end
  17. self:IceActor()
  18. end
  19. function BuffEntityIce:OnExit()
  20. BuffEntityIce.super.OnExit(self)
  21. local actor = global.actorManager:GetActor(self._actorID)
  22. if not actor then
  23. return nil
  24. end
  25. self:UnIceActor()
  26. end
  27. function BuffEntityIce:IceActor()
  28. local actor = global.actorManager:GetActor(self._actorID)
  29. if not actor then
  30. return nil
  31. end
  32. local function shaderNode(node)
  33. self:ShaderIce(node)
  34. end
  35. if actor:IsPlayer() then
  36. local anim = actor:GetAnimation()
  37. if anim then
  38. shaderNode(anim)
  39. end
  40. anim = actor:GetAnimationWeapon()
  41. if anim then
  42. shaderNode(anim)
  43. end
  44. anim = actor:GetAnimationShield()
  45. if anim then
  46. shaderNode(anim)
  47. end
  48. anim = actor:GetAnimationMount()
  49. if anim then
  50. shaderNode(anim)
  51. end
  52. anim = actor:GetAnimationHair()
  53. if anim then
  54. shaderNode(anim)
  55. end
  56. anim = actor:GetAnimationMonster()
  57. if anim then
  58. shaderNode(anim)
  59. end
  60. elseif actor:IsMonster() then
  61. local anim = actor:GetAnimation()
  62. if anim then
  63. shaderNode(anim)
  64. end
  65. elseif actor:IsNPC() then
  66. local anim = actor:GetAnimation()
  67. if anim then
  68. shaderNode(anim)
  69. end
  70. end
  71. end
  72. function BuffEntityIce:UnIceActor()
  73. local actor = global.actorManager:GetActor(self._actorID)
  74. if not actor then
  75. return nil
  76. end
  77. local function shaderNode(node)
  78. self:ShaderNormal(node)
  79. end
  80. if actor:IsPlayer() then
  81. local anim = actor:GetAnimation()
  82. if anim then
  83. shaderNode(anim)
  84. end
  85. anim = actor:GetAnimationWeapon()
  86. if anim then
  87. shaderNode(anim)
  88. end
  89. anim = actor:GetAnimationShield()
  90. if anim then
  91. shaderNode(anim)
  92. end
  93. anim = actor:GetAnimationMount()
  94. if anim then
  95. shaderNode(anim)
  96. end
  97. anim = actor:GetAnimationHair()
  98. if anim then
  99. shaderNode(anim)
  100. end
  101. anim = actor:GetAnimationMonster()
  102. if anim then
  103. shaderNode(anim)
  104. end
  105. elseif actor:IsMonster() then
  106. local anim = actor:GetAnimation()
  107. if anim then
  108. shaderNode(anim)
  109. end
  110. elseif actor:IsNPC() then
  111. local anim = actor:GetAnimation()
  112. if anim then
  113. shaderNode(anim)
  114. end
  115. end
  116. end
  117. function BuffEntityIce:ShaderIce(node)
  118. if not node then
  119. return
  120. end
  121. local iceShader = global.MMO.SHADER_TYPE_ICE
  122. if node.GetBlendMode then
  123. local blendType = node:GetBlendMode()
  124. if 4 == blendType then
  125. iceShader = global.MMO.SHADER_TYPE_ICE_ALPHA_MULTIP
  126. end
  127. end
  128. global.Facade:sendNotification(global.NoticeTable.HighLightNodeShader, node, iceShader)
  129. end
  130. function BuffEntityIce:ShaderNormal(node)
  131. if not node then
  132. return
  133. end
  134. local p = global.GLProgramCache:getGLProgram("ShaderPositionTextureColor_noMVP")
  135. node:setGLProgram(p)
  136. end
  137. function BuffEntityIce:UpdatePresent()
  138. local actor = global.actorManager:GetActor(self._actorID)
  139. if not actor then
  140. return false
  141. end
  142. if not (actor:IsPlayer() or actor:IsMonster()) then
  143. return false
  144. end
  145. self:IceActor()
  146. end
  147. return BuffEntityIce