Jump to content

启蒙动画在月岛变猴的时候会额外播放一遍。


AlPt
  • Pending

原因:

玩家变猴子的时候是创建了一个新的玩家实体,并将旧的组件转移过去

但是 sanity.lua:L481 的 Sanity:TransferComponent() 函数仅将自己的百分比复制过去,没有复制其月岛状态(也就是 ThePlayer.components.sanity.mode 的值为默认的 SANITY_MODE_INSANITY 而不是 SANITY_MODE_LUNACY)

然后在下一 tick 又检测到玩家以sanity正常模式进月岛,因此播放了sanity转换动画。

 

怎么修理这个 bug?

将 sanity.lua:L481 的 Sanity:TransferComponent() 函数中,将 mode 和 _lunacy_sources 复制给新组件。


Steps to Reproduce

复现方法:

1. 把一只猴子传送到月岛

2. 确保背包里有九个项链儿

3. 杀死月岛这只猴子,使自己变成猴子

4. 观察到右上角san槽额外播放了一遍启蒙值动画




User Feedback


diff --git a/scripts/components/sanity.lua b/scripts/components/sanity.lua
index 97c6b15..c252149 100644
--- a/scripts/components/sanity.lua
+++ b/scripts/components/sanity.lua
@@ -481,6 +481,8 @@ end
 function Sanity:TransferComponent(newinst)
     local newcomponent = newinst.components.sanity
     newcomponent:SetPercent(self:GetPercent())
+    newcomponent.mode = self.mode or newcomponent.mode
+    newcomponent._lunacy_sources = self._lunacy_sources or newcomponent._lunacy_sources
 end
 
 Sanity.LongUpdate = Sanity.OnUpdate

 

Share this comment


Link to comment
Share on other sites



Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
  • Create New...