Skip to content

Commit a760183

Browse files
committed
Allow configuring dream tunnel and seeker dash to not activate when using a green booster
1 parent b78dc90 commit a760183

8 files changed

Lines changed: 110 additions & 10 deletions

File tree

Loenn/lang/en_gb.lang

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,16 @@ triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.a
10981098
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.redirectConsumesNormalDash=Whether dream tunnel dash redirects should consume the player's normal dashes instead of their dream tunnel dashes.
10991099
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.allowTransitions=Whether to allow screen transitions while dream tunnel dashing.
11001100
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.bounceOnCollision=Whether the player should bounce on collision with a dream block while dream tunnel dashing.
1101+
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.respectBoosters=If enabled, dashing via a green booster will not trigger a dream tunnel dash.
1102+
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.revertOnLeave=Whether to revert this trigger's effects when the player leaves it.
1103+
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.revertOnDeath=Whether to revert this trigger's effects when the player dies.
1104+
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.onlyOnce=Whether this trigger should only activate once per room load.
1105+
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.flag=The flag this trigger should react to. Leave empty for this trigger to not be affected by flags.
1106+
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.flagInverted=If checked, the trigger will be disabled when the flag is active.\nIf unchecked, the trigger will be enabled when the flag is active.
1107+
1108+
# Configure Seeker Dash Trigger
1109+
triggers.CommunalHelper/ConfigureSeekerDashTrigger.placements.name.trigger=Configure Seeker Dash
1110+
triggers.CommunalHelper/ConfigureSeekerDashTrigger.attributes.description.respectBoosters=If enabled, dashing via a green booster will not trigger a seeker dash.
11011111
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.revertOnLeave=Whether to revert this trigger's effects when the player leaves it.
11021112
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.revertOnDeath=Whether to revert this trigger's effects when the player dies.
11031113
triggers.CommunalHelper/ConfigureDreamTunnelDashTrigger.attributes.description.onlyOnce=Whether this trigger should only activate once per room load.

Loenn/triggers/configure_dream_tunnel_dash.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ return {
1414
redirectConsumesNormalDash = false,
1515
allowTransitions = false,
1616
bounceOnCollision = false,
17+
respectBoosters = false,
1718
revertOnLeave = false,
1819
revertOnDeath = false,
1920
onlyOnce = false,
@@ -36,7 +37,8 @@ return {
3637
"x", "y", "width", "height",
3738
"allowRedirect", "allowSameDirectionRedirect", "sameDirectionSpeedMultiplier", "redirectConsumesNormalDash",
3839
"useEntryDirection", "speedConfiguration", "customSpeed",
39-
"allowDashCancels", "allowTransitions", "bounceOnCollision",
40+
"allowDashCancels", "allowTransitions",
41+
"bounceOnCollision", "respectBoosters",
4042
"revertOnLeave", "revertOnDeath", "onlyOnce",
4143
"flag", "flagInverted",
4244
},
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
return {
2+
name = "CommunalHelper/ConfigureSeekerDashTrigger",
3+
placements = {
4+
{
5+
name = "trigger",
6+
data = {
7+
respectBoosters = false,
8+
revertOnLeave = false,
9+
revertOnDeath = false,
10+
onlyOnce = false,
11+
flag = "",
12+
flagInverted = false,
13+
}
14+
}
15+
},
16+
fieldOrder = {
17+
"x", "y", "width", "height",
18+
"respectBoosters",
19+
"revertOnLeave", "revertOnDeath", "onlyOnce",
20+
"flag", "flagInverted",
21+
},
22+
}

src/CommunalHelperSession.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ public class CommunalHelperSession : EverestModuleSession
2828

2929
public DashStates.DreamTunnelDash.DreamTunnelDashConfiguration CurrentDreamTunnelDashConfiguration { get; set; } = DashStates.DreamTunnelDash.DefaultDreamTunnelDashConfiguration;
3030

31+
public DashStates.SeekerDash.SeekerDashConfiguration CurrentSeekerDashConfiguration { get; set; } = DashStates.SeekerDash.DefaultSeekerDashConfiguration;
32+
3133
internal float PrevGasTimer { get; set; }
3234
public float GasTimer { get; set; }
3335

src/DashStates/DreamTunnelDash/DreamTunnelDash.cs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public struct DreamTunnelDashConfiguration
7979
public bool RedirectConsumesNormalDash;
8080
public bool AllowTransitions;
8181
public bool BounceOnCollision;
82+
public bool RespectBoosters;
8283
}
8384

