Skip to content

Commit 6f9d7a5

Browse files
committed
upgrade to new monomod. currently on hold until modinterop gets less fucked
1 parent 11c1003 commit 6f9d7a5

20 files changed

+218
-84
lines changed

src/CommunalHelper.csproj

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,17 @@
2020

2121
<!--Include MonoMod and MonoMod.RuntimeDetour-->
2222
<ItemGroup>
23-
<PackageReference Include="Mono.Cecil" Version="0.11.6" />
24-
<PackageReference Include="MonoMod" Version="22.01.04.03" />
25-
<PackageReference Include="MonoMod.RuntimeDetour" Version="22.01.04.03">
26-
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
27-
</PackageReference>
28-
<PackageReference Include="CelesteMod.Publicizer" Version="*" CelesteAssembly="$(CelestePrefix)\Celeste.dll" />
23+
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.3.1" PrivateAssets="all" ExcludeAssets="runtime" />
24+
<PackageReference Include="MonoMod.Patcher" Version="25.0.0-prerelease.2" />
25+
<PackageReference Include="CelesteAnalyzer" Version="*" />
2926
</ItemGroup>
3027

3128
<!--Include Celeste.dll, MMHOOK_Celeste.dll and FNA.dll-->
3229
<ItemGroup>
33-
<Reference Include="$(CelestePrefix)\MMHOOK_Celeste.dll">
34-
<Private>false</Private>
35-
</Reference>
36-
<Reference Include="$(CelestePrefix)\FNA.dll">
37-
<Private>false</Private>
38-
</Reference>
30+
<PackageReference Include="CelesteMod.Publicizer" Version="*" CelesteAssembly="$(CelestePrefix)\Celeste.dll" />
31+
<Reference Include="$(CelestePrefix)\MMHOOK_Celeste.dll" Private="false" />
32+
<Reference Include="$(CelestePrefix)\FNA.dll" Private="false" />
33+
<Reference Include="$(CelestePrefix)\NLua.dll" Private="false" />
3934
</ItemGroup>
4035

4136
</Project>

src/Components/DreamSprite.cs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
namespace Celeste.Mod.CommunalHelper.Components;
88

99
public class DreamSprite : Sprite {
10-
internal class DreamSpriteMarker(Vector2 position) : Entity(position);
10+
internal class DreamSpriteMarker(Entity parent) : Entity(parent.Position)
11+
{
12+
public override void Update()
13+
=> Position = parent.Position;
14+
}
1115
internal DreamSpriteMarker Marker;
1216

1317
public readonly Rectangle ParticleBounds;
@@ -53,7 +57,7 @@ public override void EntityAdded(Scene scene)
5357
base.EntityAdded(scene);
5458

5559
TrackSelf();
56-
Scene.Add(Marker = new DreamSpriteMarker(Entity.Position));
60+
Scene.Add(Marker = new DreamSpriteMarker(Entity));
5761
}
5862

5963
public override void EntityAwake()
@@ -62,25 +66,25 @@ public override void EntityAwake()
6266

6367
Particles = new DreamParticle[(int)((ParticleBounds.Width / 8f) * (ParticleBounds.Height / 8f) * 0.7f)];
6468

65-
(_, _, _, _, List<List<Color>> particleLayerColors) = Imports.PandorasBox.GetVisualSettingsFor(Marker);
69+
Imports.PandorasBox.GetVisualSettingsFor(Marker, out _, out _, out _, out _, out Color[][] activeParticleLayerColors, out Color[][] disabledParticleLayerColors);
6670

