-
Notifications
You must be signed in to change notification settings - Fork 1
/
SomezEffectPatch.cs
59 lines (50 loc) · 2 KB
/
SomezEffectPatch.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
using FezEngine.Effects;
using FezEngine.Effects.Structures;
using FezGame.Components;
using Microsoft.Xna.Framework;
using MonoMod.RuntimeDetour;
using System;
using System.Reflection;
namespace Sonez
{
public class SonezEffectPatch : GameComponent
{
private static IDetour GomezHostUpdateDetour;
public SonezEffectPatch(Game game) : base(game)
{
GomezHostUpdateDetour = new Hook(
typeof(GomezHost).GetMethod("Update"),
(Action<Action<GomezHost, GameTime>, GomezHost, GameTime>)delegate(Action<GomezHost, GameTime> original, GomezHost gomezHost, GameTime gameTime)
{
UpdateHooked(original, gomezHost, gameTime);
}
);
}
private void UpdateHooked(Action<GomezHost, GameTime> original, GomezHost gomezHost, GameTime gameTime)
{
original(gomezHost, gameTime);
var f = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static;
GomezEffect effect = gomezHost.GetType().GetField("effect", f).GetValue(gomezHost) as GomezEffect;
if (effect == null) return;
SemanticMappedVector3 blackSwap = effect.GetType().GetField("blackSwap", f).GetValue(effect) as SemanticMappedVector3;
switch (effect.ColorSwapMode)
{
case ColorSwapMode.VirtualBoy:
blackSwap.Set(new Vector3(101f / 255f, 1f / 255f, 0f));
break;
case ColorSwapMode.Gameboy:
blackSwap.Set(new Vector3(82f / 255f, 127f / 255f, 19f / 85f));
break;
case ColorSwapMode.Cmyk:
blackSwap.Set(new Vector3(0f, 92f / 255f, 127f / 255f));
break;
default:
break;
}
}
protected override void Dispose(bool disposing)
{
GomezHostUpdateDetour.Dispose();
}
}
}