-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCustomCrystalHeartHelper.cs
81 lines (73 loc) · 3.67 KB
/
CustomCrystalHeartHelper.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
using Celeste.Mod.CollabUtils2.UI;
using Microsoft.Xna.Framework;
using Monocle;
using MonoMod.Utils;
using System.Text.RegularExpressions;
namespace Celeste.Mod.CollabUtils2 {
class CustomCrystalHeartHelper {
internal static void Load() {
On.Celeste.HeartGem.Awake += customizeParticles;
On.Celeste.Poem.ctor += customizePoemDisplay;
}
internal static void Unload() {
On.Celeste.HeartGem.Awake -= customizeParticles;
On.Celeste.Poem.ctor -= customizePoemDisplay;
}
private static void customizeParticles(On.Celeste.HeartGem.orig_Awake orig, HeartGem self, Scene scene) {
orig(self, scene);
if (!self.IsGhost && LobbyHelper.IsHeartSide(self.SceneAs<Level>().Session.Area.GetSID())) {
// we are in a heartside: make the heart particles match the heart sprite.
DynData<HeartGem> selfData = new DynData<HeartGem>(self);
switch (selfData.Get<Sprite>("sprite").Texture.AtlasPath) {
case "collectables/heartGem/1/00":
selfData["shineParticle"] = HeartGem.P_RedShine;
break;
case "collectables/heartGem/2/00":
selfData["shineParticle"] = HeartGem.P_GoldShine;
break;
case "CollabUtils2/crystalHeart/expert/00":
selfData["shineParticle"] = new ParticleType(HeartGem.P_BlueShine) {
Color = Color.Orange
};
break;
case "CollabUtils2/crystalHeart/grandmaster/00":
selfData["shineParticle"] = new ParticleType(HeartGem.P_BlueShine) {
Color = Color.DarkViolet
};
break;
}
}
}
private static void customizePoemDisplay(On.Celeste.Poem.orig_ctor orig, Poem self, string text, int heartIndex, float heartAlpha) {
orig(self, text, heartIndex, heartAlpha);
string sid = (Engine.Scene as Level).Session.Area.GetSID();
if (InGameOverworldHelper.HeartSpriteBank.Has("crystalHeart_" + sid.DialogKeyify())) {
// we have a custom heart in our sprite bank, use it.
InGameOverworldHelper.HeartSpriteBank.CreateOn(self.Heart, "crystalHeart_" + sid.DialogKeyify());
self.Heart.Play("spin");
// and adjust the screen color to the heart.
DynData<Poem> selfData = new DynData<Poem>(self);
switch (self.Heart.Texture.AtlasPath) {
case "collectables/heartgem/1/spin00":
selfData["Color"] = Calc.HexToColor("ff668a");
break;
case "collectables/heartgem/2/spin00":
selfData["Color"] = Calc.HexToColor("D2AD01");
break;
case "CollabUtils2/crystalHeart/expert/spin00":
selfData["Color"] = Color.Orange;
break;
case "CollabUtils2/crystalHeart/grandmaster/spin00":
selfData["Color"] = Calc.HexToColor("d9a2ff");
break;
default:
Match match = Regex.Match(self.Heart.Texture.AtlasPath, "poemtextcolor_([0-9a-fA-F]{6})");
if (match.Success) {
selfData["Color"] = Calc.HexToColor(match.Groups[1].Value);
}
break;
}
}
}
}
}