@@ -11,25 +11,9 @@ namespace CommunityBugFixCollection
1111 [ HarmonyPatch ( typeof ( Animator ) , nameof ( Animator . OnCommonUpdate ) ) ]
1212 internal sealed class PauseAnimatorUpdates : ResoniteBugFixMonkey < PauseAnimatorUpdates >
1313 {
14- public override IEnumerable < string > Authors => Contributors . Banane9 ;
14+ private static readonly ConditionalWeakTable < Animator , Box < float > > _lastPositionByAnimator = new ( ) ;
1515
16- private class Float
17- {
18- public float Value ;
19-
20- public Float ( float value )
21- {
22- Value = value ;
23- }
24-
25- public Float ( )
26- {
27- Value = 0f ;
28- }
29- }
30-
31-
32- private static readonly ConditionalWeakTable < Animator , Float > _hasChangedPlayhead = new ( ) ;
16+ public override IEnumerable < string > Authors { get ; } = [ .. Contributors . Banane9 , .. Contributors . Onan ] ;
3317
3418 private static bool Prefix ( Animator __instance )
3519 {
@@ -41,11 +25,17 @@ private static bool Prefix(Animator __instance)
4125 if ( ! __instance . _fieldMappersValid )
4226 __instance . GenerateFieldMappers ( ) ;
4327
28+ if ( ! _lastPositionByAnimator . TryGetValue ( __instance , out var lastPosition ) )
29+ {
30+ // Make sure that initial state is always applied,
31+ // since playback position can't be < 0
32+ lastPosition = - 1 ;
33+ _lastPositionByAnimator . Add ( __instance , lastPosition ) ;
34+ }
4435
45- if ( _hasChangedPlayhead . GetOrCreateValue ( __instance ) . Value != __instance . _playback . Position )
36+ if ( lastPosition != __instance . Position )
4637 {
47- var position = __instance . Position ;
48- _hasChangedPlayhead . GetOrCreateValue ( __instance ) . Value = __instance . Position ;
38+ var position = lastPosition . Value = __instance . Position ;
4939
5040 foreach ( var fieldMapper in __instance . _fieldMappers )
5141 fieldMapper . Set ( position ) ;
@@ -54,6 +44,4 @@ private static bool Prefix(Animator __instance)
5444 return false ;
5545 }
5646 }
57-
58-
5947}
0 commit comments