22using Microsoft . Xna . Framework ;
33using Monocle ;
44using System ;
5+ using System . Collections ;
56using System . Collections . Generic ;
67using System . Linq ;
8+ using System . Reflection ;
79using System . Text ;
810using System . Threading . Tasks ;
911
@@ -20,6 +22,32 @@ namespace Celeste.Mod.SpringCollab2020.Entities {
2022 [ CustomEntity ( "SpringCollab2020/FlagTouchSwitch" ) ]
2123 [ Tracked ]
2224 class FlagTouchSwitch : Entity {
25+ private static FieldInfo seekerPushRadius = typeof ( Seeker ) . GetField ( "pushRadius" , BindingFlags . NonPublic | BindingFlags . Instance ) ;
26+ private static FieldInfo seekerPhysicsHitbox = typeof ( Seeker ) . GetField ( "physicsHitbox" , BindingFlags . NonPublic | BindingFlags . Instance ) ;
27+
28+ public static void Load ( ) {
29+ On . Celeste . Seeker . RegenerateCoroutine += onSeekerRegenerateCoroutine ;
30+ }
31+
32+ public static void Unload ( ) {
33+ On . Celeste . Seeker . RegenerateCoroutine -= onSeekerRegenerateCoroutine ;
34+ }
35+
36+ private static IEnumerator onSeekerRegenerateCoroutine ( On . Celeste . Seeker . orig_RegenerateCoroutine orig , Seeker self ) {
37+ IEnumerator origEnum = orig ( self ) ;
38+ while ( origEnum . MoveNext ( ) ) {
39+ yield return origEnum . Current ;
40+ }
41+
42+ // make the seeker check for flag touch switches as well.
43+ self . Collider = ( Collider ) seekerPushRadius . GetValue ( self ) ;
44+ foreach ( FlagTouchSwitch touchSwitch in self . Scene . Tracker . GetEntities < FlagTouchSwitch > ( ) ) {
45+ if ( self . CollideCheck ( touchSwitch ) ) {
46+ touchSwitch . turnOn ( ) ;
47+ }
48+ }
49+ self . Collider = ( Collider ) seekerPhysicsHitbox . GetValue ( self ) ;
50+ }
2351
2452 private ParticleType P_RecoloredFire ;
2553
0 commit comments