Skip to content

Commit 73bbf27

Browse files
authored
Merge pull request #160 from EverestAPI/strawberries_ignore_lighting
Added Ignore Lighting option to vanilla, bubble return and multi-room strawberries
2 parents fd367eb + 077f882 commit 73bbf27

File tree

7 files changed

+85
-2
lines changed

7 files changed

+85
-2
lines changed

Ahorn/entities/bubbleReturnBerry.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
using ..Ahorn, Maple
44

5-
@mapdef Entity "SpringCollab2020/returnBerry" ReturnBerry(x::Integer, y::Integer, order::Integer=-1, checkpointID::Integer=-1, winged::Bool=false, nodes::Array{Tuple{Integer, Integer}, 1}=Tuple{Integer, Integer}[])
5+
@mapdef Entity "SpringCollab2020/returnBerry" ReturnBerry(x::Integer, y::Integer, order::Integer=-1, checkpointID::Integer=-1, winged::Bool=false,
6+
nodes::Array{Tuple{Integer, Integer}, 1}=Tuple{Integer, Integer}[], SpringCollab2020_ignoreLighting::Bool=false)
67

78
const placements = Ahorn.PlacementDict(
89
"Strawberry (With Return) (Spring Collab 2020)" => Ahorn.EntityPlacement(

Ahorn/entities/multiRoomStrawberry.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using ..Ahorn, Maple
44

55
@mapdef Entity "SpringCollab2020/MultiRoomStrawberry" MultiRoomStrawberry(x::Integer, y::Integer,
6-
name::String="multi_room_strawberry", winged::Bool=false, moon::Bool=false, checkpointID::Integer=-1, order::Integer=-1)
6+
name::String="multi_room_strawberry", winged::Bool=false, moon::Bool=false, checkpointID::Integer=-1, order::Integer=-1, SpringCollab2020_ignoreLighting::Bool=false)
77

88
const placements = Ahorn.PlacementDict(
99
"Multi-Room Strawberry (Spring Collab 2020)" => Ahorn.EntityPlacement(
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module SpringCollab2020StrawberryIgnoringLighting
2+
3+
using ..Ahorn, Maple
4+
5+
const placements = Ahorn.PlacementDict(
6+
"Strawberry (Ignore Lighting) (Spring Collab 2020)" => Ahorn.EntityPlacement(
7+
Maple.Strawberry,
8+
"point",
9+
Dict{String, Any}(
10+
"SpringCollab2020_ignoreLighting" => true
11+
)
12+
)
13+
)
14+
15+
end

Ahorn/lang/en_gb.lang

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ placements.entities.SpringCollab2020/diagonalWingedStrawberry.tooltips.checkpoin
66
placements.entities.SpringCollab2020/returnBerry.tooltips.winged=Flies away upon dashing.
77
placements.entities.SpringCollab2020/returnBerry.tooltips.checkpointID=Manually determine what checkpoint section strawberries are visually grouped up in, showing up on the start menu during gameplay and level select. Overrides Everest's automatic berry IDs. (Default = -1)
88
placements.entities.SpringCollab2020/returnBerry.tooltips.order=Manually determine what order strawberries are visually placed in on the start menu during gameplay and level select. Overrides Everest's automatic berry IDs. (Default = -1)
9+
placements.entities.SpringCollab2020/returnBerry.names.SpringCollab2020_ignoreLighting=Ignore Lighting
10+
placements.entities.SpringCollab2020/returnBerry.tooltips.SpringCollab2020_ignoreLighting=(Spring Collab 2020 attribute) If checked, the berry will appear bright at all times, even if the room is dark.
911

1012
# Glass Berry
1113
placements.entities.SpringCollab2020/glassBerry.tooltips.checkpointID=Manually determine what checkpoint section strawberries are visually grouped up in, showing up on the start menu during gameplay and level select. Overrides Everest's automatic berry IDs. (Default = -1)
@@ -187,6 +189,12 @@ placements.entities.SpringCollab2020/MultiRoomStrawberry.tooltips.winged=The str
187189
placements.entities.SpringCollab2020/MultiRoomStrawberry.tooltips.checkpointID=Manually determine what checkpoint section strawberries are visually grouped up in, showing up on the start menu during gameplay and level select. Overrides Everest's automatic berry IDs. (Default= -1)
188190
placements.entities.SpringCollab2020/MultiRoomStrawberry.tooltips.order=Manually determine what order strawberries are visually placed in on the start menu during gameplay and level select. Overrides Everest's automatic berry IDs. (Default= -1)
189191
placements.entities.SpringCollab2020/MultiRoomStrawberry.tooltips.moon=Makes the strawberry render as a space berry.\nDoes not work with wings or nodes in the base game.
192+
placements.entities.SpringCollab2020/MultiRoomStrawberry.names.SpringCollab2020_ignoreLighting=Ignore Lighting
193+
placements.entities.SpringCollab2020/MultiRoomStrawberry.tooltips.SpringCollab2020_ignoreLighting=(Spring Collab 2020 attribute) If checked, the berry will appear bright at all times, even if the room is dark.
194+
195+
# Strawberry ignoring lighting
196+
placements.entities.strawberry.names.SpringCollab2020_ignoreLighting=Ignore Lighting
197+
placements.entities.strawberry.tooltips.SpringCollab2020_ignoreLighting=(Spring Collab 2020 attribute) If checked, the berry will appear bright at all times, even if the room is dark.
190198

191199
# Madeline Silhouette Trigger
192200
placements.triggers.SpringCollab2020/MadelineSilhouetteTrigger.tooltips.enable=If checked, the trigger will turn Madeline into a silhouette. If unchecked, it will turn Madeline back to normal.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using Microsoft.Xna.Framework;
2+
using Microsoft.Xna.Framework.Graphics;
3+
using Monocle;
4+
using MonoMod.Utils;
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Text;
9+
using System.Threading.Tasks;
10+
11+
namespace Celeste.Mod.SpringCollab2020.Entities {
12+
/// <summary>
13+
/// This class adds a custom attribute to vanilla strawberries. This is not a new entity.
14+
/// </summary>
15+
class StrawberryIgnoringLighting {
16+
private static MTexture strawberryCutoutTexture;
17+
18+
public static void Load() {
19+
On.Celeste.Strawberry.ctor += onStrawberryConstructor;
20+
On.Celeste.LightingRenderer.BeforeRender += onLightingBeforeRender;
21+
}
22+
23+
public static void LoadContent() {
24+
strawberryCutoutTexture = GFX.Game["collectables/SpringCollab2020/strawberry/cutout"];
25+
}
26+
27+
public static void Unload() {
28+
On.Celeste.Strawberry.ctor -= onStrawberryConstructor;
29+
On.Celeste.LightingRenderer.BeforeRender -= onLightingBeforeRender;
30+
}
31+
32+
private static void onStrawberryConstructor(On.Celeste.Strawberry.orig_ctor orig, Strawberry self, EntityData data, Vector2 offset, EntityID gid) {
33+
orig(self, data, offset, gid);
34+
35+
// save the value for SpringCollab2020_ignoreLighting to the DynData for the strawberry.
36+
new DynData<Strawberry>(self)["SpringCollab2020_ignoreLighting"] = data.Bool("SpringCollab2020_ignoreLighting");
37+
}
38+
39+
private static void onLightingBeforeRender(On.Celeste.LightingRenderer.orig_BeforeRender orig, LightingRenderer self, Scene scene) {
40+
orig(self, scene);
41+
42+
Draw.SpriteBatch.GraphicsDevice.SetRenderTarget(GameplayBuffers.Light);
43+
Draw.SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullNone, null, Matrix.Identity);
44+
foreach (Entity entity in scene.Entities) {
45+
if (entity is Strawberry berry) {
46+
DynData<Strawberry> berryData = new DynData<Strawberry>(berry);
47+
if (berryData.Get<bool>("SpringCollab2020_ignoreLighting")) {
48+
Draw.SpriteBatch.Draw(strawberryCutoutTexture.Texture.Texture, berry.Position + berryData.Get<Sprite>("sprite").Position - (scene as Level).Camera.Position
49+
- new Vector2(9, 8), Color.White);
50+
}
51+
}
52+
}
53+
Draw.SpriteBatch.End();
54+
}
55+
}
56+
}
197 Bytes
Loading

SpringCollab2020Module.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,13 @@ public override void Load() {
3030
MultiRoomStrawberrySeed.Load();
3131
MadelineSilhouetteTrigger.Load();
3232
BlockJellySpawnTrigger.Load();
33+
StrawberryIgnoringLighting.Load();
3334
}
3435

3536
public override void LoadContent(bool firstLoad) {
3637
base.LoadContent(firstLoad);
3738
GlassBerry.LoadContent();
39+
StrawberryIgnoringLighting.LoadContent();
3840
}
3941

4042
public override void Unload() {
@@ -54,6 +56,7 @@ public override void Unload() {
5456
MultiRoomStrawberrySeed.Unload();
5557
MadelineSilhouetteTrigger.Unload();
5658
BlockJellySpawnTrigger.Unload();
59+
StrawberryIgnoringLighting.Unload();
5760
}
5861

5962
public override void PrepareMapDataProcessors(MapDataFixup context) {

0 commit comments

Comments
 (0)