-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGreyPatch.cs
More file actions
82 lines (74 loc) · 3.31 KB
/
GreyPatch.cs
File metadata and controls
82 lines (74 loc) · 3.31 KB
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
82
using UnityEngine;
namespace GreyScreen
{
public static class GreyPatch
{
public static void Patch()
{
ColorMagic.GenerateColorUV();
//On.CustomDecal.DrawSprites += DecalPatch;
On.Water.DrawSprites += WaterPatch;
On.RoomCamera.ApplyFade += CameraFadePatch;
On.RainWorldGame.ExitGame += ExitGamePatch;
On.Menu.PauseMenu.ctor += PauseNoFade;
On.RoomCamera.DrawUpdate += RCDrawFreeze;
}
private static void DecalPatch(On.CustomDecal.orig_DrawSprites orig, CustomDecal self, RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
{
orig.Invoke(self, sLeaser, rCam, timeStacker, camPos);
if (GreyPlugin.mask) { sLeaser.sprites[0].alpha = 0f; }
else { sLeaser.sprites[0].alpha = 1f; }
}
private static void WaterPatch(On.Water.orig_DrawSprites orig, Water self, RoomCamera.SpriteLeaser sLeaser, RoomCamera rCam, float timeStacker, Vector2 camPos)
{
orig.Invoke(self, sLeaser, rCam, timeStacker, camPos);
if (GreyPlugin.mask) { sLeaser.sprites[1].isVisible = false; }
else { sLeaser.sprites[1].isVisible = !rCam.voidSeaMode; }
}
private static void CameraFadePatch(On.RoomCamera.orig_ApplyFade orig, RoomCamera self)
{
if (!GreyPlugin.mask) { orig.Invoke(self); return; }
foreach (GreyPlugin.CameraInfo info in GreyPlugin.infos)
{
if (info.camera == self)
{
typeof(RoomCamera).GetField("paletteTexture", GreyPlugin.flags).SetValue(self, info.tOrig);
orig.Invoke(self);
info.tOrig = (Texture2D)typeof(RoomCamera).GetField("paletteTexture", GreyPlugin.flags).GetValue(self);
typeof(RoomCamera).GetField("paletteTexture", GreyPlugin.flags).SetValue(self, info.pGrey.texture);
typeof(RoomCamera).GetMethod("ApplyPalette", GreyPlugin.flags).Invoke(self, new object[] { });
return;
}
}
orig.Invoke(self);
}
private static void ExitGamePatch(On.RainWorldGame.orig_ExitGame orig, RainWorldGame self, bool asDeath, bool asQuit)
{
orig.Invoke(self, asDeath, asQuit);
GreyPlugin.mask = false;
}
private static void PauseNoFade(On.Menu.PauseMenu.orig_ctor orig, Menu.PauseMenu self, ProcessManager manager, RainWorldGame game)
{
orig(self, manager, game);
if (GreyPlugin.mask || GreyPlugin.freeze) { self.blackSprite.isVisible = false; }
}
private static void RCDrawFreeze(On.RoomCamera.orig_DrawUpdate orig, RoomCamera self, float timeStacker, float timeSpeed)
{
if (GreyPlugin.freeze)
{
orig(self, timeStacker, 0f);
Shader.SetGlobalFloat("_cloudsSpeed", 0f);
}
else
{
orig(self, timeStacker, timeSpeed);
}
if (GreyPlugin.mask)
{
Shader.DisableKeyword("RoomHasDeathFall");
if (self.fullScreenEffect != null)
self.fullScreenEffect.alpha = 0f;
}
}
}
}