Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DontStarveSeed.cs
Go to the documentation of this file.
1using System;
4
6
7public class DontStarveSeed
8{
9 public static void ModifyNightColor(ref Color bgColorToSet, ref Color moonColor)
10 {
11 if (Main.GetMoonPhase() != 0)
12 {
13 float fromValue = (float)(Main.time / 32400.0);
14 Color value = bgColorToSet;
15 Color black = Color.Black;
16 Color value2 = bgColorToSet;
17 float amount = Utils.Remap(fromValue, 0f, 0.5f, 0f, 1f);
18 float amount2 = Utils.Remap(fromValue, 0.5f, 1f, 0f, 1f);
19 Color color = Color.Lerp(Color.Lerp(value, black, amount), value2, amount2);
20 bgColorToSet = color;
21 }
22 }
23
24 public static void ModifyMinimumLightColorAtNight(ref byte minimalLight)
25 {
26 switch (Main.GetMoonPhase())
27 {
28 case MoonPhase.Empty:
29 minimalLight = 1;
30 break;
31 case MoonPhase.QuarterAtLeft:
32 case MoonPhase.QuarterAtRight:
33 minimalLight = 1;
34 break;
35 case MoonPhase.HalfAtLeft:
36 case MoonPhase.HalfAtRight:
37 minimalLight = 1;
38 break;
39 case MoonPhase.ThreeQuartersAtLeft:
40 case MoonPhase.ThreeQuartersAtRight:
41 minimalLight = 1;
42 break;
43 case MoonPhase.Full:
44 minimalLight = 45;
45 break;
46 }
47 if (Main.bloodMoon)
48 {
49 minimalLight = Utils.Max(new byte[2] { minimalLight, 35 });
50 }
51 }
52
53 public static void FixBiomeDarkness(ref Color bgColor, ref int R, ref int G, ref int B)
54 {
56 {
57 R = (byte)Math.Min(bgColor.R, R);
58 G = (byte)Math.Min(bgColor.G, G);
59 B = (byte)Math.Min(bgColor.B, B);
60 }
61 }
62
63 public static void Initialize()
64 {
65 Player.Hooks.OnEnterWorld += Hook_OnEnterWorld;
66 }
67
68 private static void Hook_OnEnterWorld(Player player)
69 {
70 player.UpdateStarvingState(withEmote: false);
71 }
72}
static byte Min(byte val1, byte val2)
Definition Math.cs:912
static void ModifyNightColor(ref Color bgColorToSet, ref Color moonColor)
static void FixBiomeDarkness(ref Color bgColor, ref int R, ref int G, ref int B)
static void Hook_OnEnterWorld(Player player)
static void ModifyMinimumLightColorAtNight(ref byte minimalLight)
static double time
Definition Main.cs:1284
static MoonPhase GetMoonPhase()
Definition Main.cs:3058
static bool bloodMoon
Definition Main.cs:1296
static bool dontStarveWorld
Definition Main.cs:345
void UpdateStarvingState(bool withEmote)
Definition Player.cs:11593
static float Remap(float fromValue, float fromMin, float fromMax, float toMin, float toMax, bool clamped=true)
Definition Utils.cs:233
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491