6771
for (int i = 0; i < Particles.Length; i++) {
6872
Particles[i].Position = new Vector2(Calc.Random.NextFloat(ParticleBounds.Width), Calc.Random.NextFloat(ParticleBounds.Height));
6973
Particles[i].Layer = Calc.Random.Choose(0, 1, 1, 2, 2, 2);
7074
Particles[i].TimeOffset = Calc.Random.NextFloat();
7175

72-
Particles[i].DisabledColor = Color.LightGray * (0.5f + Particles[i].Layer / 2f * 0.5f);
73-
Particles[i].DisabledColor.A = 255;
74-
75-
Particles[i].EnabledColor = particleLayerColors is not null
76-
? Calc.Random.Choose(particleLayerColors[Particles[i].Layer])
76+
Particles[i].DisabledColor = disabledParticleLayerColors is not null
77+
? Calc.Random.Choose(disabledParticleLayerColors[Particles[i].Layer])
78+
: Color.LightGray * (0.5f + Particles[i].Layer / 2f * 0.5f);
79+
Particles[i].EnabledColor = activeParticleLayerColors is not null
80+
? Calc.Random.Choose(activeParticleLayerColors[Particles[i].Layer])
7781
: Particles[i].Layer switch
78-
{
79-
0 => Calc.Random.Choose(ParticleColors[0], ParticleColors[1], ParticleColors[2]),
80-
1 => Calc.Random.Choose(ParticleColors[3], ParticleColors[4], ParticleColors[5]),
81-
2 => Calc.Random.Choose(ParticleColors[6], ParticleColors[7], ParticleColors[8]),
82-
_ => throw new NotImplementedException()
83-
};
82+
{
83+
0 => Calc.Random.Choose(ParticleColors[0], ParticleColors[1], ParticleColors[2]),
84+
1 => Calc.Random.Choose(ParticleColors[3], ParticleColors[4], ParticleColors[5]),
85+
2 => Calc.Random.Choose(ParticleColors[6], ParticleColors[7], ParticleColors[8]),
86+
_ => throw new NotImplementedException()
87+
};
8488
}
8589
}
8690

src/Components/Pushable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ private static Pushable LowestPullable(List<Pushable> pushables)
139139
}
140140

141141
// ReSharper disable once InconsistentNaming
142-
private static IDetour hook_Player_orig_UpdateSprite;
142+
private static ILHook hook_Player_orig_UpdateSprite;
143143

