-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathExtensionSequencerExe.cs
360 lines (333 loc) · 11.7 KB
/
ExtensionSequencerExe.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
using System;
using System.Collections.Generic;
using Hacknet.Effects;
using Hacknet.Extensions;
using Hacknet.Gui;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Media;
namespace Hacknet
{
// Token: 0x0200006D RID: 109
internal class ExtensionSequencerExe : ExeModule
{
// Token: 0x06000222 RID: 546 RVA: 0x0001E424 File Offset: 0x0001C624
public ExtensionSequencerExe(Rectangle location, OS operatingSystem, string[] p) : base(location, operatingSystem)
{
this.name = "ESequencer";
this.ramCost = ExtensionSequencerExe.ACTIVATING_RAM_COST;
this.IdentifierName = "ESequencer";
this.targetIP = this.os.thisComputer.ip;
this.bars.MinLineChangeTime = 1f;
this.bars.MaxLineChangeTime = 3f;
this.beatDropTime = (double)ExtensionLoader.ActiveExtensionInfo.SequencerSpinUpTime;
}
// Token: 0x06000223 RID: 547 RVA: 0x0001E500 File Offset: 0x0001C700
public override void LoadContent()
{
base.LoadContent();
this.nodeeffects.Add(new ConnectedNodeEffect(this.os, true));
this.nodeeffects.Add(new ConnectedNodeEffect(this.os, true));
this.nodeeffects.Add(new ConnectedNodeEffect(this.os, true));
this.nodeeffects.Add(new ConnectedNodeEffect(this.os, true));
this.nodeeffects.Add(new ConnectedNodeEffect(this.os, true));
this.targetID = ExtensionLoader.ActiveExtensionInfo.SequencerTargetID;
this.flagForProgressionName = ExtensionLoader.ActiveExtensionInfo.SequencerFlagRequiredForStart;
}
// Token: 0x06000224 RID: 548 RVA: 0x0001E5B0 File Offset: 0x0001C7B0
public override void Update(float t)
{
base.Update(t);
if (!this.HasBeenKilled)
{
this.bars.Update(t);
this.UpdateRamCost(t);
this.stateTimer += t;
if (this.isExiting)
{
this.os.netMap.DimNonConnectedNodes = false;
}
bool flag = true;
if (!string.IsNullOrWhiteSpace(this.flagForProgressionName))
{
string[] array = this.flagForProgressionName.Split(Utils.newlineDelim, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < array.Length; i++)
{
flag &= (this.os.Flags.HasFlag(this.flagForProgressionName) || Settings.debugCommandsEnabled);
}
}
switch (this.state)
{
case ExtensionSequencerExe.SequencerExeState.Unavaliable:
if (flag)
{
this.state = ExtensionSequencerExe.SequencerExeState.AwaitingActivation;
}
else
{
this.bars.MinLineChangeTime = 1f;
this.bars.MaxLineChangeTime = 3f;
}
break;
case ExtensionSequencerExe.SequencerExeState.AwaitingActivation:
if (!flag)
{
this.state = ExtensionSequencerExe.SequencerExeState.Unavaliable;
}
break;
case ExtensionSequencerExe.SequencerExeState.SpinningUp:
if (MediaPlayer.State == MediaState.Playing)
{
if (MediaPlayer.PlayPosition.TotalSeconds >= this.beatDropTime && (double)this.stateTimer > this.beatDropTime - 0.5)
{
this.MoveToActiveState();
}
}
else if (this.stateTimer > ExtensionLoader.ActiveExtensionInfo.SequencerSpinUpTime)
{
this.MoveToActiveState();
}
break;
case ExtensionSequencerExe.SequencerExeState.Active:
{
float num = 2.5f;
if (this.stateTimer < num)
{
double num2 = MediaPlayer.PlayPosition.TotalSeconds - this.beatDropTime;
if (num2 % (double)this.beatHits < 0.009999999776482582)
{
this.os.warningFlash();
}
}
this.ActiveStateUpdate(t);
break;
}
}
}
}
// Token: 0x06000225 RID: 549 RVA: 0x0001E7DC File Offset: 0x0001C9DC
private void ActiveStateUpdate(float t)
{
double num = (double)this.stateTimer;
double num2 = num - this.beatDropTime;
if (num2 % (double)ExtensionSequencerExe.TimeBetweenBeats < (double)t)
{
this.os.warningFlash();
}
}
// Token: 0x06000226 RID: 550 RVA: 0x0001E81C File Offset: 0x0001CA1C
private void UpdateRamCost(float t)
{
if (this.targetRamUse != this.ramCost)
{
if (this.targetRamUse < this.ramCost)
{
this.ramCost -= (int)(t * ExtensionSequencerExe.RAM_CHANGE_PS);
if (this.ramCost < this.targetRamUse)
{
this.ramCost = this.targetRamUse;
}
}
else
{
int num = (int)(t * ExtensionSequencerExe.RAM_CHANGE_PS);
if (this.os.ramAvaliable >= num)
{
this.ramCost += num;
if (this.ramCost > this.targetRamUse)
{
this.ramCost = this.targetRamUse;
}
}
}
}
}
// Token: 0x06000227 RID: 551 RVA: 0x0001E968 File Offset: 0x0001CB68
public override void Killed()
{
base.Killed();
if (this.state == ExtensionSequencerExe.SequencerExeState.Active)
{
this.os.delayer.Post(ActionDelayer.NextTick(), delegate
{
ExtensionSequencerExe exe = new ExtensionSequencerExe(this.bounds, this.os, new string[0])
{
state = this.state,
stateTimer = this.stateTimer,
bounds = this.bounds,
oldSongName = this.oldSongName,
nodeeffects = this.nodeeffects,
ramCost = this.ramCost
};
this.os.addExe(exe);
});
}
else
{
this.os.netMap.DimNonConnectedNodes = false;
this.os.runCommand("disconnect");
if (this.targetComp != null)
{
this.os.netMap.visibleNodes.Remove(this.os.netMap.nodes.IndexOf(this.targetComp));
}
}
}
// Token: 0x06000228 RID: 552 RVA: 0x0001EA20 File Offset: 0x0001CC20
private void MoveToActiveState()
{
this.state = ExtensionSequencerExe.SequencerExeState.Active;
this.stateTimer = 0f;
this.targetRamUse = ExtensionSequencerExe.BASE_RAM_COST;
this.os.warningFlashTimer = OS.WARNING_FLASH_TIME;
this.os.netMap.DimNonConnectedNodes = true;
this.os.netMap.discoverNode(this.targetComp);
this.os.runCommand("connect " + this.targetComp.ip);
}
// Token: 0x06000229 RID: 553 RVA: 0x0001EAA4 File Offset: 0x0001CCA4
public override void Draw(float t)
{
base.Draw(t);
this.drawOutline();
this.drawTarget("app:");
Rectangle rectangle = base.GetContentAreaDest();
rectangle = Utils.InsetRectangle(rectangle, 1);
float num = this.os.warningFlashTimer / OS.WARNING_FLASH_TIME;
float num2 = 2f;
if (num > 0f)
{
num2 += num * ((float)rectangle.Height - num2);
}
Color drawColor = Color.Lerp(Utils.AddativeWhite * 0.5f, Utils.AddativeRed, num);
this.bars.Draw(this.spriteBatch, base.GetContentAreaDest(), num2, 4f, 1f, drawColor);
switch (this.state)
{
case ExtensionSequencerExe.SequencerExeState.Unavaliable:
{
this.spriteBatch.Draw(Utils.white, rectangle, Color.Black * 0.5f);
Rectangle rectangle2 = Utils.InsetRectangle(rectangle, 6);
if (!this.isExiting)
{
TextItem.doFontLabelToSize(rectangle2, "LINK UNAVAILABLE", GuiData.titlefont, Utils.AddativeWhite, false, false);
}
Rectangle destinationRectangle = rectangle2;
destinationRectangle.Y += destinationRectangle.Height - 20;
destinationRectangle.Height = 20;
if (!this.isExiting)
{
GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Black * 0.5f);
if (Button.doButton(32711803, destinationRectangle.X, destinationRectangle.Y, destinationRectangle.Width, destinationRectangle.Height, LocaleTerms.Loc("Exit"), new Color?(this.os.lockedColor)))
{
this.isExiting = true;
}
}
break;
}
case ExtensionSequencerExe.SequencerExeState.AwaitingActivation:
{
int num3 = 30;
Rectangle destinationRectangle2 = new Rectangle(this.bounds.X + 1, this.bounds.Y + this.bounds.Height / 2 - num3, this.bounds.Width - 2, num3 * 2);
this.spriteBatch.Draw(Utils.white, destinationRectangle2, Color.Black * 0.92f);
if (Button.doButton(8310101, this.bounds.X + 10, this.bounds.Y + this.bounds.Height / 2 - num3 / 2, this.bounds.Width - 20, num3, LocaleTerms.Loc("ACTIVATE"), new Color?(this.os.highlightColor)))
{
if (this.os.TraceDangerSequence.IsActive)
{
this.os.write("SEQUENCER ERROR: OS reports critical action already in progress.");
}
else
{
this.stateTimer = 0f;
this.state = ExtensionSequencerExe.SequencerExeState.SpinningUp;
this.bars.MinLineChangeTime = 0.1f;
this.bars.MaxLineChangeTime = 1f;
MusicManager.FADE_TIME = 0.6f;
this.oldSongName = MusicManager.currentSongName;
this.targetComp = Programs.getComputer(this.os, this.targetID);
WebServerDaemon webServerDaemon = (WebServerDaemon)this.targetComp.getDaemon(typeof(WebServerDaemon));
if (webServerDaemon != null)
{
webServerDaemon.LoadWebPage("index.html");
}
RunnableConditionalActions.LoadIntoOS(ExtensionLoader.ActiveExtensionInfo.ActionsToRunOnSequencerStart, this.os);
}
}
break;
}
case ExtensionSequencerExe.SequencerExeState.SpinningUp:
{
Rectangle bounds = rectangle;
bounds.Height = (int)((float)bounds.Height * (this.stateTimer / ExtensionLoader.ActiveExtensionInfo.SequencerSpinUpTime));
bounds.Y = rectangle.Y + rectangle.Height - bounds.Height + 1;
bounds.Width += 4;
this.bars.Draw(this.spriteBatch, bounds, num2, 4f, 1f, this.os.brightLockedColor);
break;
}
case ExtensionSequencerExe.SequencerExeState.Active:
this.spriteBatch.Draw(Utils.white, base.GetContentAreaDest(), Color.Black * 0.5f);
TextItem.doFontLabelToSize(base.GetContentAreaDest(), " G O G O G O ", GuiData.titlefont, Color.Lerp(Utils.AddativeRed, this.os.brightLockedColor, Math.Min(1f, this.stateTimer / 2f)), false, false);
this.DrawActiveState();
break;
}
}
// Token: 0x0600022A RID: 554 RVA: 0x0001EF20 File Offset: 0x0001D120
private void DrawActiveState()
{
float num = 5.2f;
float point = Math.Min(num, this.stateTimer) / num;
float num2 = 30f;
Vector2 value = new Vector2((float)this.os.netMap.bounds.X, (float)this.os.netMap.bounds.Y) + new Vector2((float)NetworkMap.NODE_SIZE / 2f);
for (int i = 0; i < this.nodeeffects.Count; i++)
{
float num3 = (float)(i + 1) / (float)(this.nodeeffects.Count + 1);
float num4 = 3f * num3;
float num5 = 1f - Utils.QuadraticOutCurve(Utils.QuadraticOutCurve(Utils.QuadraticOutCurve(point)));
this.nodeeffects[i].ScaleFactor = num3 * (num2 * num5) + num4;
this.nodeeffects[i].draw(this.spriteBatch, value + this.os.netMap.GetNodeDrawPos(this.targetComp));
}
}
// Token: 0x0400025C RID: 604
public static int ACTIVATING_RAM_COST = 170;
// Token: 0x0400025D RID: 605
public static int BASE_RAM_COST = 60;
// Token: 0x0400025E RID: 606
public static float RAM_CHANGE_PS = 100f;
// Token: 0x0400025F RID: 607
public static double Song_Length = 186.0;
// Token: 0x04000260 RID: 608
private static float TimeBetweenBeats = 1.832061f;
// Token: 0x04000261 RID: 609
private MovingBarsEffect bars = new MovingBarsEffect();
// Token: 0x04000262 RID: 610
private string targetID;
// Token: 0x04000263 RID: 611
private string flagForProgressionName;
// Token: 0x04000264 RID: 612
private string oldSongName = null;
// Token: 0x04000265 RID: 613
private int targetRamUse = ExtensionSequencerExe.ACTIVATING_RAM_COST;
// Token: 0x04000266 RID: 614
private float stateTimer = 0f;
// Token: 0x04000267 RID: 615
private float beatHits = 0.15f;
// Token: 0x04000268 RID: 616
private double beatDropTime = 16.64;
// Token: 0x04000269 RID: 617
private List<ConnectedNodeEffect> nodeeffects = new List<ConnectedNodeEffect>();
// Token: 0x0400026A RID: 618
private ExtensionSequencerExe.SequencerExeState state = ExtensionSequencerExe.SequencerExeState.Unavaliable;
// Token: 0x0400026B RID: 619
private Computer targetComp;
// Token: 0x0400026C RID: 620
private bool HasBeenKilled = false;
// Token: 0x0200006E RID: 110
private enum SequencerExeState
{
// Token: 0x0400026E RID: 622
Unavaliable,
// Token: 0x0400026F RID: 623
AwaitingActivation,
// Token: 0x04000270 RID: 624
SpinningUp,
// Token: 0x04000271 RID: 625
Active
}
}
}