Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RgbKey.cs
Go to the documentation of this file.
1using System;
3using Microsoft.Xna.Framework.Input;
4
6
7public class RgbKey
8{
9 public readonly Keys Key;
10
11 public readonly string KeyTriggerName;
12
13 private float _timeRemaining;
14
15 private float _totalTime = 1f;
16
17 private float _effectRate = 1f;
18
19 public int CurrentIntegerRepresentation { get; private set; }
20
21 public RgbKeyEffect Effect { get; private set; }
22
23 public Color BaseColor { get; private set; }
24
25 public Color TargetColor { get; private set; }
26
27 public Color CurrentColor { get; private set; }
28
29 public bool IsVisible => Effect != RgbKeyEffect.Clear;
30
31 public RgbKey(Keys key, string keyTriggerName)
32 {
33 //IL_001d: Unknown result type (might be due to invalid IL or missing references)
34 //IL_001e: Unknown result type (might be due to invalid IL or missing references)
35 //IL_002b: Unknown result type (might be due to invalid IL or missing references)
36 //IL_0036: Unknown result type (might be due to invalid IL or missing references)
37 //IL_0041: Unknown result type (might be due to invalid IL or missing references)
38 Key = key;
39 KeyTriggerName = keyTriggerName;
43 Effect = RgbKeyEffect.Clear;
44 }
45
46 public void SetIntegerRepresentation(int integerValue)
47 {
48 CurrentIntegerRepresentation = integerValue;
49 }
50
51 public void FadeTo(Color targetColor, float time)
52 {
53 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
54 TargetColor = targetColor;
55 _timeRemaining = time;
56 _totalTime = time;
57 Effect = RgbKeyEffect.Fade;
58 }
59
60 public void SetFlashing(Color flashColor, float time, float flashesPerSecond = 1f)
61 {
62 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
63 TargetColor = flashColor;
64 _timeRemaining = time;
65 _totalTime = time;
66 _effectRate = flashesPerSecond;
67 Effect = RgbKeyEffect.Flashing;
68 }
69
70 public void SetFlashing(Color baseColor, Color flashColor, float time, float flashesPerSecond = 1f)
71 {
72 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
73 //IL_0008: Unknown result type (might be due to invalid IL or missing references)
74 SetBaseColor(baseColor);
75 SetFlashing(flashColor, time, flashesPerSecond);
76 }
77
78 public void SetBaseColor(Color color)
79 {
80 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
81 BaseColor = color;
82 }
83
84 public void SetTargetColor(Color color)
85 {
86 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
87 TargetColor = color;
88 }
89
90 public void SetSolid()
91 {
92 Effect = RgbKeyEffect.Solid;
93 }
94
95 public void SetSolid(Color color)
96 {
97 //IL_0001: Unknown result type (might be due to invalid IL or missing references)
98 BaseColor = color;
99 Effect = RgbKeyEffect.Solid;
100 }
101
102 public void Clear()
103 {
104 Effect = RgbKeyEffect.Clear;
105 }
106
107 internal void Update(float timeElapsed)
108 {
109 switch (Effect)
110 {
111 case RgbKeyEffect.Solid:
113 break;
114 case RgbKeyEffect.Fade:
116 break;
117 case RgbKeyEffect.Flashing:
119 break;
120 }
121 _timeRemaining = Math.Max(_timeRemaining - timeElapsed, 0f);
122 }
123
124 private void UpdateSolidEffect()
125 {
126 //IL_0002: Unknown result type (might be due to invalid IL or missing references)
128 }
129
130 private void UpdateFadeEffect()
131 {
132 //IL_0029: Unknown result type (might be due to invalid IL or missing references)
133 //IL_002f: Unknown result type (might be due to invalid IL or missing references)
134 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
135 float amount = 0f;
136 if (_totalTime > 0f)
137 {
138 amount = 1f - _timeRemaining / _totalTime;
139 }
141 }
142
143 private void UpdateFlashingEffect()
144 {
145 //IL_0029: Unknown result type (might be due to invalid IL or missing references)
146 //IL_002f: Unknown result type (might be due to invalid IL or missing references)
147 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
148 float amount = (float)Math.Sin(_timeRemaining * _effectRate * ((float)Math.PI * 2f)) * 0.5f + 0.5f;
150 }
151}
void Update(float timeElapsed)
Definition RgbKey.cs:107
void SetFlashing(Color baseColor, Color flashColor, float time, float flashesPerSecond=1f)
Definition RgbKey.cs:70
void FadeTo(Color targetColor, float time)
Definition RgbKey.cs:51
readonly string KeyTriggerName
Definition RgbKey.cs:11
RgbKey(Keys key, string keyTriggerName)
Definition RgbKey.cs:31
void SetTargetColor(Color color)
Definition RgbKey.cs:84
void SetFlashing(Color flashColor, float time, float flashesPerSecond=1f)
Definition RgbKey.cs:60
void SetBaseColor(Color color)
Definition RgbKey.cs:78
void SetSolid(Color color)
Definition RgbKey.cs:95
void SetIntegerRepresentation(int integerValue)
Definition RgbKey.cs:46
static double Sin(double a)
const double PI
Definition Math.cs:16
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491