Skip to content

Commit 62e93af

Browse files
authored
Merge pull request #184 from EverestAPI/heatwave_no_colorgrade
Heat Wave effect not affecting color grade when disabled
2 parents 96a0ba1 + 123d26b commit 62e93af

File tree

3 files changed

+71
-2
lines changed

3 files changed

+71
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module SpringCollab2020HeatWaveNoColorGrade
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Effect "SpringCollab2020/HeatWaveNoColorGrade" HeatWaveNoColorGrade(only::String="*", exclude::String="")
6+
7+
placements = HeatWaveNoColorGrade
8+
9+
function Ahorn.canFgBg(effect::HeatWaveNoColorGrade)
10+
return true, true
11+
end
12+
13+
end

Effects/HeatWaveNoColorGrade.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Monocle;
2+
using MonoMod.Utils;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Celeste.Mod.SpringCollab2020.Effects {
10+
/// <summary>
11+
/// A heatwave effect that does not affect the colorgrade when it is hidden.
12+
/// </summary>
13+
class HeatWaveNoColorGrade : HeatWave {
14+
private DynData<HeatWave> self = new DynData<HeatWave>();
15+
16+
public HeatWaveNoColorGrade() : base() {
17+
self = new DynData<HeatWave>(this);
18+
}
19+
20+
public override void Update(Scene scene) {
21+
Level level = scene as Level;
22+
bool show = (IsVisible(level) && level.CoreMode != Session.CoreModes.None);
23+
24+
if (!show) {
25+
// if not fading out, the heatwave is invisible, so don't even bother updating it.
26+
if (self.Get<float>("fade") > 0) {
27+
// be sure to lock color grading to prevent it from becoming "none".
28+
DynData<Level> levelData = new DynData<Level>(level);
29+
30+
float colorGradeEase = levelData.Get<float>("colorGradeEase");
31+
float colorGradeEaseSpeed = levelData.Get<float>("colorGradeEaseSpeed");
32+
string colorGrade = level.Session.ColorGrade;
33+
34+
base.Update(scene);
35+
36+
levelData["colorGradeEase"] = colorGradeEase;
37+
levelData["colorGradeEaseSpeed"] = colorGradeEaseSpeed;
38+
level.Session.ColorGrade = colorGrade;
39+
}
40+
} else {
41+
// heat wave is visible: update as usual.
42+
base.Update(scene);
43+
}
44+
}
45+
}
46+
}

SpringCollab2020Module.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using Celeste.Mod.SpringCollab2020.Effects;
12
using Celeste.Mod.SpringCollab2020.Entities;
23
using Celeste.Mod.SpringCollab2020.Triggers;
34
using System;
@@ -34,6 +35,7 @@ public override void Load() {
3435
SeekerCustomColors.Load();
3536
CameraCatchupSpeedTrigger.Load();
3637
ColorGradeFadeTrigger.Load();
38+
Everest.Events.Level.OnLoadBackdrop += onLoadBackdrop;
3739
}
3840

3941
public override void LoadContent(bool firstLoad) {
@@ -63,8 +65,16 @@ public override void Unload() {
6365
SeekerCustomColors.Unload();
6466
CameraCatchupSpeedTrigger.Unload();
6567
ColorGradeFadeTrigger.Unload();
66-
}
67-
68+
Everest.Events.Level.OnLoadBackdrop -= onLoadBackdrop;
69+
}
70+
71+
private Backdrop onLoadBackdrop(MapData map, BinaryPacker.Element child, BinaryPacker.Element above) {
72+
if (child.Name.Equals("SpringCollab2020/HeatWaveNoColorGrade", StringComparison.OrdinalIgnoreCase)) {
73+
return new HeatWaveNoColorGrade();
74+
}
75+
return null;
76+
}
77+
6878
public override void PrepareMapDataProcessors(MapDataFixup context) {
6979
base.PrepareMapDataProcessors(context);
7080

0 commit comments

Comments
 (0)