144144
internal static void Load()
145145
{

src/DashStates/DreamTunnelDash/DreamTunnelDash.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ public static bool NextDashFeather
5555
// Keep a List<Entity> around to not allocate a new one every CollideAll<T>() call
5656
private static List<Entity> dreamTunnelBlockers = new();
5757

58-
private static IDetour hook_Player_DashCoroutine;
59-
private static IDetour hook_Player_orig_Update;
60-
private static IDetour hook_Player_orig_UpdateSprite;
58+
private static ILHook hook_Player_DashCoroutine;
59+
private static ILHook hook_Player_orig_Update;
60+
private static ILHook hook_Player_orig_UpdateSprite;
6161

6262

6363
public enum SpeedConfiguration

src/DashStates/DreamTunnelDash/DreamTunnelEntry.cs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -343,11 +343,12 @@ public void WobbleLine(Vector2 from, Vector2 to, float offset, bool line, bool b
343343
Vector2 vector = Vector2.Normalize(to - from);
344344
Vector2 perp = new(vector.Y, -vector.X);
345345

346-
(Color? controllerActiveBackColor,
347-
Color? controllerDisabledBackColor,
348-
Color? controllerActiveLineColor,
349-
Color? controllerDisabledLineColor,
350-
_) = Imports.PandorasBox.GetVisualSettingsFor(this);
346+
Imports.PandorasBox.GetVisualSettingsFor(this,
347+
out Color? controllerActiveBackColor,
348+
out Color? controllerDisabledBackColor,
349+
out Color? controllerActiveLineColor,
350+
out Color? controllerDisabledLineColor,
351+
out _, out _);
351352

352353
Color backColor = PlayerHasDreamDash
353354
? controllerActiveBackColor ?? DreamBlock.activeBackColor
@@ -397,24 +398,26 @@ private void Setup()
397398
{
398399
particles = new DreamParticle[(int) (Width / 4f * (Height / 4f) * 0.5f)];
399400

400-
(_, _, _, _, List<List<Color>> particleLayerColors) = Imports.PandorasBox.GetVisualSettingsFor(this);
401+
Imports.PandorasBox.GetVisualSettingsFor(this, out _, out _, out _, out _, out Color[][] activeParticleLayerColors, out Color[][] disabledParticleLayerColors);
401402

402403
for (int i = 0; i < particles.Length; i++)
403404
{
404405
particles[i].Position = new Vector2(Calc.Random.NextFloat(Width), Calc.Random.NextFloat(Height));
405406
particles[i].Layer = Calc.Random.Choose(0, 1, 1, 2, 2, 2);
406407
particles[i].TimeOffset = Calc.Random.NextFloat();
407408
particles[i].Color = PlayerHasDreamDash
408-
? particleLayerColors is not null
409-
? Calc.Random.Choose(particleLayerColors[particles[i].Layer])
409+
? activeParticleLayerColors is not null
410+
? Calc.Random.Choose(activeParticleLayerColors[particles[i].Layer])
410411
: particles[i].Layer switch
411412
{
412413
0 => Calc.Random.Choose(CustomDreamBlock.DreamColors[0], CustomDreamBlock.DreamColors[1], CustomDreamBlock.DreamColors[2]),
413414
1 => Calc.Random.Choose(CustomDreamBlock.DreamColors[3], CustomDreamBlock.DreamColors[4], CustomDreamBlock.DreamColors[5]),
414415
2 => Calc.Random.Choose(CustomDreamBlock.DreamColors[6], CustomDreamBlock.DreamColors[7], CustomDreamBlock.DreamColors[8]),
415416
_ => throw new NotImplementedException()
416417
}
417-
: Color.LightGray * (0.5f + particles[i].Layer / 2f * 0.5f);
418+
: disabledParticleLayerColors is not null
419+
? Calc.Random.Choose(disabledParticleLayerColors[particles[i].Layer])
420+
: Color.LightGray * (0.5f + particles[i].Layer / 2f * 0.5f);
418421
}
419422
}
420423

@@ -474,8 +477,8 @@ private IEnumerator FastDeactivate()
474477

475478
#region Hooks
476479

477-
private static IDetour hook_Player_DashCoroutine;
478-
private static IDetour hook_Player_orig_WallJump;
480+
private static ILHook hook_Player_DashCoroutine;
481+
private static ILHook hook_Player_orig_WallJump;
479482

480483
internal static new void Load()
481484
{

src/DashStates/DreamTunnelDash/DreamTunnelEntryRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public override void Render()
2929
Vector2 start = shake + e.Start;
3030
Vector2 end = shake + e.End;
3131

32-
(Color? controllerActiveBackColor, Color? controllerDisabledBackColor, _, _, _) = Imports.PandorasBox.GetVisualSettingsFor(e);
32+
Imports.PandorasBox.GetVisualSettingsFor(e, out Color? controllerActiveBackColor, out Color? controllerDisabledBackColor, out _, out _, out _, out _);
3333
Color backColor = e.PlayerHasDreamDash
3434
? controllerActiveBackColor ?? DreamBlock.activeBackColor
3535
: controllerDisabledBackColor ?? DreamBlock.disabledBackColor;

src/DashStates/SeekerDash/SeekerDash.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static bool HasSeekerDash
3434
private static readonly MethodInfo m_Seeker_GotBouncedOn = typeof(Seeker).GetMethod("GotBouncedOn", BindingFlags.NonPublic | BindingFlags.Instance);
3535
private static readonly FieldInfo f_Seeker_dead = typeof(Seeker).GetField("dead", BindingFlags.NonPublic | BindingFlags.Instance);
3636

37-
private static IDetour hook_Player_get_CanDash;
37+
private static Hook hook_Player_get_CanDash;
3838

3939
internal static void Load()
4040
{

src/Entities/Aero/AeroBlockCharged.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ public override void Update()
352352

353353
internal static void Load()
354354
{
355-
using (new DetourContext { After = { "*" } })
355+
// equivalent to `new DetourContextConfig { After = { "*" } }`
356+
using (new DetourConfigContext(new DetourConfig(nameof(CommunalHelper), int.MinValue)).Use())
356357
{
357358
On.Celeste.Player.Jump += Player_Jump;
358359
On.Celeste.Player.WallJump += Player_WallJump;

src/Entities/DreamBlocks/ConnectedDreamBlock.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,12 @@ public override void Render()
351351
if (!MasterOfGroup)
352352
return;
353353

354-
(Color? controllerActiveBackColor, Color? controllerDisabledBackColor, Color? controllerActiveLineColor, Color? controllerDisabledLineColor, _)
355-
= Imports.PandorasBox.GetVisualSettingsFor(this);
354+
Imports.PandorasBox.GetVisualSettingsFor(this,
355+
out Color? controllerActiveBackColor,
356+
out Color? controllerDisabledBackColor,
357+
out Color? controllerActiveLineColor,
358+
out Color? controllerDisabledLineColor,
359+
out _, out _);
356360
Color backColor = Color.Lerp(PlayerHasDreamDash
357361
? controllerActiveBackColor ?? activeBackColor
358362
: controllerDisabledBackColor ?? disabledBackColor, Color.White, ColorLerp);

src/Entities/DreamBlocks/CustomDreamBlock.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using MonoMod.Cil;
33
using System.Collections;
44
using System.Collections.Generic;
5+
using System.Linq;
56

67
namespace Celeste.Mod.CommunalHelper.Entities;
78

@@ -154,22 +155,23 @@ protected virtual void SetupCustomParticles(float canvasWidth, float canvasHeigh
154155

155156
private Color GetParticleColor(int layer, Color[] dashColors)
156157
{
157-
Color defaultColor = layer switch
158-
{
159-
0 => Calc.Random.Choose(DreamColors[0], DreamColors[1], DreamColors[2]),
160-
1 => Calc.Random.Choose(DreamColors[3], DreamColors[4], DreamColors[5]),
161-
2 => Calc.Random.Choose(DreamColors[6], DreamColors[7], DreamColors[8]),
162-
_ => throw new NotImplementedException()
163-
};
164-
(_, _, _, _, List<List<Color>> particleLayerColors) = Imports.PandorasBox.GetVisualSettingsFor(this);
158+
Imports.PandorasBox.GetVisualSettingsFor(this, out _, out _, out _, out _, out Color[][] activeParticleLayerColors, out Color[][] disabledParticleLayerColors);
165159

166160
return PlayerHasDreamDash
167161
? RefillCount != -1
168162
? dashColors[layer]
169-
: particleLayerColors is not null
170-
? Calc.Random.Choose(particleLayerColors[layer])
171-
: defaultColor
172-
: Color.LightGray * (0.5f + layer / 2f * 0.5f);
163+
: activeParticleLayerColors is not null
164+
? Calc.Random.Choose(activeParticleLayerColors[layer])
165+
: layer switch
166+
{
167+
0 => Calc.Random.Choose(DreamColors[0], DreamColors[1], DreamColors[2]),
168+
1 => Calc.Random.Choose(DreamColors[3], DreamColors[4], DreamColors[5]),
169+
2 => Calc.Random.Choose(DreamColors[6], DreamColors[7], DreamColors[8]),
170+
_ => throw new NotImplementedException()
171+
}
172+
: disabledParticleLayerColors is not null
173+
? Calc.Random.Choose(disabledParticleLayerColors[layer])
174+
: Color.LightGray * (0.5f + layer / 2f * 0.5f);
173175
}
174176

175177
private void ShakeParticles()
@@ -263,8 +265,12 @@ public override void Render()
263265
if (Right < camera.Left || Left > camera.Right || Bottom < camera.Top || Top > camera.Bottom)
264266
return;
265267

266-
(Color? controllerActiveBackColor, Color? controllerDisabledBackColor, Color? controllerActiveLineColor, Color? controllerDisabledLineColor, _)
267-
= Imports.PandorasBox.GetVisualSettingsFor(this);
268+
Imports.PandorasBox.GetVisualSettingsFor(this,
269+
out Color? controllerActiveBackColor,
270+
out Color? controllerDisabledBackColor,
271+
out Color? controllerActiveLineColor,
272+
out Color? controllerDisabledLineColor,
273+
out _, out _);
268274
Color backColor = Color.Lerp(PlayerHasDreamDash
269275
? controllerActiveBackColor ?? activeBackColor
270276
: controllerDisabledBackColor ?? disabledBackColor, Color.White, ColorLerp);
@@ -500,7 +506,7 @@ private static void Player_DreamDashBegin(On.Celeste.Player.orig_DreamDashBegin
500506
player.Position += player.DashDir.Sign();
501507

502508
// Only override speed if there isn't a Dream Dash Controller affecting this block
503-
(_, _, bool? overrideDreamDashSpeed, _, _, _, _, _, _) = Imports.PandorasBox.GetGameplaySettingsFor(player.dreamBlock);
509+
Imports.PandorasBox.GetGameplaySettingsFor(player.dreamBlock, out _, out _, out bool? overrideDreamDashSpeed, out _, out _, out _, out _, out _, out _);
504510
if (!(overrideDreamDashSpeed ?? false))
505511
player.Speed = player.DashDir * customDreamBlock.dashSpeed;
506512
}
@@ -532,10 +538,9 @@ private static void Player_DreamDashEnd(ILContext il)
532538
return;
533539

534540
cursor.Emit(OpCodes.Ldarg_0);
535-
cursor.EmitDelegate<Func<Player, bool>>(player => player.GetData().Get<DreamBlock>("dreamBlock") is CustomDreamBlock block && block.RefillCount == -2);
541+
cursor.EmitDelegate<Func<Player, bool>>(player => player.GetData().Get<DreamBlock>("dreamBlock") is CustomDreamBlock { RefillCount: -2 });
536542
cursor.Emit(OpCodes.Brtrue_S, cursor.Next.Next);
537543
}
538544

539545
#endregion
540-
541546
}

0 commit comments

Comments
 (0)