forked from E-riCA0/StawdewValley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Event.cs
8012 lines (7937 loc) · 427 KB
/
Event.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
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Decompiled with JetBrains decompiler
// Type: StardewValley.Event
// Assembly: Stardew Valley, Version=1.2.6400.27469, Culture=neutral, PublicKeyToken=null
// MVID: 77B7094A-F6F0-4ACC-91F4-E335E2733EDB
// Assembly location: D:\SteamLibrary\steamapps\common\Stardew Valley\Stardew Valley.exe
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using StardewValley.BellsAndWhistles;
using StardewValley.Characters;
using StardewValley.Locations;
using StardewValley.Menus;
using StardewValley.Minigames;
using StardewValley.Objects;
using StardewValley.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using xTile;
using xTile.Dimensions;
namespace StardewValley
{
public class Event
{
public int oldPixelZoom = Game1.pixelZoom;
public List<NPC> actors = new List<NPC>();
public List<Object> props = new List<Object>();
public List<Prop> festivalProps = new List<Prop>();
public bool showGroundObjects = true;
public List<NPC> npcsWithUniquePortraits = new List<NPC>();
private LocalizedContentManager festivalContent = Game1.content.CreateTemporary();
public List<Vector2> characterWalkLocations = new List<Vector2>();
public int grangeScore = -1000;
private int previousFacingDirection = -1;
private int previousAnswerChoice = -1;
private const float timeBetweenSpeech = 500f;
private const float viewportMoveSpeed = 3f;
public string[] eventCommands;
public int currentCommand;
public int readyConfirmationTimer;
public int farmerAddedSpeed;
public string messageToScreen;
public string playerControlSequenceID;
public bool showActiveObject;
public bool continueAfterMove;
public bool specialEventVariable1;
public bool forked;
public bool wasBloomDay;
public bool wasBloomVisible;
public bool playerControlSequence;
public bool eventSwitched;
public bool isFestival;
public bool sentReadyConfirmation;
public bool allPlayersReady;
public bool playerWasMounted;
private Dictionary<string, Vector3> actorPositionsAfterMove;
private float timeAccumulator;
private float viewportXAccumulator;
private float viewportYAccumulator;
private Vector3 viewportTarget;
private Color previousAmbientLight;
private BloomSettings previousBloomSettings;
private GameLocation temporaryLocation;
public Point playerControlTargetTile;
private Texture2D _festivalTexture;
public List<NPCController> npcControllers;
public NPC secretSantaRecipient;
public NPC mySecretSanta;
public bool skippable;
private int id;
private Dictionary<string, string> festivalData;
private int oldShirt;
private Color oldPants;
private Item tmpItem;
private bool drawTool;
public bool skipped;
private bool waitingForMenuClose;
private int oldTime;
public List<TemporaryAnimatedSprite> underwaterSprites;
public List<TemporaryAnimatedSprite> aboveMapSprites;
private NPC festivalHost;
private string hostMessage;
public int festivalTimer;
private Item tempItemStash;
public Farmer playerUsingGrangeDisplay;
public Dictionary<string, Dictionary<Item, int[]>> festivalShops;
private bool startSecretSantaAfterDialogue;
public List<Item> grangeDisplay;
public bool specialEventVariable2;
public List<Item> luauIngredients;
public Texture2D festivalTexture
{
get
{
if (this._festivalTexture == null)
this._festivalTexture = this.festivalContent.Load<Texture2D>("Maps\\Festivals");
return this._festivalTexture;
}
}
public int CurrentCommand
{
get
{
return this.currentCommand;
}
set
{
this.currentCommand = value;
}
}
public Event(string eventString, int eventID = -1)
{
this.id = eventID;
this.eventCommands = eventString.Split('/');
this.actorPositionsAfterMove = new Dictionary<string, Vector3>();
this.previousAmbientLight = Game1.ambientLight;
this.wasBloomDay = Game1.bloomDay;
this.wasBloomVisible = Game1.bloom != null && Game1.bloom.Visible;
if (this.wasBloomDay)
this.previousBloomSettings = Game1.bloom.Settings;
if (Game1.player.getMount() != null)
{
this.playerWasMounted = true;
Game1.player.getMount().dismount();
}
Game1.player.canOnlyWalk = true;
Game1.player.showNotCarrying();
this.drawTool = false;
}
public Event()
{
}
public bool tryToLoadFestival(string festival)
{
Game1.player.festivalScore = 0;
foreach (Farmer farmer in Game1.otherFarmers.Values)
farmer.festivalScore = 0;
try
{
this.festivalData = this.festivalContent.Load<Dictionary<string, string>>("Data\\Festivals\\" + festival);
this.festivalData.Add("file", festival);
}
catch (Exception ex)
{
return false;
}
string str = this.festivalData["conditions"].Split('/')[0];
int int32_1 = Convert.ToInt32(this.festivalData["conditions"].Split('/')[1].Split(' ')[0]);
int int32_2 = Convert.ToInt32(this.festivalData["conditions"].Split('/')[1].Split(' ')[1]);
if (!str.Equals(Game1.currentLocation.Name) || Game1.timeOfDay < int32_1 || (Game1.timeOfDay >= int32_2 || Game1.currentLocation.getFarmersCount() + 1 < Game1.numberOfPlayers()))
return false;
this.eventCommands = this.festivalData["set-up"].Split('/');
this.actorPositionsAfterMove = new Dictionary<string, Vector3>();
this.previousAmbientLight = Game1.ambientLight;
int num = this.wasBloomDay ? 1 : 0;
this.isFestival = true;
Game1.setRichPresence(nameof (festival), (object) festival);
return true;
}
public void endBehaviors(string[] split, GameLocation location)
{
Game1.pixelZoom = this.oldPixelZoom;
if (Game1.currentSong != null && !Game1.currentSong.Name.Contains(Game1.currentSeason) && !this.eventCommands[0].Equals("continue"))
Game1.changeMusicTrack("none");
if (split != null && split.Length > 1)
{
string s = split[1];
// ISSUE: reference to a compiler-generated method
uint stringHash = \u003CPrivateImplementationDetails\u003E.ComputeStringHash(s);
if (stringHash <= 1997527009U)
{
if (stringHash <= 1353598700U)
{
if ((int) stringHash != 878656485)
{
if ((int) stringHash != 1266391031)
{
if ((int) stringHash == 1353598700 && s == "bed")
Game1.player.position = Game1.player.mostRecentBed + new Vector2(0.0f, (float) Game1.tileSize);
}
else if (s == "wedding")
{
if (Game1.player.isMale)
{
Game1.player.changeShirt(this.oldShirt);
Game1.player.changePants(this.oldPants);
Game1.getCharacterFromName("Lewis", false).CurrentDialogue.Push(new Dialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1025"), Game1.getCharacterFromName("Lewis", false)));
}
Game1.warpFarmer("Farm", Utility.getHomeOfFarmer(Game1.player).getPorchStandingSpot().X - 1, Utility.getHomeOfFarmer(Game1.player).getPorchStandingSpot().Y, 2);
}
}
else if (s == "busIntro")
Game1.currentMinigame = (IMinigame) new Intro(4);
}
else if ((int) stringHash != 1358361813)
{
if ((int) stringHash != 1619733218)
{
if ((int) stringHash == 1997527009 && s == "warpOut")
{
int index = 0;
if (location is BathHousePool && Game1.player.isMale)
index = 1;
Game1.warpFarmer(location.warps[index].TargetName, location.warps[index].TargetX, location.warps[index].TargetY, true);
Game1.eventOver = true;
this.CurrentCommand = this.CurrentCommand + 2;
Game1.screenGlowHold = false;
}
}
else if (s == "invisibleWarpOut")
{
Game1.getCharacterFromName(split[2], false).isInvisible = true;
Game1.warpFarmer(location.warps[0].TargetName, location.warps[0].TargetX, location.warps[0].TargetY, true);
Game1.fadeScreenToBlack();
Game1.eventOver = true;
this.CurrentCommand = this.CurrentCommand + 2;
Game1.screenGlowHold = false;
}
}
else if (s == "credits")
{
Game1.debrisWeather.Clear();
Game1.isDebrisWeather = false;
Game1.changeMusicTrack("wedding");
Game1.gameMode = (byte) 10;
this.CurrentCommand = this.CurrentCommand + 2;
}
}
else if (stringHash <= 2519057040U)
{
if ((int) stringHash != -2136135913)
{
if ((int) stringHash != -1823519222)
{
if ((int) stringHash == -1775910256 && s == "invisible")
Game1.getCharacterFromName(split[2], false).isInvisible = true;
}
else if (s == "position")
Game1.player.positionBeforeEvent = new Vector2((float) Convert.ToInt32(split[2]), (float) Convert.ToInt32(split[3]));
}
else if (s == "dialogueWarpOut")
{
int index = 0;
if (location is BathHousePool && Game1.player.isMale)
index = 1;
Game1.warpFarmer(location.warps[index].TargetName, location.warps[index].TargetX, location.warps[index].TargetY, true);
NPC characterFromName = Game1.getCharacterFromName(split[2], false);
int startIndex = this.eventCommands[this.CurrentCommand].IndexOf('"') + 1;
int length = this.eventCommands[this.CurrentCommand].Substring(this.eventCommands[this.CurrentCommand].IndexOf('"') + 1).IndexOf('"');
characterFromName.CurrentDialogue.Clear();
characterFromName.CurrentDialogue.Push(new Dialogue(this.eventCommands[this.CurrentCommand].Substring(startIndex, length), characterFromName));
Game1.eventOver = true;
this.CurrentCommand = this.CurrentCommand + 2;
Game1.screenGlowHold = false;
}
}
else if (stringHash <= 2988976489U)
{
if ((int) stringHash != -1371854509)
{
if ((int) stringHash == -1305990807 && s == "newDay")
{
if (Game1.player.isRidingHorse())
Game1.player.getMount().dismount();
Game1.player.faceDirection(2);
Game1.warpFarmer((GameLocation) Utility.getHomeOfFarmer(Game1.player), (int) Game1.player.mostRecentBed.X / Game1.tileSize, (int) Game1.player.mostRecentBed.Y / Game1.tileSize, 2, false);
Game1.newDay = true;
Game1.player.currentLocation.lastTouchActionLocation = new Vector2((float) ((int) Game1.player.mostRecentBed.X / Game1.tileSize), (float) ((int) Game1.player.mostRecentBed.Y / Game1.tileSize));
Game1.player.completelyStopAnimatingOrDoingAction();
if (Game1.player.bathingClothes)
Game1.player.changeOutOfSwimSuit();
Game1.player.swimming = false;
Game1.player.CanMove = false;
Game1.changeMusicTrack("none");
}
}
else if (s == "dialogue")
{
NPC characterFromName = Game1.getCharacterFromName(split[2], false);
int startIndex = this.eventCommands[this.CurrentCommand].IndexOf('"') + 1;
int length = this.eventCommands[this.CurrentCommand].Substring(this.eventCommands[this.CurrentCommand].IndexOf('"') + 1).IndexOf('"');
if (characterFromName != null)
{
characterFromName.CurrentDialogue.Clear();
characterFromName.CurrentDialogue.Push(new Dialogue(this.eventCommands[this.CurrentCommand].Substring(startIndex, length), characterFromName));
}
}
}
else if ((int) stringHash != -898604268)
{
if ((int) stringHash == -38085231 && s == "Maru1")
{
Game1.getCharacterFromName("Demetrius", false).setNewDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1018"), false, false);
Game1.getCharacterFromName("Maru", false).setNewDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1020"), false, false);
Game1.warpFarmer(location.warps[0].TargetName, location.warps[0].TargetX, location.warps[0].TargetY, true);
Game1.fadeScreenToBlack();
Game1.eventOver = true;
this.CurrentCommand = this.CurrentCommand + 2;
}
}
else if (s == "beginGame")
{
Game1.gameMode = (byte) 3;
if (Game1.IsServer)
Game1.initializeMultiplayerServer();
if (Game1.IsClient)
Game1.initializeMultiplayerClient();
Game1.warpFarmer("FarmHouse", 9, 9, false);
Game1.NewDay(1000f);
}
}
this.exitEvent();
}
public void exitEvent()
{
if (this.id != -1 && !Game1.player.eventsSeen.Contains(this.id))
Game1.player.eventsSeen.Add(this.id);
Game1.player.canOnlyWalk = false;
Game1.nonWarpFade = true;
if (!Game1.fadeIn || (double) Game1.fadeToBlackAlpha >= 1.0)
Game1.fadeScreenToBlack();
Game1.eventOver = true;
Game1.fadeToBlack = true;
this.CurrentCommand = this.CurrentCommand + 2;
Game1.screenGlowHold = false;
if (this.isFestival)
{
Game1.timeOfDay = 2200;
string str = this.festivalData["file"];
int minutes = 780;
if (this.festivalData != null && (this.festivalData["file"].Equals("summer28") || this.festivalData["file"].Equals("fall27")))
{
Game1.timeOfDay = 2400;
minutes = 240;
}
Game1.warpFarmer((GameLocation) Game1.getFarm(), 64 - Utility.getFarmerNumberFromFarmer(Game1.player), 15, 2, false);
Game1.player.toolOverrideFunction = (AnimatedSprite.endOfAnimationBehavior) null;
this.isFestival = false;
if (Game1.player.getSpouse() != null)
Game1.warpCharacter(Game1.player.getSpouse(), "FarmHouse", Utility.getHomeOfFarmer(Game1.player).getSpouseBedSpot(), false, true);
Game1.currentLocation.currentEvent = (Event) null;
foreach (GameLocation location in Game1.locations)
{
location.currentEvent = (Event) null;
foreach (Object @object in location.objects.Values)
@object.minutesElapsed(minutes, location);
}
Game1.player.freezePause = 1500;
}
else
{
if (this.playerWasMounted && Game1.currentLocation.isOutdoors)
{
Horse horse = Utility.findHorse();
if (horse != null)
Game1.warpCharacter((NPC) horse, Game1.currentLocation.name, new Vector2((float) Game1.xLocationAfterWarp, (float) Game1.yLocationAfterWarp), false, true);
}
Game1.player.forceCanMove();
}
}
public void incrementCommandAfterFade()
{
this.CurrentCommand = this.CurrentCommand + 1;
Game1.globalFade = false;
}
public void cleanup()
{
Game1.ambientLight = this.previousAmbientLight;
if (Game1.bloom != null)
{
Game1.bloom.Settings = this.previousBloomSettings;
Game1.bloom.Visible = this.wasBloomVisible;
Game1.bloom.reload();
}
foreach (NPC withUniquePortrait in this.npcsWithUniquePortraits)
{
withUniquePortrait.Portrait = Game1.content.Load<Texture2D>("Portraits\\" + withUniquePortrait.name);
withUniquePortrait.uniquePortraitActive = false;
}
if (this._festivalTexture != null)
this._festivalTexture = (Texture2D) null;
this.festivalContent.Unload();
}
public void checkForNextCommand(GameLocation location, GameTime time)
{
if (this.skipped)
return;
foreach (NPC actor in this.actors)
{
actor.update(time, Game1.currentLocation);
if (actor.Sprite.currentAnimation != null)
actor.Sprite.animateOnce(time);
}
if (this.aboveMapSprites != null)
{
for (int index = this.aboveMapSprites.Count - 1; index >= 0; --index)
{
if (this.aboveMapSprites[index].update(time))
this.aboveMapSprites.RemoveAt(index);
}
}
if (!this.playerControlSequence)
Game1.player.setRunning(false, false);
if (this.npcControllers != null)
{
for (int index = this.npcControllers.Count - 1; index >= 0; --index)
{
if (this.npcControllers[index].update(time, location, this.npcControllers))
this.npcControllers.RemoveAt(index);
}
}
if (this.isFestival)
this.festivalUpdate(time);
string[] split = this.eventCommands[Math.Min(this.eventCommands.Length - 1, this.CurrentCommand)].Split(' ');
if (this.temporaryLocation != null && !Game1.currentLocation.Equals((object) this.temporaryLocation))
this.temporaryLocation.updateEvenIfFarmerIsntHere(time, true);
TimeSpan elapsedGameTime;
if (this.CurrentCommand == 0 && !this.forked && !this.eventSwitched)
{
Game1.player.speed = 2;
Game1.player.running = false;
Game1.eventOver = false;
if ((!this.eventCommands[0].Equals("none") || !Game1.isRaining) && (!this.eventCommands[0].Equals("continue") && !this.eventCommands[0].Contains("pause")))
Game1.changeMusicTrack(this.eventCommands[0]);
if (location is Farm)
{
Point positionForFarmer = Farm.getFrontDoorPositionForFarmer(Game1.player);
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
xTile.Dimensions.Rectangle& local1 = @Game1.viewport;
Viewport viewport;
int num1;
if (!Game1.currentLocation.IsOutdoors)
{
num1 = positionForFarmer.X - Game1.graphics.GraphicsDevice.Viewport.Width / 2;
}
else
{
int val1_1 = 0;
int x = positionForFarmer.X;
viewport = Game1.graphics.GraphicsDevice.Viewport;
int num2 = viewport.Width / 2;
int val1_2 = x - num2;
int displayWidth = Game1.currentLocation.Map.DisplayWidth;
viewport = Game1.graphics.GraphicsDevice.Viewport;
int width = viewport.Width;
int val2_1 = displayWidth - width;
int val2_2 = Math.Min(val1_2, val2_1);
num1 = Math.Max(val1_1, val2_2);
}
// ISSUE: explicit reference operation
(^local1).X = num1;
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
xTile.Dimensions.Rectangle& local2 = @Game1.viewport;
int num3;
if (!Game1.currentLocation.IsOutdoors)
{
int y = positionForFarmer.Y;
viewport = Game1.graphics.GraphicsDevice.Viewport;
int num2 = viewport.Height / 2;
num3 = y - num2;
}
else
{
int val1_1 = 0;
int y = positionForFarmer.Y;
viewport = Game1.graphics.GraphicsDevice.Viewport;
int num2 = viewport.Height / 2;
int val1_2 = y - num2;
int displayHeight = Game1.currentLocation.Map.DisplayHeight;
viewport = Game1.graphics.GraphicsDevice.Viewport;
int height = viewport.Height;
int val2_1 = displayHeight - height;
int val2_2 = Math.Min(val1_2, val2_1);
num3 = Math.Max(val1_1, val2_2);
}
// ISSUE: explicit reference operation
(^local2).Y = num3;
}
else if (!this.eventCommands[1].Equals("follow"))
{
try
{
string[] strArray = this.eventCommands[1].Split(' ');
Game1.viewportFreeze = true;
int index1 = 0;
int num1 = Convert.ToInt32(strArray[index1]) * Game1.tileSize + Game1.tileSize / 2;
int index2 = 1;
int num2 = Convert.ToInt32(strArray[index2]) * Game1.tileSize + Game1.tileSize / 2;
int index3 = 0;
if ((int) strArray[index3][0] == 45)
{
Game1.viewport.X = num1;
Game1.viewport.Y = num2;
}
else
{
Game1.viewport.X = Game1.currentLocation.IsOutdoors ? Math.Max(0, Math.Min(num1 - Game1.viewport.Width / 2, Game1.currentLocation.Map.DisplayWidth - Game1.viewport.Width)) : num1 - Game1.viewport.Width / 2;
Game1.viewport.Y = Game1.currentLocation.IsOutdoors ? Math.Max(0, Math.Min(num2 - Game1.viewport.Height / 2, Game1.currentLocation.Map.DisplayHeight - Game1.viewport.Height)) : num2 - Game1.viewport.Height / 2;
}
if (num1 > 0 && Game1.graphics.GraphicsDevice.Viewport.Width > Game1.currentLocation.Map.DisplayWidth)
Game1.viewport.X = (Game1.currentLocation.Map.DisplayWidth - Game1.viewport.Width) / 2;
if (num2 > 0)
{
if (Game1.graphics.GraphicsDevice.Viewport.Height > Game1.currentLocation.Map.DisplayHeight)
Game1.viewport.Y = (Game1.currentLocation.Map.DisplayHeight - Game1.viewport.Height) / 2;
}
}
catch (Exception ex)
{
this.forked = true;
return;
}
}
this.setUpCharacters(this.eventCommands[2], location);
this.populateWalkLocationsList();
this.CurrentCommand = 3;
foreach (NPC actor in this.actors)
;
}
else if (!Game1.fadeToBlack || this.actorPositionsAfterMove.Count > 0 || (this.CurrentCommand > 3 || this.forked))
{
if (this.eventCommands.Length <= this.CurrentCommand)
return;
Vector3 viewportTarget = this.viewportTarget;
if (!this.viewportTarget.Equals(Vector3.Zero))
{
int speed = Game1.player.speed;
Game1.player.speed = (int) this.viewportTarget.X;
Game1.viewport.X += (int) this.viewportTarget.X;
if ((double) this.viewportTarget.X != 0.0)
Game1.updateRainDropPositionForPlayerMovement((double) this.viewportTarget.X < 0.0 ? 3 : 1, true, Math.Abs(this.viewportTarget.X + (!Game1.player.isMoving() || Game1.player.facingDirection != 3 ? (!Game1.player.isMoving() || Game1.player.facingDirection != 1 ? 0.0f : (float) Game1.player.speed) : (float) -Game1.player.speed)));
Game1.viewport.Y += (int) this.viewportTarget.Y;
Game1.player.speed = (int) this.viewportTarget.Y;
if ((double) this.viewportTarget.Y != 0.0)
Game1.updateRainDropPositionForPlayerMovement((double) this.viewportTarget.Y < 0.0 ? 0 : 2, true, Math.Abs(this.viewportTarget.Y - (!Game1.player.isMoving() || Game1.player.facingDirection != 0 ? (!Game1.player.isMoving() || Game1.player.facingDirection != 2 ? 0.0f : (float) Game1.player.speed) : (float) -Game1.player.speed)));
Game1.player.speed = speed;
// ISSUE: explicit reference operation
// ISSUE: variable of a reference type
float& local = @this.viewportTarget.Z;
// ISSUE: explicit reference operation
double num1 = (double) ^local;
elapsedGameTime = time.ElapsedGameTime;
double milliseconds = (double) elapsedGameTime.Milliseconds;
double num2 = num1 - milliseconds;
// ISSUE: explicit reference operation
^local = (float) num2;
if ((double) this.viewportTarget.Z <= 0.0)
this.viewportTarget = Vector3.Zero;
}
if (this.actorPositionsAfterMove.Count > 0)
{
foreach (string index in this.actorPositionsAfterMove.Keys.ToArray<string>())
{
Microsoft.Xna.Framework.Rectangle rectangle = new Microsoft.Xna.Framework.Rectangle((int) this.actorPositionsAfterMove[index].X * Game1.tileSize, (int) this.actorPositionsAfterMove[index].Y * Game1.tileSize, Game1.tileSize, Game1.tileSize);
rectangle.Inflate(-Game1.pixelZoom, 0);
if (this.getActorByName(index) != null && this.getActorByName(index).GetBoundingBox().Width > Game1.tileSize)
{
rectangle.Width = this.getActorByName(index).GetBoundingBox().Width + Game1.pixelZoom;
rectangle.Height = this.getActorByName(index).GetBoundingBox().Height + Game1.pixelZoom;
}
if (index.Contains("farmer"))
{
Farmer farmerNumberString = Utility.getFarmerFromFarmerNumberString(index);
if (farmerNumberString != null && rectangle.Contains(farmerNumberString.GetBoundingBox()) && ((double) (farmerNumberString.GetBoundingBox().Y - rectangle.Top) <= (double) (Game1.tileSize / 4) + (double) farmerNumberString.getMovementSpeed() && farmerNumberString.FacingDirection != 2 || (double) (rectangle.Bottom - farmerNumberString.GetBoundingBox().Bottom) <= (double) (Game1.tileSize / 4) + (double) farmerNumberString.getMovementSpeed() && farmerNumberString.FacingDirection == 2))
{
farmerNumberString.showNotCarrying();
farmerNumberString.Halt();
farmerNumberString.faceDirection((int) this.actorPositionsAfterMove[index].Z);
farmerNumberString.FarmerSprite.StopAnimation();
farmerNumberString.Halt();
this.actorPositionsAfterMove.Remove(index);
}
else if (farmerNumberString != null)
{
farmerNumberString.canOnlyWalk = false;
farmerNumberString.setRunning(false, true);
farmerNumberString.canOnlyWalk = true;
farmerNumberString.lastPosition = Game1.player.position;
farmerNumberString.MovePosition(time, Game1.viewport, location);
}
}
else
{
foreach (NPC actor in this.actors)
{
Microsoft.Xna.Framework.Rectangle boundingBox = actor.GetBoundingBox();
if (actor.name.Equals(index) && rectangle.Contains(boundingBox) && actor.GetBoundingBox().Y - rectangle.Top <= Game1.tileSize / 4)
{
actor.Halt();
actor.faceDirection((int) this.actorPositionsAfterMove[index].Z);
this.actorPositionsAfterMove.Remove(index);
break;
}
if (actor.name.Equals(index))
{
actor.MovePosition(time, Game1.viewport, (GameLocation) null);
break;
}
}
}
}
if (this.actorPositionsAfterMove.Count == 0)
{
if (this.continueAfterMove)
this.continueAfterMove = false;
else
this.CurrentCommand = this.CurrentCommand + 1;
}
if (!this.continueAfterMove)
return;
}
if (split[0].Equals("move"))
{
int index = 1;
while (index < split.Length && split.Length - index >= 3)
{
if (split[index].Contains("farmer") && !this.actorPositionsAfterMove.ContainsKey(split[index]))
{
Farmer farmerNumberString = Utility.getFarmerFromFarmerNumberString(split[index]);
if (farmerNumberString != null)
{
farmerNumberString.canOnlyWalk = false;
farmerNumberString.setRunning(false, true);
farmerNumberString.canOnlyWalk = true;
farmerNumberString.convertEventMotionCommandToMovement(new Vector2((float) Convert.ToInt32(split[index + 1]), (float) Convert.ToInt32(split[index + 2])));
this.actorPositionsAfterMove.Add(split[index], this.getPositionAfterMove((Character) Game1.player, Convert.ToInt32(split[index + 1]), Convert.ToInt32(split[index + 2]), Convert.ToInt32(split[index + 3])));
}
}
else
{
NPC actorByName = this.getActorByName(split[index]);
string key = split[index].Equals("rival") ? Utility.getOtherFarmerNames()[0] : split[index];
if (!this.actorPositionsAfterMove.ContainsKey(key))
{
actorByName.convertEventMotionCommandToMovement(new Vector2((float) Convert.ToInt32(split[index + 1]), (float) Convert.ToInt32(split[index + 2])));
this.actorPositionsAfterMove.Add(key, this.getPositionAfterMove((Character) actorByName, Convert.ToInt32(split[index + 1]), Convert.ToInt32(split[index + 2]), Convert.ToInt32(split[index + 3])));
}
}
index += 4;
}
if (((IEnumerable<string>) split).Last<string>().Equals("true"))
{
this.continueAfterMove = true;
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (((IEnumerable<string>) split).Last<string>().Equals("false"))
{
this.continueAfterMove = false;
if (split.Length == 2 && this.actorPositionsAfterMove.Count == 0)
this.CurrentCommand = this.CurrentCommand + 1;
}
}
else if (split[0].Equals("speak"))
{
if (this.skipped)
return;
if (!Game1.dialogueUp)
{
double timeAccumulator = (double) this.timeAccumulator;
elapsedGameTime = time.ElapsedGameTime;
double milliseconds = (double) elapsedGameTime.Milliseconds;
this.timeAccumulator = (float) (timeAccumulator + milliseconds);
if ((double) this.timeAccumulator < 500.0)
return;
this.timeAccumulator = 0.0f;
NPC npc = Game1.getCharacterFromName(split[1].Equals("rival") ? Utility.getOtherFarmerNames()[0] : split[1], false) ?? this.getActorByName(split[1]);
if (npc == null)
{
Game1.eventFinished();
return;
}
int num = this.eventCommands[this.currentCommand].IndexOf('"');
if (num > 0)
{
int length = this.eventCommands[this.CurrentCommand].Substring(num + 1).IndexOf('"');
Game1.player.checkForQuestComplete(npc, -1, -1, (Item) null, (string) null, 5, -1);
if (Game1.NPCGiftTastes.ContainsKey(split[1]) && !Game1.player.friendships.ContainsKey(split[1]))
Game1.player.friendships.Add(split[1], new int[6]);
if (length > 0)
npc.CurrentDialogue.Push(new Dialogue(this.eventCommands[this.CurrentCommand].Substring(num + 1, length), npc));
else
npc.CurrentDialogue.Push(new Dialogue("...", npc));
}
else
npc.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString(split[2]), npc));
Game1.drawDialogue(npc);
}
}
else if (split[0].Equals("minedeath"))
{
if (!Game1.dialogueUp)
{
Random random = new Random((int) Game1.uniqueIDForThisGame / 2 + (int) Game1.stats.DaysPlayed + Game1.timeOfDay);
int num1 = Math.Min(random.Next(Game1.player.Money / 20, Game1.player.Money / 4), 5000);
int num2 = num1 - (int) ((double) Game1.player.LuckLevel * 0.01 * (double) num1);
int num3 = num2 - num2 % 100;
int num4 = 0;
double num5 = 0.25 - (double) Game1.player.LuckLevel * 0.05 - Game1.dailyLuck;
for (int index = Game1.player.Items.Count - 1; index >= 0; --index)
{
if (Game1.player.Items[index] != null && (!(Game1.player.Items[index] is Tool) || Game1.player.Items[index] is MeleeWeapon && (Game1.player.Items[index] as MeleeWeapon).initialParentTileIndex != 47 && (Game1.player.Items[index] as MeleeWeapon).initialParentTileIndex != 4) && (Game1.player.Items[index].canBeTrashed() && !(Game1.player.Items[index] is Ring) && random.NextDouble() < num5))
{
++num4;
Game1.player.Items[index] = (Item) null;
}
}
Game1.player.Stamina = Math.Min(Game1.player.Stamina, 2f);
int num6 = (int) ((double) (10 - Game1.player.LuckLevel / 3) - Game1.dailyLuck * 20.0);
Game1.player.deepestMineLevel = Math.Max(1, Game1.mine.lowestLevelReached - num6);
if (Game1.mine != null)
Game1.mine.lowestLevelReached = Math.Max(1, Game1.mine.lowestLevelReached - num6);
Game1.player.Money = Math.Max(0, Game1.player.money - num3);
string str1;
if (num6 <= 0)
str1 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1057");
else
str1 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1055", (object) num6);
string str2;
if (num3 > 0)
str2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1058", (object) num3);
else
str2 = "";
string str3;
if (num4 <= 0)
str3 = num3 <= 0 ? "" : ".";
else if (num3 > 0)
{
string str4 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1063");
string str5;
if (num4 != 1)
str5 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1062", (object) num4);
else
str5 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1061");
str3 = str4 + str5;
}
else
{
string str4 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1060");
string str5;
if (num4 != 1)
str5 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1062", (object) num4);
else
str5 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1061");
str3 = str4 + str5;
}
Game1.drawObjectDialogue(str1 + str2 + str3);
}
}
else if (split[0].Equals("hospitaldeath"))
{
if (!Game1.dialogueUp)
{
Random random = new Random((int) Game1.uniqueIDForThisGame / 2 + (int) Game1.stats.DaysPlayed + Game1.timeOfDay);
int num1 = 0;
double num2 = 0.25 - (double) Game1.player.LuckLevel * 0.05 - Game1.dailyLuck;
for (int index = Game1.player.Items.Count - 1; index >= 0; --index)
{
if (Game1.player.Items[index] != null && (!(Game1.player.Items[index] is Tool) || Game1.player.Items[index] is MeleeWeapon && (Game1.player.Items[index] as MeleeWeapon).initialParentTileIndex != 47 && (Game1.player.Items[index] as MeleeWeapon).initialParentTileIndex != 4) && (Game1.player.Items[index].canBeTrashed() && !(Game1.player.Items[index] is Ring) && random.NextDouble() < num2))
{
++num1;
Game1.player.Items[index] = (Item) null;
}
}
Game1.player.Stamina = Math.Min(Game1.player.Stamina, 2f);
int num3 = Math.Min(1000, Game1.player.money);
Game1.player.Money -= num3;
string str1;
if (num3 <= 0)
str1 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1070");
else
str1 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1068", (object) num3);
string str2;
if (num1 <= 0)
{
str2 = "";
}
else
{
string str3 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1071");
string str4;
if (num1 != 1)
str4 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1062", (object) num1);
else
str4 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1061");
str2 = str3 + str4;
}
Game1.drawObjectDialogue(str1 + str2);
}
}
else if (split[0].Equals("end"))
this.endBehaviors(split, location);
else if (split[0].Equals("skippable"))
{
this.skippable = true;
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("emote"))
{
bool flag = split.Length > 3;
if (split[1].Contains("farmer"))
{
if (Utility.getFarmerFromFarmerNumberString(split[1]) != null)
Game1.player.doEmote(Convert.ToInt32(split[2]), !flag);
}
else
{
NPC actorByName = this.getActorByName(split[1]);
if (!actorByName.isEmoting)
actorByName.doEmote(Convert.ToInt32(split[2]), !flag);
}
if (flag)
{
this.CurrentCommand = this.CurrentCommand + 1;
this.checkForNextCommand(location, time);
}
}
else if (split[0].Equals("stopMusic"))
{
Game1.changeMusicTrack("none");
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("playSound"))
{
Game1.playSound(split[1]);
this.CurrentCommand = this.CurrentCommand + 1;
this.checkForNextCommand(location, time);
}
else if (split[0].Equals("pause"))
{
if ((double) Game1.pauseTime <= 0.0)
Game1.pauseTime = (float) Convert.ToInt32(split[1]);
}
else if (split[0].Equals("resetVariable"))
{
this.specialEventVariable1 = false;
this.currentCommand = this.currentCommand + 1;
}
else if (split[0].Equals("faceDirection"))
{
if (split[1].Contains("farmer"))
{
Farmer farmerNumberString = Utility.getFarmerFromFarmerNumberString(split[1]);
if (farmerNumberString != null)
{
farmerNumberString.FarmerSprite.StopAnimation();
farmerNumberString.completelyStopAnimatingOrDoingAction();
farmerNumberString.faceDirection(Convert.ToInt32(split[2]));
farmerNumberString.FarmerSprite.StopAnimation();
}
}
else if (split[1].Contains("spouse"))
{
if (Game1.player.spouse != null && Game1.player.spouse.Length > 0 && this.getActorByName(Game1.player.spouse.Replace("engaged", "")) != null)
this.getActorByName(Game1.player.spouse.Replace("engaged", "")).faceDirection(Convert.ToInt32(split[2]));
}
else
this.getActorByName(split[1]).faceDirection(Convert.ToInt32(split[2]));
if (split.Length == 3 && (double) Game1.pauseTime <= 0.0)
Game1.pauseTime = 500f;
else if (split.Length > 3)
{
this.CurrentCommand = this.CurrentCommand + 1;
this.checkForNextCommand(location, time);
}
}
else if (split[0].Equals("warp"))
{
if (split[1].Contains("farmer"))
{
Farmer farmerNumberString = Utility.getFarmerFromFarmerNumberString(split[1]);
if (farmerNumberString != null)
{
farmerNumberString.position.X = (float) (Convert.ToInt32(split[2]) * Game1.tileSize);
farmerNumberString.position.Y = (float) (Convert.ToInt32(split[3]) * Game1.tileSize);
if (Game1.IsClient)
farmerNumberString.remotePosition = new Vector2(farmerNumberString.position.X, farmerNumberString.position.Y);
}
}
else if (split[1].Contains("spouse"))
{
if (Game1.player.spouse != null && Game1.player.spouse.Length > 0 && this.getActorByName(Game1.player.spouse.Replace("engaged", "")) != null)
{
for (int index = this.npcControllers.Count - 1; index >= 0; --index)
{
if (this.npcControllers[index].puppet.name.Equals(Game1.player.spouse.Replace("engaged", "")))
this.npcControllers.RemoveAt(index);
}
this.getActorByName(Game1.player.spouse.Replace("engaged", "")).position = new Vector2((float) (Convert.ToInt32(split[2]) * Game1.tileSize), (float) (Convert.ToInt32(split[3]) * Game1.tileSize));
}
}
else
{
NPC actorByName = this.getActorByName(split[1]);
if (actorByName != null)
{
actorByName.position.X = (float) (Convert.ToInt32(split[2]) * Game1.tileSize + Game1.pixelZoom);
actorByName.position.Y = (float) (Convert.ToInt32(split[3]) * Game1.tileSize);
}
}
this.CurrentCommand = this.CurrentCommand + 1;
if (split.Length > 4)
this.checkForNextCommand(location, time);
}
else if (split[0].Equals("speed"))
{
if (split[1].Equals("farmer"))
this.farmerAddedSpeed = Convert.ToInt32(split[2]);
else
this.getActorByName(split[1]).speed = Convert.ToInt32(split[2]);
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("stopAdvancedMoves"))
{
this.npcControllers.Clear();
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("doAction"))
{
location.checkAction(new Location(Convert.ToInt32(split[1]), Convert.ToInt32(split[2])), Game1.viewport, Game1.player);
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("removeTile"))
{
location.removeTile(Convert.ToInt32(split[1]), Convert.ToInt32(split[2]), split[3]);
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("textAboveHead"))
{
NPC actorByName = this.getActorByName(split[1]);
if (actorByName != null)
{
int startIndex = this.eventCommands[this.CurrentCommand].IndexOf('"') + 1;
int length = this.eventCommands[this.CurrentCommand].Substring(this.eventCommands[this.CurrentCommand].IndexOf('"') + 1).IndexOf('"');
actorByName.showTextAboveHead(this.eventCommands[this.CurrentCommand].Substring(startIndex, length), -1, 2, 3000, 0);
}
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("showFrame"))
{
if (split.Length > 2 && !split[2].Equals("flip") && !split[1].Contains("farmer"))
{
NPC actorByName = this.getActorByName(split[1]);
if (actorByName != null)
{
actorByName.sprite.CurrentFrame = Convert.ToInt32(split[2]);
if (split[1].Equals("spouse") && actorByName.gender == 0 && (actorByName.sprite.CurrentFrame >= 36 && actorByName.sprite.CurrentFrame <= 38))
actorByName.sprite.CurrentFrame += 12;
}
}
else
{
Farmer farmer = Utility.getFarmerFromFarmerNumberString(split[1]);
if (split.Length == 2)
farmer = Game1.player;
if (farmer != null)
{
if (split.Length > 2)
split[1] = split[2];
farmer.FarmerSprite.setCurrentAnimation(new List<FarmerSprite.AnimationFrame>()
{
new FarmerSprite.AnimationFrame(Convert.ToInt32(split[1]), 100, false, split.Length > 2, (AnimatedSprite.endOfAnimationBehavior) null, false)
}.ToArray());
farmer.FarmerSprite.loopThisAnimation = true;
farmer.FarmerSprite.PauseForSingleAnimation = true;
farmer.sprite.CurrentFrame = Convert.ToInt32(split[1]);
}
}
this.CurrentCommand = this.CurrentCommand + 1;
this.checkForNextCommand(location, time);
}
else if (split[0].Equals("farmerAnimation"))
{
Game1.player.FarmerSprite.setCurrentSingleAnimation(Convert.ToInt32(split[1]));
this.CurrentCommand = this.CurrentCommand + 1;
}
else if (split[0].Equals("animate"))
{
int int32 = Convert.ToInt32(split[4]);
bool flip = split[2].Equals("true");
bool flag = split[3].Equals("true");
List<FarmerSprite.AnimationFrame> animation = new List<FarmerSprite.AnimationFrame>();
for (int index = 5; index < split.Length; ++index)
animation.Add(new FarmerSprite.AnimationFrame(Convert.ToInt32(split[index]), int32, false, flip, (AnimatedSprite.endOfAnimationBehavior) null, false));
if (split[1].Contains("farmer"))