Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SandstormSky.cs
Go to the documentation of this file.
1using System;
7
9
10public class SandstormSky : CustomSky
11{
13
14 private bool _isActive;
15
16 private bool _isLeaving;
17
18 private float _opacity;
19
20 public override void OnLoad()
21 {
22 }
23
24 public override void Update(GameTime gameTime)
25 {
27 {
28 return;
29 }
30 if (_isLeaving)
31 {
32 _opacity -= (float)gameTime.ElapsedGameTime.TotalSeconds;
33 if (_opacity < 0f)
34 {
35 _isActive = false;
36 _opacity = 0f;
37 }
38 }
39 else
40 {
41 _opacity += (float)gameTime.ElapsedGameTime.TotalSeconds;
42 if (_opacity > 1f)
43 {
44 _opacity = 1f;
45 }
46 }
47 }
48
49 public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
50 {
51 if (minDepth < 1f || maxDepth == float.MaxValue)
52 {
53 float num = Math.Min(1f, Sandstorm.Severity * 1.5f);
54 Color color = new Color(new Vector4(0.85f, 0.66f, 0.33f, 1f) * 0.8f * Main.ColorOfTheSkies.ToVector4()) * _opacity * num;
55 spriteBatch.Draw(TextureAssets.MagicPixel.Value, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), color);
56 }
57 }
58
59 public override void Activate(Vector2 position, params object[] args)
60 {
61 _isActive = true;
62 _isLeaving = false;
63 }
64
65 public override void Deactivate(params object[] args)
66 {
67 _isLeaving = true;
68 }
69
70 public override void Reset()
71 {
72 _opacity = 0f;
73 _isActive = false;
74 }
75
76 public override bool IsActive()
77 {
78 return _isActive;
79 }
80}
void Draw(Texture2D texture, Vector2 position, Color color)
static byte Min(byte val1, byte val2)
Definition Math.cs:912
override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth)
override void Update(GameTime gameTime)
override void Activate(Vector2 position, params object[] args)
override void Deactivate(params object[] args)
static Asset< Texture2D > MagicPixel
static Microsoft.Xna.Framework.Color ColorOfTheSkies
Definition Main.cs:2577
static bool hasFocus
Definition Main.cs:1781
static int screenHeight
Definition Main.cs:1721
static int screenWidth
Definition Main.cs:1719
static bool gamePaused
Definition Main.cs:1072