Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
ChromaEngine.cs
Go to the documentation of this file.
1using System;
3using System.Linq;
6using Microsoft.Xna.Framework.Input;
8
10
11public class ChromaEngine
12{
13 private readonly ChromaPipeline _pipeline = new ChromaPipeline();
14
16
17 private readonly HotkeyCollection _hotkeys = new HotkeyCollection();
18
20
21 private readonly object _updateLock = new object();
22
23 private float _lastTime;
24
25 public float FrameTimeInSeconds { get; set; }
26
28
29 public ChromaEngine()
30 {
32 FrameTimeInSeconds = 1f / 45f;
33 }
34
35 public void AddDeviceGroup(string name, RgbDeviceGroup deviceGroup)
36 {
38 {
40 }
41 }
42
43 public bool HasDeviceGroup(string name)
44 {
45 return _deviceGroups.ContainsKey(name);
46 }
47
48 public void RemoveDeviceGroup(string name)
49 {
52 {
53 if (rgbDeviceGroup.IsEnabled)
54 {
55 rgbDeviceGroup.Disable();
56 }
58 }
59 }
60
61 public void EnableDeviceGroup(string name)
62 {
65 {
66 if (!rgbDeviceGroup.IsEnabled)
67 {
68 rgbDeviceGroup.Enable();
69 }
70 }
71 }
72
73 public void DisableDeviceGroup(string name)
74 {
77 {
78 if (rgbDeviceGroup.IsEnabled)
79 {
80 rgbDeviceGroup.Disable();
81 }
82 }
83 }
84
86 {
88 {
90 {
91 item.Enable();
92 }
93 }
94 }
95
97 {
99 {
101 {
102 item.Disable();
103 }
104 }
105 }
106
108 {
110 {
112 {
113 item.LoadSpecialRules(specialRulesObject);
114 }
115 }
116 }
117
118 public bool IsDeviceGroupEnabled(string name)
119 {
120 return _deviceGroups[name].IsEnabled;
121 }
122
124 {
126 {
127 _shaderSelector.Register(shader, condition, layer);
128 }
129 }
130
131 public void UnregisterShader(ChromaShader shader)
132 {
134 {
136 }
137 }
138
139 public RgbKey BindKey(Keys key, string keyTriggerName)
140 {
141 //IL_0017: Unknown result type (might be due to invalid IL or missing references)
143 {
145 }
146 }
147
148 public void UnbindKey(Keys key)
149 {
150 //IL_0017: Unknown result type (might be due to invalid IL or missing references)
152 {
154 }
155 }
156
157 public void DebugDraw(IDebugDrawer drawer, Vector2 position, float scale)
158 {
159 //IL_002b: Unknown result type (might be due to invalid IL or missing references)
161 {
162 bool flag = false;
163 foreach (RgbDevice item in value)
164 {
165 item.DebugDraw(drawer, position, scale);
166 flag = true;
167 }
168 if (flag)
169 {
170 position.Y += 1.2f * scale;
171 }
172 }
173 }
174
175 public void Update(float totalTime)
176 {
177 if (_deviceGroups.Count == 0)
178 {
179 return;
180 }
181 if (totalTime < _lastTime)
182 {
183 _lastTime = totalTime;
184 }
185 float num = totalTime - _lastTime;
187 {
188 return;
189 }
190 try
191 {
192 if (this.OnUpdate != null)
193 {
194 this.OnUpdate(this, new ChromaEngineUpdateEventArgs(num));
195 }
196 _hotkeys.UpdateAll(num);
198 _lastTime = totalTime;
200 {
201 ((ChromaEngine)context).Draw();
202 }, this);
203 }
204 catch
205 {
207 }
208 finally
209 {
211 }
212 }
213
214 private void Draw()
215 {
217 {
218 try
219 {
220 for (int i = 0; i <= 1; i++)
221 {
225 {
227 }
228 }
229 }
230 catch
231 {
233 }
235 {
236 value2.OnceProcessed();
237 }
238 }
239 }
240}
void UnregisterShader(ChromaShader shader)
RgbKey BindKey(Keys key, string keyTriggerName)
void RegisterShader(ChromaShader shader, ChromaCondition condition, ShaderLayer layer)
readonly HotkeyCollection _hotkeys
void AddDeviceGroup(string name, RgbDeviceGroup deviceGroup)
EventHandler< ChromaEngineUpdateEventArgs > OnUpdate
readonly Dictionary< string, RgbDeviceGroup > _deviceGroups
readonly ShaderSelector _shaderSelector
void LoadSpecialRules(object specialRulesObject)
void DebugDraw(IDebugDrawer drawer, Vector2 position, float scale)
readonly ChromaPipeline _pipeline
void SetHotkeys(IEnumerable< RgbKey > keys)
void Process(IEnumerable< RgbDevice > devices, IEnumerable< ShaderOperation > shaders, float time)
RgbKey BindKey(Keys key, string keyTriggerName)
EffectDetailLevel PreferredLevelOfDetail
Definition RgbDevice.cs:18
ICollection< ShaderOperation > AtDetailLevel(EffectDetailLevel quality)
void Unregister(ChromaShader shader)
void Register(ChromaShader shader, ChromaCondition condition, ShaderLayer layer)
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
static void Exit(object obj)
static bool TryEnter(object obj)
Definition Monitor.cs:36
static bool QueueUserWorkItem(WaitCallback callBack)