Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
OverlayManager.cs
Go to the documentation of this file.
1using System;
5
7
8public class OverlayManager : EffectManager<Overlay>
9{
10 private const float OPACITY_RATE = 1f;
11
13
14 private int _overlayCount;
15
17 {
18 for (int i = 0; i < _activeOverlays.Length; i++)
19 {
21 }
22 }
23
24 public override void OnActivate(Overlay overlay, Vector2 position)
25 {
27 if (overlay.Mode == OverlayMode.FadeIn || overlay.Mode == OverlayMode.Active)
28 {
29 return;
30 }
31 if (overlay.Mode == OverlayMode.FadeOut)
32 {
35 }
36 else
37 {
38 overlay.Opacity = 0f;
39 }
40 if (linkedList.Count != 0)
41 {
42 foreach (Overlay item in linkedList)
43 {
44 item.Mode = OverlayMode.FadeOut;
45 }
46 }
47 linkedList.AddLast(overlay);
49 }
50
52 {
53 for (int i = 0; i < _activeOverlays.Length; i++)
54 {
56 while (linkedListNode != null)
57 {
60 value.Update(gameTime);
61 switch (value.Mode)
62 {
63 case OverlayMode.Active:
64 value.Opacity = Math.Min(1f, value.Opacity + (float)gameTime.ElapsedGameTime.TotalSeconds * 1f);
65 break;
66 case OverlayMode.FadeIn:
67 value.Opacity += (float)gameTime.ElapsedGameTime.TotalSeconds * 1f;
68 if (value.Opacity >= 1f)
69 {
70 value.Opacity = 1f;
71 value.Mode = OverlayMode.Active;
72 }
73 break;
74 case OverlayMode.FadeOut:
75 value.Opacity -= (float)gameTime.ElapsedGameTime.TotalSeconds * 1f;
76 if (value.Opacity <= 0f)
77 {
78 value.Opacity = 0f;
79 value.Mode = OverlayMode.Inactive;
82 }
83 break;
84 }
85 linkedListNode = next;
86 }
87 }
88 }
89
90 public void Draw(SpriteBatch spriteBatch, RenderLayers layer)
91 {
92 if (_overlayCount == 0)
93 {
94 return;
95 }
96 bool flag = false;
97 for (int i = 0; i < _activeOverlays.Length; i++)
98 {
100 {
102 if (value.Layer == layer && value.IsVisible())
103 {
104 if (!flag)
105 {
107 flag = true;
108 }
109 value.Draw(spriteBatch);
110 }
111 }
112 }
113 if (flag)
114 {
115 spriteBatch.End();
116 }
117 }
118}
static readonly BlendState AlphaBlend
Definition BlendState.cs:36
static readonly SamplerState LinearClamp
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
static string[] GetNames(Type enumType)
Definition Enum.cs:295
static byte Min(byte val1, byte val2)
Definition Math.cs:912
void Draw(SpriteBatch spriteBatch, RenderLayers layer)
override void OnActivate(Overlay overlay, Vector2 position)
static Matrix Transform
Definition Main.cs:2771