forked from forkification/OpenHacknet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEndingSequenceModule.cs
More file actions
318 lines (294 loc) · 9.67 KB
/
EndingSequenceModule.cs
File metadata and controls
318 lines (294 loc) · 9.67 KB
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
using System;
using Hacknet.Effects;
using Hacknet.UIUtils;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
namespace Hacknet
{
// Token: 0x020000DC RID: 220
internal class EndingSequenceModule : Module
{
// Token: 0x06000469 RID: 1129 RVA: 0x00046BCC File Offset: 0x00044DCC
public EndingSequenceModule(Rectangle location, OS operatingSystem) : base(location, operatingSystem)
{
this.bounds = location;
this.creditsScroll = (float)(this.os.fullscreen.Height / 2);
this.spinUpEffect = this.os.content.Load<SoundEffect>("Music/Ambient/spiral_gauge_up");
this.traceDownEffect = this.os.content.Load<SoundEffect>("SFX/TraceKill");
this.BitSpeechText = Utils.readEntireFile("Content/Post/BitSpeech.txt");
}
// Token: 0x0600046A RID: 1130 RVA: 0x00046C98 File Offset: 0x00044E98
public override void Update(float t)
{
base.Update(t);
if (this.IsActive)
{
if (!this.IsInCredits)
{
if (this.waveRender == null)
{
this.traceDownEffect.Play();
this.speech = this.os.content.Load<SoundEffect>("SFX/Ending/EndingSpeech");
this.waveRender = new WaveformRenderer("Content/SFX/Ending/EndingSpeech.wav");
this.speechinstance = this.speech.CreateInstance();
this.speechinstance.IsLooped = false;
this.CreditsData = Utils.readEntireFile("Content/Post/CreditsData.txt").Split(Utils.newlineDelim, StringSplitOptions.None);
MusicManager.stop();
}
if (this.speechinstance.State == SoundState.Playing)
{
this.elapsedTime += t;
if (this.elapsedTime > (float)this.speech.Duration.TotalSeconds)
{
this.RollCredits();
}
else
{
this.SpeechTextTimer += t;
if (this.SpeechTextIndex < this.BitSpeechText.Length)
{
if (this.BitSpeechText[this.SpeechTextIndex] == '#')
{
if (this.SpeechTextTimer >= 1f)
{
this.SpeechTextTimer -= 1f;
this.SpeechTextIndex++;
}
}
else if (this.BitSpeechText[this.SpeechTextIndex] == '%')
{
if (this.SpeechTextTimer >= 0.5f)
{
this.SpeechTextTimer -= 0.5f;
this.SpeechTextIndex++;
}
}
else if (this.SpeechTextTimer >= 0.05f)
{
this.SpeechTextTimer -= 0.05f;
this.SpeechTextIndex++;
}
}
}
}
else
{
this.speechinstance.Play();
}
}
else
{
this.elapsedTime += t;
if (this.elapsedTime > this.HacknetTitleFreezeTime)
{
float num = Math.Min(1f, (this.elapsedTime - 10f) / 8f);
this.creditsScroll -= t * this.creditsPixelsScrollPerSecond * num;
}
}
}
}
// Token: 0x0600046B RID: 1131 RVA: 0x00046F4C File Offset: 0x0004514C
private void RollCredits()
{
if (this.os.TraceDangerSequence.IsActive)
{
this.os.TraceDangerSequence.CancelTraceDangerSequence();
}
this.IsInCredits = true;
if (this.speechinstance != null)
{
this.speechinstance.Stop();
}
Settings.soundDisabled = false;
this.elapsedTime = 0f;
this.os.delayer.Post(ActionDelayer.Wait(1.0), delegate
{
MusicManager.playSongImmediatley("Music\\Bit(Ending)");
MediaPlayer.IsRepeating = false;
AchievementsManager.Unlock("progress_complete", false);
});
PostProcessor.dangerModeEnabled = false;
PostProcessor.dangerModePercentComplete = 0f;
}
// Token: 0x0600046C RID: 1132 RVA: 0x00047004 File Offset: 0x00045204
public override void Draw(float t)
{
base.Draw(t);
Rectangle fullscreen = this.os.fullscreen;
this.spriteBatch.Draw(Utils.white, fullscreen, Color.Black);
if (this.waveRender != null)
{
if (!this.IsInCredits)
{
int width = this.os.fullscreen.Width;
int height = this.os.fullscreen.Height;
Rectangle bounds = new Rectangle(0, this.os.fullscreen.Height / 2 - height / 2, width, height);
this.waveRender.RenderWaveform((double)this.elapsedTime, this.speech.Duration.TotalSeconds, this.spriteBatch, bounds);
string[] array = this.BitSpeechText.Substring(0, this.SpeechTextIndex).Replace("#", "").Replace("%", "").Split(Utils.newlineDelim, StringSplitOptions.None);
Vector2 position = new Vector2((float)this.bounds.X + 150f, (float)(this.bounds.Y + this.bounds.Height) - 100f);
float num = 1f;
int num2 = array.Length - 1;
while (num2 >= 0 && num2 > array.Length - 5)
{
this.spriteBatch.DrawString(GuiData.smallfont, array[num2], position, Utils.AddativeWhite * num);
num *= 0.6f;
position.Y -= GuiData.ActiveFontConfig.tinyFontCharHeight + 8f;
num2--;
}
}
else
{
this.DrawCredits();
}
}
}
// Token: 0x0600046D RID: 1133 RVA: 0x000471D4 File Offset: 0x000453D4
private void DrawCredits()
{
float y = this.creditsScroll;
Vector2 value = new Vector2(0f, y);
int num = (int)((float)this.os.fullscreen.Width * 0.5f);
int num2 = (int)((float)this.os.fullscreen.Height * 0.4f);
Rectangle dest = new Rectangle(this.os.fullscreen.Width / 2 - num / 2, (int)(value.Y - (float)(num2 / 2)), num, num2);
Rectangle destinationRectangle = new Rectangle(this.os.fullscreen.X, dest.Y + 65, this.os.fullscreen.Width, dest.Height - 135);
bool flag = this.elapsedTime >= 1.71f;
if (flag)
{
this.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Lerp(Utils.AddativeRed, Color.Red, 0.2f + Utils.randm(0.05f)) * 0.5f);
FlickeringTextEffect.DrawLinedFlickeringText(dest, "HACKNET", 16f, 0.4f, GuiData.titlefont, this.os, Color.White, 5);
}
value.Y += (float)this.os.fullscreen.Height / 2f;
for (int i = 0; i < this.CreditsData.Length; i++)
{
float num3 = 20f;
string text = this.CreditsData[i];
if (!string.IsNullOrEmpty(text))
{
string text2 = text;
SpriteFont spriteFont = GuiData.font;
Color color = Color.White * 0.7f;
if (text.StartsWith("^"))
{
text2 = text.Substring(1);
color = Color.Gray * 0.6f;
}
else if (text.StartsWith("%"))
{
text2 = text.Substring(1);
spriteFont = GuiData.titlefont;
num3 = 90f;
}
if (text.StartsWith("$"))
{
text2 = text.Substring(1);
color = Color.Gray * 0.6f;
spriteFont = GuiData.smallfont;
}
Vector2 vector = spriteFont.MeasureString(text2);
Vector2 position = value + new Vector2((float)(this.os.fullscreen.Width / 2) - vector.X / 2f, 0f);
text2 = Utils.CleanStringToRenderable(text2);
this.spriteBatch.DrawString(spriteFont, text2, position, color);
value.Y += num3;
}
value.Y += num3;
}
if (value.Y < -500f)
{
this.CompleteAndReturnToMenu();
}
}
// Token: 0x0600046E RID: 1134 RVA: 0x000475A4 File Offset: 0x000457A4
private void CompleteAndReturnToMenu()
{
this.os.Flags.AddFlag("Victory");
Programs.disconnect(new string[0], this.os);
Computer computer = Programs.getComputer(this.os, "porthackHeart");
this.os.netMap.visibleNodes.Remove(this.os.netMap.nodes.IndexOf(computer));
computer.disabled = true;
computer.daemons.Clear();
computer.ip = NetworkMap.generateRandomIP();
this.os.terminal.inputLocked = false;
this.os.ram.inputLocked = false;
this.os.netMap.inputLocked = false;
this.os.DisableTopBarButtons = false;
this.os.canRunContent = true;
this.IsActive = false;
ComputerLoader.loadMission("Content/Missions/CreditsMission.xml", false);
this.os.threadedSaveExecute(false);
MediaPlayer.IsRepeating = true;
MusicManager.playSongImmediatley("Music\\Bit(Ending)");
if (Settings.isPirateBuild)
{
this.os.delayer.Post(ActionDelayer.Wait(15.0), delegate
{
try
{
ComputerLoader.loadMission("Content/Missions/CreditsMission_p.xml", false);
}
catch (Exception)
{
}
});
}
if (Settings.sendsDLC1PromoEmailAtEnd)
{
this.os.delayer.Post(ActionDelayer.Wait(30.0), delegate
{
try
{
string body = Utils.readEntireFile("Content/LocPost/DLCMessage.txt");
string subject = "Labyrinths";
string sender = "Matt Trobbiani";
string mail = MailServer.generateEmail(subject, body, sender);
MailServer mailServer = this.os.netMap.mailServer.getDaemon(typeof(MailServer)) as MailServer;
if (mailServer != null)
{
mailServer.addMail(mail, this.os.defaultUser.name);
}
}
catch (Exception)
{
}
});
}
}
// Token: 0x04000548 RID: 1352
private const float SpeechTextHashDelay = 1f;
// Token: 0x04000549 RID: 1353
private const float SpeechTextPercDelay = 0.5f;
// Token: 0x0400054A RID: 1354
private const float SpeechTextCharDelay = 0.05f;
// Token: 0x0400054B RID: 1355
public bool IsActive = false;
// Token: 0x0400054C RID: 1356
private float elapsedTime = 0f;
// Token: 0x0400054D RID: 1357
private float HacknetTitleFreezeTime = 10f;
// Token: 0x0400054E RID: 1358
private float creditsPixelsScrollPerSecond = 65f;
// Token: 0x0400054F RID: 1359
private SoundEffect speech;
// Token: 0x04000550 RID: 1360
private SoundEffectInstance speechinstance;
// Token: 0x04000551 RID: 1361
private WaveformRenderer waveRender;
// Token: 0x04000552 RID: 1362
private bool IsInCredits = false;
// Token: 0x04000553 RID: 1363
private float creditsScroll = 0f;
// Token: 0x04000554 RID: 1364
private string[] CreditsData;
// Token: 0x04000555 RID: 1365
private SoundEffect spinUpEffect;
// Token: 0x04000556 RID: 1366
private SoundEffect traceDownEffect;
// Token: 0x04000557 RID: 1367
private string BitSpeechText;
// Token: 0x04000558 RID: 1368
private int SpeechTextIndex = 0;
// Token: 0x04000559 RID: 1369
private float SpeechTextTimer = 0f;
}
}