Uh oh!
There was an error while loading. Please reload this page.
forked from forkification/OpenHacknet
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdvancedTutorial.cs
More file actions
Latest commit
490 lines (463 loc) · 15.3 KB
/
Copy pathAdvancedTutorial.cs
File metadata and controls
490 lines (463 loc) · 15.3 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
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
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
usingSystem;
usingSystem.Collections.Generic;
usingHacknet.Effects;
usingHacknet.Gui;
usingMicrosoft.Xna.Framework;
usingMicrosoft.Xna.Framework.Audio;
usingMicrosoft.Xna.Framework.Graphics;
usingMicrosoft.Xna.Framework.Input;
namespaceHacknet
{
// Token: 0x020000B7 RID: 183
internalclassAdvancedTutorial:ExeModule
{
// Token: 0x060003B2 RID: 946 RVA: 0x00038E4C File Offset: 0x0003704C
publicAdvancedTutorial(Rectanglelocation,OSoperatingSystem):base(location,operatingSystem)
{
this.state=0;
this.lastCommand="";
this.ramCost=500;
this.IdentifierName="Tutorial v16.2";
this.flashTimer=1f;
this.startSound=this.os.content.Load<SoundEffect>("SFX/DoomShock");
this.advanceFlash=this.os.content.Load<SoundEffect>("SFX/BrightFlash");
AdvancedTutorial.commandSequence=null;
}
// Token: 0x060003B3 RID: 947 RVA: 0x00039010 File Offset: 0x00037210
publicoverridevoidLoadContent()
{
base.LoadContent();
this.bounceEffect=newNodeBounceEffect
{
NodeHitDelay=0.02f,
TimeBetweenBounces=0.2f
};
stringtext="\n\n%&%&%&%\n";
stringtext2=LocalizedFileLoader.Read("Content/Post/AdvancedTutorialData.txt").Replace("\r\n","\n");
string[]array=text2.Split(newstring[]
{
text
},StringSplitOptions.None);
if(AdvancedTutorial.feedbackSequence!=null&&AdvancedTutorial.loadedLocale!=Settings.ActiveLocale)
{
AdvancedTutorial.feedbackSequence=null;
}
AdvancedTutorial.loadedLocale=(Settings.ActiveLocale??"");
if(AdvancedTutorial.commandSequence==null)
{
AdvancedTutorial.altCommandequence=newList<string[]>();
for(inti=0;i<15;i++)
{
AdvancedTutorial.altCommandequence.Add(newstring[0]);
}
AdvancedTutorial.commandSequence=newList<string>();
AdvancedTutorial.commandSequence.Add("&#*@(&#@(&#@&)@&#)(@&)@#");
AdvancedTutorial.commandSequence.Add("connect "+this.os.thisComputer.ip);
AdvancedTutorial.commandSequence.Add("scan");
AdvancedTutorial.commandSequence.Add("dc");
AdvancedTutorial.altCommandequence[3]=newstring[]
{
"disconnect"
};
AdvancedTutorial.commandSequence.Add("connect");
AdvancedTutorial.commandSequence.Add("probe");
AdvancedTutorial.altCommandequence[5]=newstring[]
{
"nmap"
};
AdvancedTutorial.commandSequence.Add("porthack");
AdvancedTutorial.commandSequence.Add("scan");
AdvancedTutorial.commandSequence.Add("ls");
AdvancedTutorial.altCommandequence[8]=newstring[]
{
"dir"
};
AdvancedTutorial.commandSequence.Add("cd bin");
AdvancedTutorial.altCommandequence[9]=newstring[]
{
"cd ../bin",
"cd ../../bin",
"cd /bin"
};
AdvancedTutorial.commandSequence.Add("cat config.txt");
AdvancedTutorial.altCommandequence[10]=newstring[]
{
"less config.txt"
};
AdvancedTutorial.commandSequence.Add("cd ..");
AdvancedTutorial.altCommandequence[11]=newstring[]
{
"cd..",
"cd /"
};
AdvancedTutorial.commandSequence.Add("cd log");
AdvancedTutorial.altCommandequence[12]=newstring[]
{
"cd ../log",
"cd ../../log",
"cd /log"
};
AdvancedTutorial.commandSequence.Add("rm *");
AdvancedTutorial.commandSequence.Add("dc");
AdvancedTutorial.altCommandequence[14]=newstring[]
{
"disconnect"
};
}
if(AdvancedTutorial.feedbackSequence==null)
{
AdvancedTutorial.feedbackSequence=newList<string>();
AdvancedTutorial.feedbackSequence.Add(array[0]);
AdvancedTutorial.feedbackSequence.Add(array[1]);
AdvancedTutorial.feedbackSequence.Add(array[2]);
AdvancedTutorial.feedbackSequence.Add(array[3]);
AdvancedTutorial.feedbackSequence.Add(array[4]);
AdvancedTutorial.feedbackSequence.Add(array[5]);
AdvancedTutorial.feedbackSequence.Add(array[6]);
AdvancedTutorial.feedbackSequence.Add(array[7]);
AdvancedTutorial.feedbackSequence.Add(array[8]);
AdvancedTutorial.feedbackSequence.Add(array[9]);
AdvancedTutorial.feedbackSequence.Add(array[10]);
AdvancedTutorial.feedbackSequence.Add(array[11]);
AdvancedTutorial.feedbackSequence.Add(array[12]);
AdvancedTutorial.feedbackSequence.Add(array[13]);
AdvancedTutorial.feedbackSequence.Add(array[14]);
AdvancedTutorial.feedbackSequence.Add(array[15]);
}
this.stepCompletionSequence=newList<Action>();
for(inti=0;i<AdvancedTutorial.feedbackSequence.Count;i++)
{
this.stepCompletionSequence.Add(null);
}
this.stepCompletionSequence[1]=delegate()
{
this.os.netMap.visible=true;
this.os.netMap.inputLocked=false;
};
this.stepCompletionSequence[2]=delegate()
{
this.os.display.visible=true;
this.os.display.inputLocked=false;
};
this.stepCompletionSequence[3]=delegate()
{
this.os.netMap.inputLocked=true;
};
this.stepCompletionSequence[4]=delegate()
{
this.os.netMap.inputLocked=false;
};
this.stepCompletionSequence[5]=delegate()
{
this.os.display.inputLocked=true;
this.os.ram.inputLocked=true;
this.os.netMap.inputLocked=true;
this.os.terminal.visible=true;
this.os.terminal.inputLocked=false;
this.os.terminal.clearCurrentLine();
};
this.stepCompletionSequence[8]=delegate()
{
this.os.display.inputLocked=false;
this.os.ram.inputLocked=false;
};
this.state=0;
this.getRenderText();
}
// Token: 0x060003B4 RID: 948 RVA: 0x0003956C File Offset: 0x0003776C
publicoverridevoidUpdate(floatt)
{
base.Update(t);
stringlastRunCommand=this.os.terminal.getLastRunCommand();
if(this.lastCommand!=lastRunCommand)
{
this.lastCommand=lastRunCommand;
this.parseCommand();
}
elseif(GuiData.getKeyboadState().IsKeyDown(Keys.F8))
{
this.lastCommand="";
}
this.flashTimer-=t;
this.flashTimer=Math.Max(this.flashTimer,0f);
this.bounceEffect.Update(t,delegate(Vector2nodePos)
{
this.bounceEffect.NodeHitDelay=Math.Max(0f,-0.2f+Utils.randm(0.5f));
this.bounceEffect.TimeBetweenBounces=0.15f+Utils.randm(0.7f);
});
this.hintTextFadeTimer=Math.Max(0f,this.hintTextFadeTimer-t);
}
// Token: 0x060003B5 RID: 949 RVA: 0x00039630 File Offset: 0x00037830
publicvoidparseCommand()
{
try
{
if(this.state<AdvancedTutorial.commandSequence.Count)
{
boolflag=this.lastCommand.ToLower().StartsWith(AdvancedTutorial.commandSequence[this.state]);
if(!flag)
{
for(inti=0;i<AdvancedTutorial.altCommandequence[this.state].Length;i++)
{
flag|=this.lastCommand.ToLower().StartsWith(AdvancedTutorial.altCommandequence[this.state][i]);
}
}
if(flag)
{
this.advanceState();
}
}
else
{
this.lastCommand=null;
}
}
catch(Exception)
{
this.lastCommand="";
}
}
// Token: 0x060003B6 RID: 950 RVA: 0x0003970C File Offset: 0x0003790C
privatevoidadvanceState()
{
this.state++;
this.getRenderText();
if(this.state>0)
{
this.printCurrentCommandToTerminal();
}
this.flashTimer=1f;
if(this.stepCompletionSequence[this.state]!=null)
{
this.stepCompletionSequence[this.state]();
}
if(!Settings.soundDisabled&&!MusicManager.isMuted)
{
if(this.state>1)
{
this.advanceFlash.Play(0.6f,1f,1f);
}
}
}
// Token: 0x060003B7 RID: 951 RVA: 0x000397C4 File Offset: 0x000379C4
publicvoidprintCurrentCommandToTerminal()
{
this.os.terminal.writeLine("\n--------------------------------------------------");
this.os.terminal.writeLine(" ");
for(inti=0;i<this.renderText.Length;i++)
{
if(!this.renderText[i].Contains("<#")&&!this.renderText[i].Contains("#>"))
{
this.os.terminal.writeLine(this.renderText[i]);
}
}
this.os.terminal.writeLine(" ");
this.os.terminal.writeLine("--------------------------------------------------\n");
}
// Token: 0x060003B8 RID: 952 RVA: 0x0003988C File Offset: 0x00037A8C
publicvoidgetRenderText()
{
stringtext=AdvancedTutorial.feedbackSequence[this.state];
char[]separator=newchar[]
{
'\n'
};
string[]array=text.Split(this.hintButtonDelimiter,StringSplitOptions.RemoveEmptyEntries);
if(array.Length>1)
{
this.hintButtonText=DisplayModule.cleanSplitForWidth(array[1],178).Split(separator);
text=array[0];
this.hintTextFadeTimer=0f;
}
else
{
this.hintButtonText=null;
}
stringdata=LocalizedFileLoader.SafeFilterString(text);
this.renderText=Utils.SuperSmartTwimForWidth(data,this.bounds.Width-10,GuiData.tinyfont).Split(separator);
}
// Token: 0x060003B9 RID: 953 RVA: 0x00039938 File Offset: 0x00037B38
publicoverridevoidKilled()
{
base.Killed();
if(!this.os.multiplayer&&this.os.initShowsTutorial)
{
this.os.currentMission.sendEmail(this.os);
this.os.Flags.AddFlag("TutorialComplete");
this.os.initShowsTutorial=false;
}
if(this.os.hubServerAlertsIcon!=null)
{
this.os.hubServerAlertsIcon.IsEnabled=true;
}
this.os.mailicon.isEnabled=true;
this.os.terminal.visible=true;
this.os.terminal.inputLocked=false;
this.os.netMap.visible=true;
this.os.netMap.inputLocked=false;
this.os.ram.visible=true;
this.os.ram.inputLocked=false;
this.os.display.visible=true;
this.os.display.inputLocked=false;
if(this.state<AdvancedTutorial.feedbackSequence.Count-1)
{
AchievementsManager.Unlock("kill_tutorial",false);
}
}
// Token: 0x060003BA RID: 954 RVA: 0x00039A90 File Offset: 0x00037C90
publicoverridevoidDraw(floatt)
{
base.Draw(t);
this.drawOutline();
Rectanglebounds=this.bounds;
bounds.X++;
bounds.Y++;
bounds.Width-=2;
bounds.Height-=2;
bounds.Height-=Module.PANEL_HEIGHT;
bounds.Y+=Module.PANEL_HEIGHT;
PatternDrawer.draw(bounds,1f,this.os.highlightColor*0.2f,this.os.highlightColor,this.spriteBatch);
bounds.X+=2;
bounds.Y+=2;
bounds.Width-=4;
bounds.Height-=4;
this.spriteBatch.Draw(Utils.white,bounds,this.os.darkBackgroundColor*0.99f);
this.drawTarget("app:");
intnum=260;
Rectanglebounds2=newRectangle(this.bounds.X+1,this.bounds.Y+this.bounds.Height-num,this.bounds.Width-2,num);
this.bounceEffect.Draw(this.spriteBatch,bounds2,Utils.AdditivizeColor(this.os.highlightColor)*0.35f,Utils.AddativeWhite*0.5f);
intnum2=210;
Rectanglerectangle=newRectangle(bounds2.X,bounds2.Y+(num-num2),bounds2.Width,num2);
this.spriteBatch.Draw(Utils.gradient,rectangle,null,this.os.darkBackgroundColor,0f,Vector2.Zero,SpriteEffects.FlipVertically,0.7f);
RectangledestinationRectangle=rectangle;
destinationRectangle.Y=bounds2.Y;
destinationRectangle.Height=num-num2;
this.spriteBatch.Draw(Utils.white,destinationRectangle,this.os.darkBackgroundColor);
this.spriteBatch.Draw(Utils.white,bounds,this.os.highlightColor*this.flashTimer);
this.spriteBatch.DrawString(GuiData.font,Utils.FlipRandomChars("Tutorial",0.024),newVector2((float)(this.bounds.X+5),(float)(this.bounds.Y+22)),this.os.subtleTextColor*0.6f);
this.spriteBatch.DrawString(GuiData.font,"Tutorial",newVector2((float)(this.bounds.X+5),(float)(this.bounds.Y+22)),this.os.subtleTextColor);
floatnum3=GuiData.ActiveFontConfig.tinyFontCharHeight+1f;
Vector2dpos=newVector2((float)(this.bounds.X+5),(float)(this.bounds.Y+67));
dpos=this.RenderText(this.renderText,dpos,num3,1f);
dpos.Y+=num3;
if(this.state==0&&this.CanActivateFirstStep)
{
if(Button.doButton(2933201,this.bounds.X+10,(int)(dpos.Y+20f),this.bounds.Width-20,30,LocaleTerms.Loc("Continue"),null)||(!this.os.terminal.visible&&Utils.keyPressed(GuiData.lastInput,Keys.Enter,null)))
{
this.advanceState();
if(!Settings.soundDisabled)
{
this.startSound.Play(1f,0f,0f);
this.startSound.Play(1f,0f,0f);
}
}
}
elseif(this.hintButtonText!=null)
{
if(Button.doButton(2933202,this.bounds.X+10,(int)(dpos.Y+6f),this.bounds.Width-20,20,LocaleTerms.Loc("Hint"),null))
{
this.hintTextFadeTimer=9f;
}
dpos.Y+=30f;
dpos.X+=10f;
floatnum4=Math.Min(1f,this.hintTextFadeTimer/3f);
stringtext="";
for(inti=0;i<this.hintButtonText.Length;i++)
{
text=text+this.hintButtonText[i]+"\n";
}
text=Utils.SuperSmartTwimForWidth(text.Trim(),this.bounds.Width,GuiData.tinyfont);
string[]array=text.Split(Utils.robustNewlineDelim,StringSplitOptions.None);
RectangledestinationRectangle2=newRectangle((int)dpos.X,(int)dpos.Y,this.bounds.Width,(int)(num3*(float)array.Length));
this.spriteBatch.Draw(Utils.white,destinationRectangle2,Color.Black*0.5f*num4);
this.RenderText(array,dpos,num3,num4);
}
}
// Token: 0x060003BB RID: 955 RVA: 0x0003A06C File Offset: 0x0003826C
privateVector2RenderText(string[]stringData,Vector2dpos,floatcharHeight,floatopacityMod=1f)
{
boolflag=false;
inti=0;
while(i<stringData.Length)
{
stringtext=stringData[i];
text=text.Replace("\r","");
if(text.Length>0)
{
if(text.Trim()=="<#")
{
flag=true;
}
elseif(text.Trim()=="#>")
{
flag=false;
}
else
{
this.spriteBatch.DrawString(GuiData.tinyfont,text,dpos,(flag?this.os.highlightColor:Color.White)*opacityMod);
dpos.Y+=charHeight;
}
}
IL_B6:
i++;
continue;
gotoIL_B6;
}
returndpos;
}
// Token: 0x060003BC RID: 956 RVA: 0x0003A148 File Offset: 0x00038348
privateVector2RenderTextOld(string[]stringData,Vector2dpos,floatcharHeight,floatopacityMod=1f)
{
foreach(stringtextinstringData)
{
if(text.Length>0)
{
boolflag=false;
if(text[0]=='#')
{
text=text.Substring(1,text.Length-2);
flag=true;
}
this.spriteBatch.DrawString(GuiData.tinyfont,text,dpos,(flag?this.os.highlightColor:Color.White)*opacityMod);
dpos.Y+=charHeight;
}
}
returndpos;
}
// Token: 0x0400044A RID: 1098
privatestaticList<string>commandSequence;
// Token: 0x0400044B RID: 1099
privatestaticList<string[]>altCommandequence;
// Token: 0x0400044C RID: 1100
privatestaticList<string>feedbackSequence;
// Token: 0x0400044D RID: 1101
privatestaticstringloadedLocale="en-us";
// Token: 0x0400044E RID: 1102
privateintstate;
// Token: 0x0400044F RID: 1103
privatestringlastCommand;
// Token: 0x04000450 RID: 1104
privatestring[]renderText;
// Token: 0x04000451 RID: 1105
privatestring[]hintButtonText=null;
// Token: 0x04000452 RID: 1106
privatefloathintTextFadeTimer=0f;
// Token: 0x04000453 RID: 1107
privatestring[]hintButtonDelimiter=newstring[]
{
"|"
};
// Token: 0x04000454 RID: 1108
privatefloatflashTimer;
// Token: 0x04000455 RID: 1109
privateSoundEffectstartSound;
// Token: 0x04000456 RID: 1110
privateSoundEffectadvanceFlash;
// Token: 0x04000457 RID: 1111
privateList<Action>stepCompletionSequence;
// Token: 0x04000458 RID: 1112
privateNodeBounceEffectbounceEffect;
// Token: 0x04000459 RID: 1113
publicboolCanActivateFirstStep=true;
}
}