Skip to content

Commit a821292

Browse files
authored
Merge pull request #31 from earthwise01/more-custom-snow-options
particle count + alpha options for custom snow
2 parents 711797e + 3ab4397 commit a821292

File tree

6 files changed

+44
-12
lines changed

6 files changed

+44
-12
lines changed

Ahorn/effects/maxHelpingHandSnowCustomColors.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
using ..Ahorn, Maple
44

5-
@mapdef Effect "MaxHelpingHand/SnowCustomColors" SnowCustomColors(only::String="*", exclude::String="", colors::String="FF0000,00FF00,0000FF", speedMin::Number=40.0, speedMax::Number=100.0)
5+
@mapdef Effect "MaxHelpingHand/SnowCustomColors" SnowCustomColors(only::String="*", exclude::String="", colors::String="FF0000,00FF00,0000FF", speedMin::Number=40.0, speedMax::Number=100.0, alpha::Number=1.0, particleCount::Integer=60)
66

77
placements = SnowCustomColors
88

Ahorn/lang/en_gb.lang

+3-1
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,11 @@ placements.entities.MaxHelpingHand/KevinBarrier.tooltips.flashOnHit=Determines w
502502
placements.entities.MaxHelpingHand/KevinBarrier.tooltips.invisible=If checked, the Kevin barrier will be invisible (doesn't apply to the flashing).
503503

504504
# Snow with Custom Colors
505-
placements.effects.MaxHelpingHand/SnowCustomColors.tooltips.colors=Comma-separated list of all colors the particles can take from.
505+
placements.effects.MaxHelpingHand/SnowCustomColors.tooltips.colors=Comma-separated list of all colors the particles can take from.\nVanilla uses 333333,19337F for background snow, FFFFFF,6495ED for foreground snow.
506506
placements.effects.MaxHelpingHand/SnowCustomColors.tooltips.speedMin=The minimum speed a snowflake can have. Vanilla uses 40 for background snow, 120 for foreground snow.
507507
placements.effects.MaxHelpingHand/SnowCustomColors.tooltips.speedMax=The maximum speed a snowflake can have. Vanilla uses 100 for background snow, 300 for foreground snow.
508+
placements.effects.MaxHelpingHand/SnowCustomColors.tooltips.alpha=The alpha of the snow particles.
509+
placements.effects.MaxHelpingHand/SnowCustomColors.tooltips.particleCount=The number of snow particles to render. Vanilla uses 60.
508510

509511
# Customizable Glass Block
510512
placements.entities.MaxHelpingHand/CustomizableGlassBlock.tooltips.behindFgTiles=Whether the glass block outline should appear behind foreground tiles.

Effects/SnowCustomColors.cs

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,24 @@
55

66
namespace Celeste.Mod.MaxHelpingHand.Effects {
77
public class SnowCustomColors : Snow {
8-
private static MethodInfo particleInit = typeof(Snow).GetNestedType("Particle", BindingFlags.NonPublic).GetMethod("Init");
8+
private static readonly Type particleType = typeof(Snow).GetNestedType("Particle", BindingFlags.NonPublic);
9+
private static readonly MethodInfo particleInit = particleType.GetMethod("Init");
910

10-
public SnowCustomColors(Color[] colors, float speedMin, float speedMax) : base(false) {
11-
DynData<Snow> selfData = new DynData<Snow>(this);
11+
public SnowCustomColors(Color[] colors, float speedMin, float speedMax, int particleCount) : base(false) {
12+
var selfData = new DynData<Snow>(this);
1213

1314
// redo the same operations as the vanilla constructor, but with our custom set of colors.
1415
selfData["colors"] = colors;
1516
selfData["blendedColors"] = new Color[colors.Length];
16-
Array particles = selfData.Get<Array>("particles");
17+
18+
// recreate the particles array with the correct length
19+
var particles = Array.CreateInstance(particleType, particleCount);
20+
selfData["particles"] = particles;
21+
1722
for (int i = 0; i < particles.Length; i++) {
1823
// Particle is a private struct, so getting it gets a copy that we should set back afterwards.
19-
object particle = particles.GetValue(i);
20-
particleInit.Invoke(particle, new object[] { colors.Length, speedMin, speedMax });
24+
var particle = particles.GetValue(i);
25+
particleInit.Invoke(particle, [colors.Length, speedMin, speedMax]);
2126
particles.SetValue(particle, i);
2227
}
2328
}

Loenn/effects/snowCustomColors.lua

+23-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,29 @@ effect.canForeground = true
77
effect.defaultData = {
88
colors = "FF0000,00FF00,0000FF",
99
speedMin = 40.0,
10-
speedMax = 100.0
10+
speedMax = 100.0,
11+
alpha = 1.0,
12+
particleCount = 60
13+
}
14+
15+
effect.fieldInformation = {
16+
colors = {
17+
fieldType = "list",
18+
minimumElements = 1,
19+
elementDefault = "ffffff",
20+
elementOptions = {
21+
fieldType = "color",
22+
allowXNAColors = false
23+
}
24+
},
25+
alpha = {
26+
maximumValue = 1.0,
27+
minimumValue = 0.0
28+
},
29+
particleCount = {
30+
fieldType = "integer",
31+
minimumValue = 1
32+
}
1133
}
1234

1335
return effect

Loenn/lang/en_gb.lang

+3-1
Original file line numberDiff line numberDiff line change
@@ -1308,9 +1308,11 @@ style.effects.MaxHelpingHand/NorthernLightsCustomColors.description.strandCount=
13081308

13091309
# Snow with Custom Colors
13101310
style.effects.MaxHelpingHand/SnowCustomColors.name=Snow (Custom)
1311-
style.effects.MaxHelpingHand/SnowCustomColors.description.colors=Comma-separated list of all colors the particles can take from.
1311+
style.effects.MaxHelpingHand/SnowCustomColors.description.colors=Comma-separated list of all colors the particles can take from.\nVanilla uses 333333,19337F for background snow, FFFFFF,6495ED for foreground snow.
13121312
style.effects.MaxHelpingHand/SnowCustomColors.description.speedMin=The minimum speed a snowflake can have. Vanilla uses 40 for background snow, 120 for foreground snow.
13131313
style.effects.MaxHelpingHand/SnowCustomColors.description.speedMax=The maximum speed a snowflake can have. Vanilla uses 100 for background snow, 300 for foreground snow.
1314+
style.effects.MaxHelpingHand/SnowCustomColors.description.alpha=The alpha of the snow particles.
1315+
style.effects.MaxHelpingHand/SnowCustomColors.description.particleCount=The number of snow particles to render. Vanilla uses 60.
13141316

13151317
# Custom Bird Tutorial: extra "Show Hints" placement
13161318
entities.everest/customBirdTutorial.placements.name.maxhelpinghand_showhints=Custom Bird Tutorial (Show Hints)

Module/MaxHelpingHandModule.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,14 @@ private Backdrop onLoadBackdrop(MapData map, BinaryPacker.Element child, BinaryP
417417
return new CustomStarfield(paths, colors, alphas, child.AttrBool("shuffle", true), child.AttrFloat("speed", 1f));
418418
}
419419
if (child.Name.Equals("MaxHelpingHand/SnowCustomColors", StringComparison.OrdinalIgnoreCase)) {
420+
float alpha = child.AttrFloat("alpha", 1f);
420421
string[] colorsAsStrings = child.Attr("colors").Split(',');
421422
Color[] colors = new Color[colorsAsStrings.Length];
422423
for (int i = 0; i < colors.Length; i++) {
423-
colors[i] = Calc.HexToColor(colorsAsStrings[i]);
424+
colors[i] = Calc.HexToColor(colorsAsStrings[i]) * alpha;
424425
}
425426

426-
return new SnowCustomColors(colors, child.AttrFloat("speedMin", 40f), child.AttrFloat("speedMax", 100f));
427+
return new SnowCustomColors(colors, child.AttrFloat("speedMin", 40f), child.AttrFloat("speedMax", 100f), child.AttrInt("particleCount", 60));
427428
}
428429
if (child.Name.Equals("MaxHelpingHand/NorthernLightsCustomColors", StringComparison.OrdinalIgnoreCase)) {
429430
string[] colorsAsStrings = child.Attr("colors").Split(',');

0 commit comments

Comments
 (0)