-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiscoGoose.cs
55 lines (44 loc) · 1.68 KB
/
DiscoGoose.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
using GooseShared;
using SamEngine;
using System.Drawing;
using DiscoGoose.Data;
namespace DiscoGoose
{
public class DiscoGoose : IMod
{
public static DiscoConfig Config;
public RainbowRender bodyRainbow;
public RainbowRender beakAndFeetRainbow;
private float nextChangeTime = -1f;
// Gets called automatically, passes in a class that contains pointers to
// useful functions we need to interface with the goose.
void IMod.Init()
{
Config = DiscoConfig.GetConfig();
// Subscribe to whatever events we want
InjectionPoints.PreRenderEvent += new InjectionPoints.PreRenderEventHandler(PreRenderEvent);
bodyRainbow = new RainbowRender();
beakAndFeetRainbow = new RainbowRender();
if (Config.RandomizeStartColor)
{
bodyRainbow = new RainbowRender(randomizeColor: true);
beakAndFeetRainbow = new RainbowRender(randomizeColor: true);
}
if (Config.SeparateOrangesFromWhites)
{
beakAndFeetRainbow = new RainbowRender(bodyRainbow.AsColor());
}
}
public void PreRenderEvent(GooseEntity goose, Graphics gfx)
{
if (Time.time >= nextChangeTime)
{
bodyRainbow.UpdateColor();
beakAndFeetRainbow.UpdateColor();
goose.renderData.brushGooseWhite.Color = bodyRainbow.AsColor();
goose.renderData.brushGooseOrange.Color = beakAndFeetRainbow.AsColor();
nextChangeTime = Time.time + Config.ColorSpeed;
}
}
}
}