Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ScreenDarkness.cs
Go to the documentation of this file.
3
5
6public class ScreenDarkness
7{
8 public static float screenObstruction;
9
10 public static Color frontColor = new Color(0, 0, 120);
11
12 public static void Update()
13 {
14 float value = 0f;
15 float amount = 1f / 60f;
16 Vector2 mountedCenter = Main.player[Main.myPlayer].MountedCenter;
17 for (int i = 0; i < 200; i++)
18 {
19 if (Main.npc[i].active && Main.npc[i].type == 370 && Main.npc[i].Distance(mountedCenter) < 3000f && (Main.npc[i].ai[0] >= 10f || (Main.npc[i].ai[0] == 9f && Main.npc[i].ai[2] > 120f)))
20 {
21 value = 0.95f;
22 frontColor = new Color(0, 0, 120) * 0.3f;
23 amount = 0.03f;
24 }
25 if (Main.npc[i].active && Main.npc[i].type == 113 && Main.npc[i].Distance(mountedCenter) < 3000f)
26 {
27 float num = Utils.Remap(Main.npc[i].Distance(mountedCenter), 2000f, 3000f, 1f, 0f);
28 value = Main.npc[i].localAI[1] * num;
29 amount = 1f;
31 }
32 }
34 }
35
36 public static void DrawBack(SpriteBatch spriteBatch)
37 {
38 if (screenObstruction != 0f)
39 {
40 Color color = Color.Black * screenObstruction;
41 spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle(0, 0, 1, 1), color);
42 }
43 }
44
45 public static void DrawFront(SpriteBatch spriteBatch)
46 {
47 if (screenObstruction != 0f)
48 {
50 spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(-2, -2, Main.screenWidth + 4, Main.screenHeight + 4), new Rectangle(0, 0, 1, 1), color);
51 }
52 }
53}
void Draw(Texture2D texture, Vector2 position, Color color)
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static void DrawBack(SpriteBatch spriteBatch)
static void DrawFront(SpriteBatch spriteBatch)
static Asset< Texture2D > MagicPixel
static int myPlayer
Definition Main.cs:1801
static int screenHeight
Definition Main.cs:1721
static NPC[] npc
Definition Main.cs:1685
static int screenWidth
Definition Main.cs:1719
static Player[] player
Definition Main.cs:1803
static float Remap(float fromValue, float fromMin, float fromMax, float toMin, float toMax, bool clamped=true)
Definition Utils.cs:233