Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SkyManager.cs
Go to the documentation of this file.
4
6
7public class SkyManager : EffectManager<CustomSky>
8{
9 public static SkyManager Instance = new SkyManager();
10
11 private float _lastDepth;
12
14
15 public void Reset()
16 {
17 foreach (CustomSky value in _effects.Values)
18 {
19 value.Reset();
20 }
22 }
23
25 {
26 int num = Main.dayRate;
27 if (num < 1)
28 {
29 num = 1;
30 }
31 for (int i = 0; i < num; i++)
32 {
34 while (linkedListNode != null)
35 {
36 CustomSky value = linkedListNode.Value;
38 value.Update(gameTime);
39 if (!value.IsActive())
40 {
42 }
43 linkedListNode = next;
44 }
45 }
46 }
47
48 public void Draw(SpriteBatch spriteBatch)
49 {
50 DrawDepthRange(spriteBatch, float.MinValue, float.MaxValue);
51 }
52
53 public void DrawToDepth(SpriteBatch spriteBatch, float minDepth)
54 {
55 if (!(_lastDepth <= minDepth))
56 {
57 DrawDepthRange(spriteBatch, minDepth, _lastDepth);
59 }
60 }
61
62 public void DrawDepthRange(SpriteBatch spriteBatch, float minDepth, float maxDepth)
63 {
65 {
66 activeSky.Draw(spriteBatch, minDepth, maxDepth);
67 }
68 }
69
70 public void DrawRemainingDepth(SpriteBatch spriteBatch)
71 {
72 DrawDepthRange(spriteBatch, float.MinValue, _lastDepth);
73 _lastDepth = float.MinValue;
74 }
75
76 public void ResetDepthTracker()
77 {
78 _lastDepth = float.MaxValue;
79 }
80
81 public void SetStartingDepth(float depth)
82 {
83 _lastDepth = depth;
84 }
85
86 public override void OnActivate(CustomSky effect, Vector2 position)
87 {
88 _activeSkies.Remove(effect);
89 _activeSkies.AddLast(effect);
90 }
91
93 {
95 {
96 color = activeSky.OnTileColor(color);
97 }
98 return color;
99 }
100
101 public float ProcessCloudAlpha()
102 {
103 float num = 1f;
104 foreach (CustomSky activeSky in _activeSkies)
105 {
106 num *= activeSky.GetCloudAlpha();
107 }
108 return MathHelper.Clamp(num, 0f, 1f);
109 }
110}
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Draw(SpriteBatch spriteBatch)
Definition SkyManager.cs:48
void DrawToDepth(SpriteBatch spriteBatch, float minDepth)
Definition SkyManager.cs:53
void DrawRemainingDepth(SpriteBatch spriteBatch)
Definition SkyManager.cs:70
void Update(GameTime gameTime)
Definition SkyManager.cs:24
Color ProcessTileColor(Color color)
Definition SkyManager.cs:92
void DrawDepthRange(SpriteBatch spriteBatch, float minDepth, float maxDepth)
Definition SkyManager.cs:62
override void OnActivate(CustomSky effect, Vector2 position)
Definition SkyManager.cs:86
LinkedList< CustomSky > _activeSkies
Definition SkyManager.cs:13
static int dayRate
Definition Main.cs:746