Skip to content

Commit 96a0ba1

Browse files
authored
Merge pull request #182 from EverestAPI/color_grade_fade_trigger
2 parents 60b7737 + 6e72199 commit 96a0ba1

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

Ahorn/lang/en_gb.lang

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ placements.entities.SpringCollab2020/LightningDashSwitch.tooltips.side=Which dir
1818
placements.entities.SpringCollab2020/LightningDashSwitch.tooltips.sprite=Changes the visual appearance of the switch.
1919
placements.entities.SpringCollab2020/LightningDashSwitch.tooltips.persistent=Whether or not the switch will stay pressed upon leaving the room.
2020

21-
2221
# Cave Wall
2322
placements.entities.SpringCollab2020/caveWall.tooltips.tiletype=Changes the visual appearance of the wall.
2423
placements.entities.SpringCollab2020/caveWall.tooltips.disableTransitionFading=If ticked, prevents the wall from fading in during transitions.
@@ -279,3 +278,8 @@ placements.entities.SpringCollab2020/CustomRespawnTimeRefill.tooltips.respawnTim
279278

280279
# Camera Catchup Speed Trigger
281280
placements.triggers.SpringCollab2020/CameraCatchupSpeedTrigger.tooltips.catchupSpeed=Raise this value to have the camera scroll quicker to its target. Vanilla values are 8 during the temple fall cutscene, and 1 everywhere else.
281+
282+
# Color Grade Fade Trigger
283+
placements.triggers.SpringCollab2020/ColorGradeFadeTrigger.tooltips.colorGradeA=The color grade to fade from.
284+
placements.triggers.SpringCollab2020/ColorGradeFadeTrigger.tooltips.colorGradeB=The color grade to fade to.
285+
placements.triggers.SpringCollab2020/ColorGradeFadeTrigger.tooltips.direction=The direction of the fade. For example, if set to LeftToRight, the color grade will fade from color grade A to color grade B when the player crosses the trigger from left to right.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module SpringCollab2020ColorGradeFadeTrigger
2+
3+
using ..Ahorn, Maple
4+
5+
@mapdef Trigger "SpringCollab2020/ColorGradeFadeTrigger" ColorGradeFadeTrigger(x::Integer, y::Integer, width::Integer=Maple.defaultTriggerWidth, height::Integer=Maple.defaultTriggerHeight,
6+
colorGradeA::String="none", colorGradeB::String="none", direction::String="LeftToRight")
7+
8+
const placements = Ahorn.PlacementDict(
9+
"Color Grade Fade (Spring Collab 2020)" => Ahorn.EntityPlacement(
10+
ColorGradeFadeTrigger,
11+
"rectangle",
12+
),
13+
)
14+
15+
const colorGrades = String["none", "oldsite", "panicattack", "templevoid", "reflection", "credits", "cold", "hot", "feelingdown", "golden"]
16+
17+
function Ahorn.editingOptions(trigger::ColorGradeFadeTrigger)
18+
return Dict{String, Any}(
19+
"direction" => String["LeftToRight", "TopToBottom"],
20+
"colorGradeA" => colorGrades,
21+
"colorGradeB" => colorGrades
22+
)
23+
end
24+
25+
end

SpringCollab2020Module.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public override void Load() {
3333
StrawberryIgnoringLighting.Load();
3434
SeekerCustomColors.Load();
3535
CameraCatchupSpeedTrigger.Load();
36+
ColorGradeFadeTrigger.Load();
3637
}
3738

3839
public override void LoadContent(bool firstLoad) {
@@ -61,6 +62,7 @@ public override void Unload() {
6162
StrawberryIgnoringLighting.Unload();
6263
SeekerCustomColors.Unload();
6364
CameraCatchupSpeedTrigger.Unload();
65+
ColorGradeFadeTrigger.Unload();
6466
}
6567

6668
public override void PrepareMapDataProcessors(MapDataFixup context) {

Triggers/ColorGradeFadeTrigger.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Celeste.Mod.Entities;
2+
using Microsoft.Xna.Framework;
3+
using Monocle;
4+
using MonoMod.Utils;
5+
6+
namespace Celeste.Mod.SpringCollab2020.Triggers {
7+
[CustomEntity("SpringCollab2020/ColorGradeFadeTrigger")]
8+
[Tracked]
9+
class ColorGradeFadeTrigger : Trigger {
10+
public static void Load() {
11+
On.Celeste.Level.Update += onLevelUpdate;
12+
}
13+
14+
public static void Unload() {
15+
On.Celeste.Level.Update -= onLevelUpdate;
16+
}
17+
18+
private static void onLevelUpdate(On.Celeste.Level.orig_Update orig, Level self) {
19+
orig(self);
20+
21+
// check if the player is in a color grade fade trigger
22+
Player player = self.Tracker.GetEntity<Player>();
23+
ColorGradeFadeTrigger trigger = player?.CollideFirst<ColorGradeFadeTrigger>();
24+
if (trigger != null) {
25+
DynData<Level> selfData = new DynData<Level>(self);
26+
27+
// the game fades from lastColorGrade to Session.ColorGrade using colorGradeEase as a lerp value.
28+
// let's hijack that!
29+
float positionLerp = trigger.GetPositionLerp(player, trigger.direction);
30+
if (positionLerp > 0.5f) {
31+
// we are closer to B. let B be the target color grade when player exits the trigger / dies in it
32+
selfData["lastColorGrade"] = trigger.colorGradeA;
33+
self.Session.ColorGrade = trigger.colorGradeB;
34+
selfData["colorGradeEase"] = positionLerp;
35+
} else {
36+
// we are closer to A. let A be the target color grade when player exits the trigger / dies in it
37+
selfData["lastColorGrade"] = trigger.colorGradeB;
38+
self.Session.ColorGrade = trigger.colorGradeA;
39+
selfData["colorGradeEase"] = 1 - positionLerp;
40+
}
41+
selfData["colorGradeEaseSpeed"] = 1f;
42+
}
43+
}
44+
45+
46+
private string colorGradeA;
47+
private string colorGradeB;
48+
private PositionModes direction;
49+
50+
public ColorGradeFadeTrigger(EntityData data, Vector2 offset) : base(data, offset) {
51+
colorGradeA = data.Attr("colorGradeA");
52+
colorGradeB = data.Attr("colorGradeB");
53+
direction = data.Enum<PositionModes>("direction");
54+
}
55+
}
56+
}

0 commit comments

Comments
 (0)