Skip to content

Commit bafe952

Browse files
authored
Merge pull request #111 from EverestAPI/flag_touch_switches_and_puffers
Have puffer fish explosions turn on flag touch switches
2 parents c70a192 + fb4d87a commit bafe952

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Entities/FlagTouchSwitch.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@ namespace Celeste.Mod.SpringCollab2020.Entities {
2424
class FlagTouchSwitch : Entity {
2525
private static FieldInfo seekerPushRadius = typeof(Seeker).GetField("pushRadius", BindingFlags.NonPublic | BindingFlags.Instance);
2626
private static FieldInfo seekerPhysicsHitbox = typeof(Seeker).GetField("physicsHitbox", BindingFlags.NonPublic | BindingFlags.Instance);
27+
private static FieldInfo pufferPushRadius = typeof(Puffer).GetField("pushRadius", BindingFlags.NonPublic | BindingFlags.Instance);
2728

2829
public static void Load() {
2930
On.Celeste.Seeker.RegenerateCoroutine += onSeekerRegenerateCoroutine;
31+
On.Celeste.Puffer.Explode += onPufferExplode;
3032
}
3133

3234
public static void Unload() {
3335
On.Celeste.Seeker.RegenerateCoroutine -= onSeekerRegenerateCoroutine;
36+
On.Celeste.Puffer.Explode -= onPufferExplode;
3437
}
3538

3639
private static IEnumerator onSeekerRegenerateCoroutine(On.Celeste.Seeker.orig_RegenerateCoroutine orig, Seeker self) {
@@ -41,12 +44,26 @@ private static IEnumerator onSeekerRegenerateCoroutine(On.Celeste.Seeker.orig_Re
4144

4245
// make the seeker check for flag touch switches as well.
4346
self.Collider = (Collider) seekerPushRadius.GetValue(self);
47+
turnOnTouchSwitchesCollidingWith(self);
48+
self.Collider = (Collider) seekerPhysicsHitbox.GetValue(self);
49+
}
50+
51+
private static void onPufferExplode(On.Celeste.Puffer.orig_Explode orig, Puffer self) {
52+
orig(self);
53+
54+
// make the puffer check for flag touch switches as well.
55+
Collider oldCollider = self.Collider;
56+
self.Collider = (Collider) pufferPushRadius.GetValue(self);
57+
turnOnTouchSwitchesCollidingWith(self);
58+
self.Collider = oldCollider;
59+
}
60+
61+
private static void turnOnTouchSwitchesCollidingWith(Entity self) {
4462
foreach (FlagTouchSwitch touchSwitch in self.Scene.Tracker.GetEntities<FlagTouchSwitch>()) {
4563
if (self.CollideCheck(touchSwitch)) {
4664
touchSwitch.turnOn();
4765
}
4866
}
49-
self.Collider = (Collider) seekerPhysicsHitbox.GetValue(self);
5067
}
5168

5269
private ParticleType P_RecoloredFire;

0 commit comments

Comments
 (0)