8485
public static readonly DreamTunnelDashConfiguration DefaultDreamTunnelDashConfiguration = new()
@@ -92,7 +93,8 @@ public struct DreamTunnelDashConfiguration
9293
AllowDashCancels = false,
9394
RedirectConsumesNormalDash = false,
9495
AllowTransitions = false,
95-
BounceOnCollision = false
96+
BounceOnCollision = false,
97+
RespectBoosters = false
9698
};
9799

98100

@@ -234,6 +236,9 @@ private static void UseDreamTunnelDash()
234236
private static void Player_DashBegin(On.Celeste.Player.orig_DashBegin orig, Player self)
235237
{
236238
orig(self);
239+
240+
if (CommunalHelperModule.Session.CurrentDreamTunnelDashConfiguration.RespectBoosters && self.CurrentBooster is not null)
241+
return;
237242

238243
UseDreamTunnelDash();
239244
if (!CommunalHelperModule.Session.CurrentDreamTunnelDashConfiguration.AllowDashCancels)
@@ -263,13 +268,16 @@ private static void Player_DashCoroutine(ILContext il)
263268
* inserts a call to StartDreamTunnelDashAttacking (without overriding Speed and DashDir) after the call to CallDashEvents if the current dream dash config allows dash cancels
264269
* is this the best place to put this logic?
265270
*/
266-
ILLabel afterStartDashAttack = cursor.DefineLabel();
267271
cursor.GotoNext(MoveType.After, instr => instr.MatchCallvirt<Player>("CallDashEvents"));
268-
cursor.EmitDelegate(() => CommunalHelperModule.Session.CurrentDreamTunnelDashConfiguration.AllowDashCancels);
269-
cursor.Emit(OpCodes.Brfalse, afterStartDashAttack);
270272
cursor.Emit(OpCodes.Ldloc_1);
271-
cursor.EmitDelegate<Action<Player>>(player => StartDreamTunnelDashAttacking(player, player.DashDir));
272-
cursor.MarkLabel(afterStartDashAttack);
273+
cursor.EmitDelegate<Action<Player>>(player =>
274+
{
275+
if (CommunalHelperModule.Session.CurrentDreamTunnelDashConfiguration.RespectBoosters && player.CurrentBooster is not null)
276+
return;
277+
278+
if (CommunalHelperModule.Session.CurrentDreamTunnelDashConfiguration.AllowDashCancels)
279+
StartDreamTunnelDashAttacking(player, player.DashDir);
280+
});
273281

274282
/*
275283
* adds a check for !dreamTunnelDashAttacking to

src/DashStates/SeekerDash/SeekerDash.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public static bool HasSeekerDash
3535
private static readonly FieldInfo f_Seeker_dead = typeof(Seeker).GetField("dead", BindingFlags.NonPublic | BindingFlags.Instance);
3636

3737
private static IDetour hook_Player_get_CanDash;
38+
39+
public struct SeekerDashConfiguration
40+
{
41+
public bool RespectBoosters;
42+
}
43+
44+
public static readonly SeekerDashConfiguration DefaultSeekerDashConfiguration = new()
45+
{
46+
RespectBoosters = false
47+
};
3848

3949
internal static void Load()
4050
{
@@ -167,6 +177,10 @@ private static bool Player_get_CanDash(Func<Player, bool> orig, Player self)
167177
private static void Player_DashBegin(On.Celeste.Player.orig_DashBegin orig, Player self)
168178
{
169179
orig(self);
180+
181+
if (CommunalHelperModule.Session.CurrentSeekerDashConfiguration.RespectBoosters && self.CurrentBooster is not null)
182+
return;
183+
170184
if (HasSeekerDash)
171185
{
172186
seekerDashAttacking = true;

src/Triggers/ConfigureDreamTunnelDashTrigger.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ protected override DreamTunnelDashConfiguration GetConfiguredOptions(EntityData
2222
AllowDashCancels = data.Bool("allowDashCancels", false),
2323
RedirectConsumesNormalDash = data.Bool("redirectConsumesNormalDash", false),
2424
AllowTransitions = data.Bool("allowTransitions", false),
25-
BounceOnCollision = data.Bool("bounceOnCollision", false)
25+
BounceOnCollision = data.Bool("bounceOnCollision", false),
26+
RespectBoosters = data.Bool("respectBoosters", false)
2627
};
2728
protected override DreamTunnelDashConfiguration GetCurrentOptions(Player player)
2829
=> CommunalHelperModule.Session.CurrentDreamTunnelDashConfiguration;
@@ -41,7 +42,8 @@ protected override DreamTunnelDashConfigurationChanges CalculateChangesNeededToR
4142
NewAllowDashCancels = to.AllowDashCancels == from.AllowDashCancels ? null : from.AllowDashCancels,
4243
NewRedirectConsumesNormalDash = to.RedirectConsumesNormalDash == from.RedirectConsumesNormalDash ? null : from.RedirectConsumesNormalDash,
4344
NewAllowTransitions = to.AllowTransitions == from.AllowTransitions ? null : from.AllowTransitions,
44-
NewBounceOnCollision = to.BounceOnCollision == from.BounceOnCollision ? null : from.BounceOnCollision
45+
NewBounceOnCollision = to.BounceOnCollision == from.BounceOnCollision ? null : from.BounceOnCollision,
46+
NewRespectBoosters = to.RespectBoosters == from.RespectBoosters ? null : from.RespectBoosters
4547
};
4648
protected override DreamTunnelDashConfiguration RevertChanges(DreamTunnelDashConfiguration current, DreamTunnelDashConfigurationChanges? changesNeededToRevert)
4749
=> new()
@@ -55,7 +57,8 @@ protected override DreamTunnelDashConfiguration RevertChanges(DreamTunnelDashCon
5557
AllowDashCancels = changesNeededToRevert?.NewAllowDashCancels ?? current.AllowDashCancels,
5658
RedirectConsumesNormalDash = changesNeededToRevert?.NewRedirectConsumesNormalDash ?? current.RedirectConsumesNormalDash,
5759
AllowTransitions = changesNeededToRevert?.NewAllowTransitions ?? current.AllowTransitions,
58-
BounceOnCollision = changesNeededToRevert?.NewBounceOnCollision ?? current.BounceOnCollision
60+
BounceOnCollision = changesNeededToRevert?.NewBounceOnCollision ?? current.BounceOnCollision,
61+
RespectBoosters = changesNeededToRevert?.NewRespectBoosters ?? current.RespectBoosters
5962
};
6063
}
6164

@@ -71,4 +74,5 @@ public struct DreamTunnelDashConfigurationChanges
7174
public bool? NewRedirectConsumesNormalDash;
7275
public bool? NewAllowTransitions;
7376
public bool? NewBounceOnCollision;
77+
public bool? NewRespectBoosters;
7478
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using static Celeste.Mod.CommunalHelper.DashStates.SeekerDash;
2+
3+
namespace Celeste.Mod.CommunalHelper.Triggers;
4+
5+
[CustomEntity("CommunalHelper/ConfigureSeekerDashTrigger")]
6+
[TrackedAs(typeof(AbstractConfigureStateTrigger<SeekerDashConfiguration, SeekerDashConfigurationChanges>))]
7+
public class ConfigureSeekerDashTrigger : AbstractConfigureStateTrigger<SeekerDashConfiguration, SeekerDashConfigurationChanges>
8+
{
9+
public ConfigureSeekerDashTrigger(EntityData data, Vector2 offset)
10+
: base(data, offset)
11+
{ }
12+
13+
protected override SeekerDashConfiguration GetConfiguredOptions(EntityData data)
14+
=> new()
15+
{
16+
RespectBoosters = data.Bool("respectBoosters", false)
17+
};
18+
protected override SeekerDashConfiguration GetCurrentOptions(Player player)
19+
=> CommunalHelperModule.Session.CurrentSeekerDashConfiguration;
20+
protected override void SaveOptions(Player player, SeekerDashConfiguration options)
21+
=> CommunalHelperModule.Session.CurrentSeekerDashConfiguration = options;
22+
23+
protected override SeekerDashConfigurationChanges CalculateChangesNeededToRevert(SeekerDashConfiguration from, SeekerDashConfiguration to)
24+
=> new()
25+
{
26+
NewRespectBoosters = to.RespectBoosters == from.RespectBoosters ? null : from.RespectBoosters
27+
};
28+
protected override SeekerDashConfiguration RevertChanges(SeekerDashConfiguration current, SeekerDashConfigurationChanges? changesNeededToRevert)
29+
=> new()
30+
{
31+
RespectBoosters = changesNeededToRevert?.NewRespectBoosters ?? current.RespectBoosters
32+
};
33+
}
34+
35+
public struct SeekerDashConfigurationChanges
36+
{
37+
public bool? NewRespectBoosters;
38+
}

0 commit comments

Comments
 (0)