@@ -52,41 +52,55 @@ private static Vector2 GetDefaultTargetPosition(ModCardPileDefinition definition
5252 var fallback = FallbackPosition ( ) ;
5353
5454 if ( definition . Anchor . Kind == ModCardPileAnchorKind . Custom )
55- return definition . Anchor . CustomPosition + definition . Anchor . Offset ;
55+ return ApplyCardNodeOffset ( definition . Anchor . CustomPosition + definition . Anchor . Offset , node ) ;
5656
5757 var button = ModCardPileButtonRegistry . TryGetButton ( definition ) ;
5858 if ( button != null && button . IsInsideTree ( ) )
59- return button . GlobalPosition + button . Size * 0.5f + definition . Anchor . Offset ;
59+ return ApplyCardNodeOffset ( button . GlobalPosition + button . Size * 0.5f + definition . Anchor . Offset , node ) ;
6060
6161 var extraHand = ModCardPileButtonRegistry . TryGetExtraHand ( definition ) ;
6262 if ( extraHand != null && extraHand . IsInsideTree ( ) )
63- return extraHand . GlobalPosition + extraHand . Size * 0.5f + definition . Anchor . Offset ;
63+ return ApplyCardNodeOffset ( extraHand . GlobalPosition + extraHand . Size * 0.5f + definition . Anchor . Offset ,
64+ node ) ;
6465
6566 if ( definition . Style == ModCardPileUiStyle . TopBarDeck )
6667 {
6768 var deck = NRun . Instance ? . GlobalUi ? . TopBar ? . Deck ;
6869 if ( deck != null )
69- return deck . GlobalPosition + deck . Size * 0.5f + new Vector2 ( - 120f , 0f ) + definition . Anchor . Offset ;
70+ return ApplyCardNodeOffset (
71+ deck . GlobalPosition + deck . Size * 0.5f + new Vector2 ( - 120f , 0f ) + definition . Anchor . Offset ,
72+ node ) ;
7073 }
7174
7275 if ( ! CombatManager . Instance . IsInProgress || NCombatRoom . Instance ? . Ui == null )
73- return fallback + definition . Anchor . Offset ;
76+ return ApplyCardNodeOffset ( fallback + definition . Anchor . Offset , node ) ;
7477
7578 var ui = NCombatRoom . Instance . Ui ;
7679 return definition . Style switch
7780 {
7881 ModCardPileUiStyle . BottomLeft =>
79- ui . DrawPile . GlobalPosition + ui . DrawPile . Size * 0.5f + new Vector2 ( 0f , - 140f ) +
80- definition . Anchor . Offset ,
82+ ApplyCardNodeOffset (
83+ ui . DrawPile . GlobalPosition + ui . DrawPile . Size * 0.5f + new Vector2 ( 0f , - 140f ) +
84+ definition . Anchor . Offset ,
85+ node ) ,
8186 ModCardPileUiStyle . BottomRight =>
82- ui . ExhaustPile . GlobalPosition + ui . ExhaustPile . Size * 0.5f + new Vector2 ( - 140f , 0f ) +
83- definition . Anchor . Offset ,
87+ ApplyCardNodeOffset (
88+ ui . ExhaustPile . GlobalPosition + ui . ExhaustPile . Size * 0.5f + new Vector2 ( - 140f , 0f ) +
89+ definition . Anchor . Offset ,
90+ node ) ,
8491 ModCardPileUiStyle . ExtraHand =>
85- new Vector2 ( fallback . X - ( node ? . Size . X ?? 0f ) * 0.5f , fallback . Y - 260f ) + definition . Anchor . Offset ,
86- _ => fallback + definition . Anchor . Offset ,
92+ ApplyCardNodeOffset ( new Vector2 ( fallback . X , fallback . Y - 260f ) + definition . Anchor . Offset , node ) ,
93+ _ => ApplyCardNodeOffset ( fallback + definition . Anchor . Offset , node ) ,
8794 } ;
8895 }
8996
97+ private static Vector2 ApplyCardNodeOffset ( Vector2 centerPosition , NCard ? node )
98+ {
99+ if ( node == null )
100+ return centerPosition ;
101+ return centerPosition - node . Size * 0.5f ;
102+ }
103+
90104 private static Vector2 FallbackPosition ( )
91105 {
92106 var game = NGame . Instance ;
0 commit comments