55using MonoMod . Utils ;
66using System ;
77using System . Collections . Generic ;
8+ using System . Linq ;
89
910namespace Celeste . Mod . EeveeHelper . Components ;
1011
@@ -19,6 +20,8 @@ public class EntityContainerMover : EntityContainer
1920 {
2021 "Position" , "ExactPosition" , "TopLeft" , "TopCenter" , "TopRight" , "Center" , "CenterLeft" , "CenterRight" , "BottomLeft" , "BottomCenter" , "BottomRight"
2122 } ;
23+ private static Dictionary < Type , HashSet < string > > IgnoredAnchorsPerType = new ( ) ;
24+
2225 private static HashSet < string > CommonAnchors = new ( )
2326 {
2427 "anchor" , "anchorPosition" , "start" , "startPosition"
@@ -271,16 +274,29 @@ public static List<string> FindAnchors(Entity entity)
271274 {
272275 var result = new List < string > ( ) ;
273276 var data = new InheritedDynData ( entity ) ;
277+
278+ var type = entity . GetType ( ) ;
279+ var ignoredAnchorsForType = IgnoredAnchorsPerType . SelectMany ( kvp => kvp . Key . IsAssignableFrom ( type ) ? kvp . Value : [ ] ) . ToArray ( ) ;
280+
274281 foreach ( var pair in data )
275282 {
276- if ( pair . Value is Vector2 vector && ! IgnoredAnchors . Contains ( pair . Key ) && ( vector == EeveeUtils . GetPosition ( entity ) || CommonAnchors . Contains ( pair . Key ) ) )
277- {
283+ if ( pair . Value is Vector2 vector
284+ && ! IgnoredAnchors . Contains ( pair . Key )
285+ && ! ignoredAnchorsForType . Contains ( pair . Key )
286+ && ( vector == EeveeUtils . GetPosition ( entity ) || CommonAnchors . Contains ( pair . Key ) ) )
278287 result . Add ( pair . Key ) ;
279- }
280288 }
281289 return result ;
282290 }
283291
292+ public static void AddIgnoredAnchors ( Type type , HashSet < string > anchors )
293+ {
294+ if ( IgnoredAnchorsPerType . TryGetValue ( type , out var alreadyIgnoredAnchors ) )
295+ alreadyIgnoredAnchors . UnionWith ( anchors ) ;
296+ else
297+ IgnoredAnchorsPerType . Add ( type , anchors ) ;
298+ }
299+
284300 public static void AddEntityHandler ( Type entityType , Type handlerType )
285301 {
286302 foreach ( var type in FakeAssembly . GetEntryAssembly ( ) . GetTypesSafe ( ) )
0 commit comments