-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathEvent.cs
9870 lines (9637 loc) · 458 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.5.6.22018, Culture=neutral, PublicKeyToken=null
// MVID: BEBB6D18-4941-4529-AC12-B54F0C61CC20
// Assembly location: C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Stardew Valley.dll
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Netcode;
using StardewValley.BellsAndWhistles;
using StardewValley.Characters;
using StardewValley.Locations;
using StardewValley.Menus;
using StardewValley.Minigames;
using StardewValley.Monsters;
using StardewValley.Network;
using StardewValley.Objects;
using StardewValley.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using xTile.Dimensions;
namespace StardewValley
{
public class Event
{
protected static Dictionary<string, MethodInfo> _commandLookup;
[InstancedStatic]
protected static object[] _eventCommandArgs = new object[3];
public const int weddingEventId = -2;
private const float timeBetweenSpeech = 500f;
private const float viewportMoveSpeed = 3f;
public const string festivalTextureName = "Maps\\Festivals";
public bool simultaneousCommand;
public string[] eventCommands;
public int currentCommand;
public int farmerAddedSpeed;
public int int_useMeForAnything;
public int int_useMeForAnything2;
public List<NPC> actors = new List<NPC>();
public List<Object> props = new List<Object>();
public List<Prop> festivalProps = new List<Prop>();
public string messageToScreen;
public string playerControlSequenceID;
public string spriteTextToDraw;
public bool showActiveObject;
public bool continueAfterMove;
public bool specialEventVariable1;
public bool forked;
public bool eventSwitched;
public bool isFestival;
public bool showGroundObjects = true;
public bool isWedding;
public bool doingSecretSanta;
public bool showWorldCharacters;
public bool isMemory;
public bool ignoreObjectCollisions = true;
protected bool _playerControlSequence;
private Dictionary<string, Vector3> actorPositionsAfterMove;
private float timeAccumulator;
private float viewportXAccumulator;
private float viewportYAccumulator;
public float float_useMeForAnything;
private Vector3 viewportTarget;
private Microsoft.Xna.Framework.Color previousAmbientLight;
public List<NPC> npcsWithUniquePortraits = new List<NPC>();
public LocationRequest exitLocation;
public ICustomEventScript currentCustomEventScript;
public List<Farmer> farmerActors = new List<Farmer>();
private HashSet<long> festivalWinners = new HashSet<long>();
public Action onEventFinished;
protected bool _repeatingLocationSpecificCommand;
private readonly LocalizedContentManager festivalContent = Game1.content.CreateTemporary();
private GameLocation temporaryLocation;
public Point playerControlTargetTile;
private Texture2D _festivalTexture;
public List<NPCController> npcControllers;
public NPC secretSantaRecipient;
public NPC mySecretSanta;
public bool skippable;
public int id;
public List<Vector2> characterWalkLocations = new List<Vector2>();
public bool ignoreTileOffsets;
public Vector2 eventPositionTileOffset = Vector2.Zero;
[NonInstancedStatic]
public static HashSet<string> invalidFestivals = new HashSet<string>();
private Dictionary<string, string> festivalData;
private int oldShirt;
private Microsoft.Xna.Framework.Color oldPants;
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;
public int grangeScore = -1000;
public bool grangeJudged;
private int previousFacingDirection = -1;
public Dictionary<string, Dictionary<ISalable, int[]>> festivalShops;
private int previousAnswerChoice = -1;
private bool startSecretSantaAfterDialogue;
public bool specialEventVariable2;
private List<Farmer> winners;
public virtual void setupEventCommands()
{
if (Event._commandLookup != null)
return;
Event._commandLookup = new Dictionary<string, MethodInfo>((IEqualityComparer<string>) StringComparer.InvariantCultureIgnoreCase);
MethodInfo[] array = ((IEnumerable<MethodInfo>) typeof (Event).GetMethods()).Where<MethodInfo>((Func<MethodInfo, bool>) (method_info => method_info.Name.StartsWith("command_"))).ToArray<MethodInfo>();
foreach (MethodInfo methodInfo in array)
Event._commandLookup.Add(methodInfo.Name.Substring("command_".Length), methodInfo);
Console.WriteLine("setupEventCommands() registered '{0}' methods", (object) array.Length);
}
public virtual void tryEventCommand(GameLocation location, GameTime time, string[] split)
{
Event._eventCommandArgs[0] = (object) location;
Event._eventCommandArgs[1] = (object) time;
Event._eventCommandArgs[2] = (object) split;
if (split.Length == 0)
return;
MethodInfo methodInfo;
if (Event._commandLookup.TryGetValue(split[0], out methodInfo))
{
try
{
methodInfo.Invoke((object) this, Event._eventCommandArgs);
}
catch (TargetInvocationException ex)
{
this.LogErrorAndHalt(ex.InnerException);
}
}
else
Console.WriteLine("ERROR: Invalid command: " + split[0]);
}
public virtual void command_ignoreEventTileOffset(
GameLocation location,
GameTime time,
string[] split)
{
this.ignoreTileOffsets = true;
++this.CurrentCommand;
}
public virtual void command_move(GameLocation location, GameTime time, string[] split)
{
for (int index = 1; index < split.Length && split.Length - index >= 3; index += 4)
{
if (split[index].Contains("farmer") && !this.actorPositionsAfterMove.ContainsKey(split[index]))
{
Farmer farmerNumberString = this.getFarmerFromFarmerNumberString(split[index], this.farmer);
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) this.farmer, 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])));
}
}
}
if (((IEnumerable<string>) split).Last<string>().Equals("true"))
{
this.continueAfterMove = true;
++this.CurrentCommand;
}
else
{
if (!((IEnumerable<string>) split).Last<string>().Equals("false"))
return;
this.continueAfterMove = false;
if (split.Length != 2 || this.actorPositionsAfterMove.Count != 0)
return;
++this.CurrentCommand;
}
}
public virtual void command_speak(GameLocation location, GameTime time, string[] split)
{
if (this.skipped || Game1.dialogueUp)
return;
this.timeAccumulator += (float) time.ElapsedGameTime.Milliseconds;
if ((double) this.timeAccumulator < 500.0)
return;
this.timeAccumulator = 0.0f;
NPC actorByName = this.getActorByName(split[1]);
if (actorByName == null)
Game1.getCharacterFromName(split[1].Equals("rival") ? Utility.getOtherFarmerNames()[0] : split[1]);
if (actorByName == null)
{
Game1.eventFinished();
}
else
{
int num = this.eventCommands[this.currentCommand].IndexOf('"');
if (num > 0)
{
int length = this.eventCommands[this.CurrentCommand].Substring(num + 1).LastIndexOf('"');
Game1.player.checkForQuestComplete(actorByName, -1, -1, (Item) null, (string) null, 5);
if (Game1.NPCGiftTastes.ContainsKey(split[1]) && !Game1.player.friendshipData.ContainsKey(split[1]))
Game1.player.friendshipData.Add(split[1], new Friendship(0));
if (length > 0)
actorByName.CurrentDialogue.Push(new Dialogue(this.eventCommands[this.CurrentCommand].Substring(num + 1, length), actorByName));
else
actorByName.CurrentDialogue.Push(new Dialogue("...", actorByName));
}
else
actorByName.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString(split[2]), actorByName));
Game1.drawDialogue(actorByName);
}
}
public virtual void command_beginSimultaneousCommand(
GameLocation location,
GameTime time,
string[] split)
{
this.simultaneousCommand = true;
++this.CurrentCommand;
}
public virtual void command_endSimultaneousCommand(
GameLocation location,
GameTime time,
string[] split)
{
this.simultaneousCommand = false;
++this.CurrentCommand;
}
public virtual void command_minedeath(GameLocation location, GameTime time, string[] split)
{
if (Game1.dialogueUp)
return;
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 sub1_1 = num2 - num2 % 100;
int sub1_2 = 0;
double num3 = 0.25 - (double) Game1.player.LuckLevel * 0.05 - Game1.player.DailyLuck;
Game1.player.itemsLostLastDeath.Clear();
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() < num3)
{
Item obj = Game1.player.Items[index];
Game1.player.Items[index] = (Item) null;
++sub1_2;
Game1.player.itemsLostLastDeath.Add(obj);
}
}
Game1.player.Stamina = Math.Min(Game1.player.Stamina, 2f);
Game1.player.Money = Math.Max(0, Game1.player.Money - sub1_1);
Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1057") + " " + (sub1_1 <= 0 ? "" : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1058", (object) sub1_1)) + (sub1_2 > 0 ? (sub1_1 <= 0 ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1060") + (sub1_2 == 1 ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1061") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1062", (object) sub1_2)) : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1063") + (sub1_2 == 1 ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1061") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1062", (object) sub1_2))) : (sub1_1 <= 0 ? "" : ".")));
List<string> list = ((IEnumerable<string>) this.eventCommands).ToList<string>();
list.Insert(this.CurrentCommand + 1, "showItemsLost");
this.eventCommands = list.ToArray();
}
public virtual void command_hospitaldeath(GameLocation location, GameTime time, string[] split)
{
if (Game1.dialogueUp)
return;
Random random = new Random((int) Game1.uniqueIDForThisGame / 2 + (int) Game1.stats.DaysPlayed + Game1.timeOfDay);
int sub1_1 = 0;
double num = 0.25 - (double) Game1.player.LuckLevel * 0.05 - Game1.player.DailyLuck;
Game1.player.itemsLostLastDeath.Clear();
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() < num)
{
Item obj = Game1.player.Items[index];
Game1.player.Items[index] = (Item) null;
++sub1_1;
Game1.player.itemsLostLastDeath.Add(obj);
}
}
Game1.player.Stamina = Math.Min(Game1.player.Stamina, 2f);
int sub1_2 = Math.Min(1000, Game1.player.Money);
Game1.player.Money -= sub1_2;
Game1.drawObjectDialogue((sub1_2 > 0 ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1068", (object) sub1_2) : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1070")) + (sub1_1 > 0 ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1071") + (sub1_1 == 1 ? Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1061") : Game1.content.LoadString("Strings\\StringsFromCSFiles:Event.cs.1062", (object) sub1_1)) : ""));
List<string> list = ((IEnumerable<string>) this.eventCommands).ToList<string>();
list.Insert(this.CurrentCommand + 1, "showItemsLost");
this.eventCommands = list.ToArray();
}
public virtual void command_showItemsLost(GameLocation location, GameTime time, string[] split)
{
if (Game1.activeClickableMenu != null)
return;
Game1.activeClickableMenu = (IClickableMenu) new ItemListMenu(Game1.content.LoadString("Strings\\UI:ItemList_ItemsLost"), Game1.player.itemsLostLastDeath.ToList<Item>());
}
public virtual void command_end(GameLocation location, GameTime time, string[] split) => this.endBehaviors(split, location);
public virtual void command_locationSpecificCommand(
GameLocation location,
GameTime time,
string[] split)
{
if (split.Length <= 1)
return;
if (location.RunLocationSpecificEventCommand(this, split[1], !this._repeatingLocationSpecificCommand, ((IEnumerable<string>) split).Skip<string>(2).ToArray<string>()))
{
this._repeatingLocationSpecificCommand = false;
++this.CurrentCommand;
}
else
this._repeatingLocationSpecificCommand = true;
}
public virtual void command_unskippable(GameLocation location, GameTime time, string[] split)
{
this.skippable = false;
++this.CurrentCommand;
}
public virtual void command_skippable(GameLocation location, GameTime time, string[] split)
{
this.skippable = true;
++this.CurrentCommand;
}
public virtual void command_emote(GameLocation location, GameTime time, string[] split)
{
bool flag = split.Length > 3;
if (split[1].Contains("farmer"))
{
if (this.getFarmerFromFarmerNumberString(split[1], this.farmer) != null)
this.farmer.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)
return;
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_stopMusic(GameLocation location, GameTime time, string[] split)
{
Game1.changeMusicTrack("none", music_context: Game1.MusicContext.Event);
++this.CurrentCommand;
}
public virtual void command_playSound(GameLocation location, GameTime time, string[] split)
{
Game1.playSound(split[1]);
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_tossConcession(
GameLocation location,
GameTime time,
string[] split)
{
NPC actorByName = this.getActorByName(split[1]);
int tilePosition = int.Parse(split[2]);
Game1.playSound("dwop");
location.temporarySprites.Add(new TemporaryAnimatedSprite()
{
texture = Game1.concessionsSpriteSheet,
sourceRect = Game1.getSourceRectForStandardTileSheet(Game1.concessionsSpriteSheet, tilePosition, 16, 16),
animationLength = 1,
totalNumberOfLoops = 1,
motion = new Vector2(0.0f, -6f),
acceleration = new Vector2(0.0f, 0.2f),
interval = 1000f,
scale = 4f,
position = this.OffsetPosition(new Vector2(actorByName.Position.X, actorByName.Position.Y - 96f)),
layerDepth = (float) actorByName.getStandingY() / 10000f
});
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_pause(GameLocation location, GameTime time, string[] split)
{
if ((double) Game1.pauseTime > 0.0)
return;
Game1.pauseTime = (float) Convert.ToInt32(split[1]);
}
public virtual void command_resetVariable(GameLocation location, GameTime time, string[] split)
{
this.specialEventVariable1 = false;
++this.currentCommand;
}
public virtual void command_faceDirection(GameLocation location, GameTime time, string[] split)
{
if (split[1].Contains("farmer"))
{
Farmer farmerNumberString = this.getFarmerFromFarmerNumberString(split[1], this.farmer);
if (farmerNumberString != null)
{
farmerNumberString.FarmerSprite.StopAnimation();
farmerNumberString.completelyStopAnimatingOrDoingAction();
farmerNumberString.faceDirection(Convert.ToInt32(split[2]));
}
}
else if (split[1].Contains("spouse"))
{
if (Game1.player.spouse != null && Game1.player.spouse.Length > 0 && this.getActorByName(Game1.player.spouse) != null && !Game1.player.isRoommate(Game1.player.spouse))
this.getActorByName(Game1.player.spouse).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)
return;
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
}
public virtual void command_warp(GameLocation location, GameTime time, string[] split)
{
if (split[1].Contains("farmer"))
{
Farmer farmerNumberString = this.getFarmerFromFarmerNumberString(split[1], this.farmer);
if (farmerNumberString != null)
{
farmerNumberString.setTileLocation(this.OffsetTile(new Vector2((float) Convert.ToInt32(split[2]), (float) Convert.ToInt32(split[3]))));
farmerNumberString.position.Y -= 16f;
if (this.farmerActors.Contains(farmerNumberString))
farmerNumberString.completelyStopAnimatingOrDoingAction();
}
}
else if (split[1].Contains("spouse"))
{
if (Game1.player.spouse != null && Game1.player.spouse.Length > 0 && this.getActorByName(Game1.player.spouse) != null && !Game1.player.isRoommate(Game1.player.spouse))
{
if (this.npcControllers != null)
{
for (int index = this.npcControllers.Count - 1; index >= 0; --index)
{
if (this.npcControllers[index].puppet.Name.Equals(Game1.player.spouse))
this.npcControllers.RemoveAt(index);
}
}
this.getActorByName(Game1.player.spouse).Position = this.OffsetPosition(new Vector2((float) (Convert.ToInt32(split[2]) * 64), (float) (Convert.ToInt32(split[3]) * 64)));
}
}
else
{
NPC actorByName = this.getActorByName(split[1]);
if (actorByName != null)
{
actorByName.position.X = this.OffsetPositionX((float) (Convert.ToInt32(split[2]) * 64 + 4));
actorByName.position.Y = this.OffsetPositionY((float) (Convert.ToInt32(split[3]) * 64));
}
}
++this.CurrentCommand;
if (split.Length <= 4)
return;
this.checkForNextCommand(location, time);
}
public virtual void command_speed(GameLocation location, GameTime time, string[] split)
{
if (split[1].Equals("farmer"))
this.farmerAddedSpeed = Convert.ToInt32(split[2]);
else
this.getActorByName(split[1]).speed = Convert.ToInt32(split[2]);
++this.CurrentCommand;
}
public virtual void command_stopAdvancedMoves(
GameLocation location,
GameTime time,
string[] split)
{
if (((IEnumerable<string>) split).Count<string>() > 1)
{
if (split[1].Equals("next"))
{
foreach (NPCController npcController in this.npcControllers)
npcController.destroyAtNextCrossroad();
}
}
else
this.npcControllers.Clear();
++this.CurrentCommand;
}
public virtual void command_doAction(GameLocation location, GameTime time, string[] split)
{
Location tile_location = new Location(this.OffsetTileX(Convert.ToInt32(split[1])), this.OffsetTileY(Convert.ToInt32(split[2])));
Game1.hooks.OnGameLocation_CheckAction(location, tile_location, Game1.viewport, this.farmer, (Func<bool>) (() => location.checkAction(tile_location, Game1.viewport, this.farmer)));
++this.CurrentCommand;
}
public virtual void command_removeTile(GameLocation location, GameTime time, string[] split)
{
location.removeTile(this.OffsetTileX(Convert.ToInt32(split[1])), this.OffsetTileY(Convert.ToInt32(split[2])), split[3]);
++this.CurrentCommand;
}
public virtual void command_textAboveHead(GameLocation location, GameTime time, string[] split)
{
NPC actorByName = this.getActorByName(split[1]);
if (actorByName != null)
{
int startIndex = this.eventCommands[this.CurrentCommand].IndexOf('"') + 1;
int length = this.eventCommands[this.CurrentCommand].Substring(startIndex).LastIndexOf('"');
actorByName.showTextAboveHead(this.eventCommands[this.CurrentCommand].Substring(startIndex, length));
}
++this.CurrentCommand;
}
public virtual void command_showFrame(GameLocation location, GameTime time, string[] split)
{
if (split.Length > 2 && !split[2].Equals("flip") && !split[1].Contains("farmer"))
{
NPC actorByName = this.getActorByName(split[1]);
if (actorByName != null)
{
int int32 = Convert.ToInt32(split[2]);
if (split[1].Equals("spouse") && actorByName.Gender == 0 && int32 >= 36 && int32 <= 38)
int32 += 12;
actorByName.Sprite.CurrentFrame = int32;
}
}
else
{
Farmer farmer = this.getFarmerFromFarmerNumberString(split[1], this.farmer);
if (split.Length == 2)
farmer = this.farmer;
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)
}.ToArray());
farmer.FarmerSprite.loop = true;
farmer.FarmerSprite.loopThisAnimation = true;
farmer.FarmerSprite.PauseForSingleAnimation = true;
farmer.Sprite.currentFrame = Convert.ToInt32(split[1]);
}
}
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_farmerAnimation(
GameLocation location,
GameTime time,
string[] split)
{
this.farmer.FarmerSprite.setCurrentSingleAnimation(Convert.ToInt32(split[1]));
this.farmer.FarmerSprite.PauseForSingleAnimation = true;
++this.CurrentCommand;
}
public virtual void command_ignoreMovementAnimation(
GameLocation location,
GameTime time,
string[] split)
{
bool flag = true;
if (split.Length > 2)
split[2].Equals("true");
if (split[1].Contains("farmer"))
{
Farmer farmerNumberString = this.getFarmerFromFarmerNumberString(split[1], this.farmer);
if (farmerNumberString != null)
farmerNumberString.ignoreMovementAnimation = flag;
}
else
{
NPC actorByName = this.getActorByName(split[1].Replace('_', ' '));
if (actorByName != null)
actorByName.ignoreMovementAnimation = flag;
}
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_animate(GameLocation location, GameTime time, string[] split)
{
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));
if (split[1].Contains("farmer"))
{
Farmer farmerNumberString = this.getFarmerFromFarmerNumberString(split[1], this.farmer);
if (farmerNumberString != null)
{
farmerNumberString.FarmerSprite.setCurrentAnimation(animation.ToArray());
farmerNumberString.FarmerSprite.loop = true;
farmerNumberString.FarmerSprite.loopThisAnimation = flag;
farmerNumberString.FarmerSprite.PauseForSingleAnimation = true;
}
}
else
{
NPC actorByName = this.getActorByName(split[1].Replace('_', ' '));
if (actorByName != null)
{
actorByName.Sprite.setCurrentAnimation(animation);
actorByName.Sprite.loop = flag;
}
}
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_stopAnimation(GameLocation location, GameTime time, string[] split)
{
if (split[1].Contains("farmer"))
{
Farmer farmerNumberString = this.getFarmerFromFarmerNumberString(split[1], this.farmer);
if (farmerNumberString != null)
{
farmerNumberString.completelyStopAnimatingOrDoingAction();
farmerNumberString.Halt();
farmerNumberString.FarmerSprite.CurrentAnimation = (List<FarmerSprite.AnimationFrame>) null;
switch (farmerNumberString.FacingDirection)
{
case 0:
farmerNumberString.FarmerSprite.setCurrentSingleFrame(12);
break;
case 1:
farmerNumberString.FarmerSprite.setCurrentSingleFrame(6);
break;
case 2:
farmerNumberString.FarmerSprite.setCurrentSingleFrame(0);
break;
case 3:
farmerNumberString.FarmerSprite.setCurrentSingleFrame(6, flip: true);
break;
}
}
}
else
{
NPC actorByName = this.getActorByName(split[1]);
if (actorByName != null)
{
actorByName.Sprite.StopAnimation();
if (split.Length > 2)
{
actorByName.Sprite.currentFrame = Convert.ToInt32(split[2]);
actorByName.Sprite.UpdateSourceRect();
}
}
}
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_showRivalFrame(
GameLocation location,
GameTime time,
string[] split)
{
this.getActorByName("rival").Sprite.currentFrame = Convert.ToInt32(split[1]);
++this.CurrentCommand;
}
public virtual void command_weddingSprite(GameLocation location, GameTime time, string[] split)
{
this.getActorByName("WeddingOutfits").Sprite.currentFrame = Convert.ToInt32(split[1]);
++this.CurrentCommand;
}
public virtual void command_changeLocation(
GameLocation location,
GameTime time,
string[] split)
{
this.changeLocation(split[1], this.farmer.getTileX(), this.farmer.getTileY(), onComplete: ((Action) (() => ++this.CurrentCommand)));
}
public virtual void command_halt(GameLocation location, GameTime time, string[] split)
{
foreach (Character actor in this.actors)
actor.Halt();
this.farmer.Halt();
++this.CurrentCommand;
this.continueAfterMove = false;
this.actorPositionsAfterMove.Clear();
}
public virtual void command_message(GameLocation location, GameTime time, string[] split)
{
if (Game1.dialogueUp || Game1.activeClickableMenu != null)
return;
int startIndex = this.eventCommands[this.CurrentCommand].IndexOf('"') + 1;
int num = this.eventCommands[this.CurrentCommand].LastIndexOf('"');
if (num > 0 && num > startIndex)
Game1.drawDialogueNoTyping(Game1.parseText(this.eventCommands[this.CurrentCommand].Substring(startIndex, num - startIndex)));
else
Game1.drawDialogueNoTyping("...");
}
public virtual void command_addCookingRecipe(
GameLocation location,
GameTime time,
string[] split)
{
Game1.player.cookingRecipes.Add(this.eventCommands[this.CurrentCommand].Substring(this.eventCommands[this.CurrentCommand].IndexOf(' ') + 1), 0);
++this.CurrentCommand;
}
public virtual void command_itemAboveHead(GameLocation location, GameTime time, string[] split)
{
if (split.Length > 1 && split[1].Equals("pan"))
this.farmer.holdUpItemThenMessage((Item) new Pan());
else if (split.Length > 1 && split[1].Equals("hero"))
this.farmer.holdUpItemThenMessage((Item) new Object(Vector2.Zero, 116));
else if (split.Length > 1 && split[1].Equals("sculpture"))
this.farmer.holdUpItemThenMessage((Item) new Furniture(1306, Vector2.Zero));
else if (split.Length > 1 && split[1].Equals("samBoombox"))
this.farmer.holdUpItemThenMessage((Item) new Furniture(1309, Vector2.Zero));
else if (split.Length > 1 && split[1].Equals("joja"))
this.farmer.holdUpItemThenMessage((Item) new Object(Vector2.Zero, 117));
else if (split.Length > 1 && split[1].Equals("slimeEgg"))
this.farmer.holdUpItemThenMessage((Item) new Object(680, 1));
else if (split.Length > 1 && split[1].Equals("rod"))
this.farmer.holdUpItemThenMessage((Item) new FishingRod());
else if (split.Length > 1 && split[1].Equals("sword"))
this.farmer.holdUpItemThenMessage((Item) new MeleeWeapon(0));
else if (split.Length > 1 && split[1].Equals("ore"))
this.farmer.holdUpItemThenMessage((Item) new Object(378, 1), false);
else if (split.Length > 1 && split[1].Equals("pot"))
this.farmer.holdUpItemThenMessage((Item) new Object(Vector2.Zero, 62), false);
else if (split.Length > 1 && split[1].Equals("jukebox"))
this.farmer.holdUpItemThenMessage((Item) new Object(Vector2.Zero, 209), false);
else
this.farmer.holdUpItemThenMessage((Item) null, false);
++this.CurrentCommand;
}
public virtual void command_addCraftingRecipe(
GameLocation location,
GameTime time,
string[] split)
{
if (!Game1.player.craftingRecipes.ContainsKey(this.eventCommands[this.CurrentCommand].Substring(this.eventCommands[this.CurrentCommand].IndexOf(' ') + 1)))
Game1.player.craftingRecipes.Add(this.eventCommands[this.CurrentCommand].Substring(this.eventCommands[this.CurrentCommand].IndexOf(' ') + 1), 0);
++this.CurrentCommand;
}
public virtual void command_hostMail(GameLocation location, GameTime time, string[] split)
{
if (Game1.IsMasterGame && !Game1.player.hasOrWillReceiveMail(split[1]))
Game1.addMailForTomorrow(split[1]);
++this.CurrentCommand;
}
public virtual void command_mail(GameLocation location, GameTime time, string[] split)
{
if (!Game1.player.hasOrWillReceiveMail(split[1]))
Game1.addMailForTomorrow(split[1]);
++this.CurrentCommand;
}
public virtual void command_shake(GameLocation location, GameTime time, string[] split)
{
this.getActorByName(split[1]).shake(Convert.ToInt32(split[2]));
++this.CurrentCommand;
}
public virtual void command_temporarySprite(
GameLocation location,
GameTime time,
string[] split)
{
location.TemporarySprites.Add(new TemporaryAnimatedSprite(Convert.ToInt32(split[3]), this.OffsetPosition(new Vector2((float) (Convert.ToInt32(split[1]) * 64), (float) (Convert.ToInt32(split[2]) * 64))), Microsoft.Xna.Framework.Color.White, Convert.ToInt32(split[4]), split.Length > 6 && split[6] == "true", split.Length > 5 ? (float) Convert.ToInt32(split[5]) : 300f, sourceRectWidth: 64, layerDepth: (split.Length > 7 ? (float) Convert.ToDouble(split[7]) : -1f)));
++this.CurrentCommand;
}
public virtual void command_removeTemporarySprites(
GameLocation location,
GameTime time,
string[] split)
{
location.TemporarySprites.Clear();
++this.CurrentCommand;
}
public virtual void command_null(GameLocation location, GameTime time, string[] split)
{
}
public virtual void command_specificTemporarySprite(
GameLocation location,
GameTime time,
string[] split)
{
this.addSpecificTemporarySprite(split[1], location, split);
++this.CurrentCommand;
}
public virtual void command_playMusic(GameLocation location, GameTime time, string[] split)
{
if (split[1].Equals("samBand"))
{
if (Game1.player.DialogueQuestionsAnswered.Contains(78))
Game1.changeMusicTrack("shimmeringbastion", music_context: Game1.MusicContext.Event);
else if (Game1.player.DialogueQuestionsAnswered.Contains(79))
Game1.changeMusicTrack("honkytonky", music_context: Game1.MusicContext.Event);
else if (Game1.player.DialogueQuestionsAnswered.Contains(77))
Game1.changeMusicTrack("heavy", music_context: Game1.MusicContext.Event);
else
Game1.changeMusicTrack("poppy", music_context: Game1.MusicContext.Event);
}
else if ((double) Game1.options.musicVolumeLevel > 0.0)
{
StringBuilder stringBuilder = new StringBuilder(split[1]);
for (int index = 2; index < split.Length; ++index)
stringBuilder.Append(" " + split[index]);
Game1.changeMusicTrack(stringBuilder.ToString(), music_context: Game1.MusicContext.Event);
}
++this.CurrentCommand;
}
public virtual void command_nameSelect(GameLocation location, GameTime time, string[] split)
{
if (Game1.nameSelectUp)
return;
Game1.showNameSelectScreen(split[1]);
}
public virtual void command_makeInvisible(GameLocation location, GameTime time, string[] split)
{
if (((IEnumerable<string>) split).Count<string>() == 3)
{
int x = this.OffsetTileX(Convert.ToInt32(split[1]));
int y = this.OffsetTileY(Convert.ToInt32(split[2]));
Object objectAtTile = location.getObjectAtTile(x, y);
if (objectAtTile != null)
objectAtTile.isTemporarilyInvisible = true;
}
else
{
int num1 = this.OffsetTileX(Convert.ToInt32(split[1]));
int num2 = this.OffsetTileY(Convert.ToInt32(split[2]));
int int32_1 = Convert.ToInt32(split[3]);
int int32_2 = Convert.ToInt32(split[4]);
for (int x = num1; x < num1 + int32_1; ++x)
{
for (int y = num2; y < num2 + int32_2; ++y)
{
Object objectAtTile = location.getObjectAtTile(x, y);
if (objectAtTile != null)
objectAtTile.isTemporarilyInvisible = true;
else if (location.terrainFeatures.ContainsKey(new Vector2((float) x, (float) y)))
location.terrainFeatures[new Vector2((float) x, (float) y)].isTemporarilyInvisible = true;
}
}
}
++this.CurrentCommand;
}
public virtual void command_addObject(GameLocation location, GameTime time, string[] split)
{
float num = (float) (this.OffsetTileY(Convert.ToInt32(split[2])) * 64) / 10000f;
if (split.Length > 4)
num = Convert.ToSingle(split[4]);
location.TemporarySprites.Add(new TemporaryAnimatedSprite(Convert.ToInt32(split[3]), 9999f, 1, 9999, this.OffsetPosition(new Vector2((float) Convert.ToInt32(split[1]), (float) Convert.ToInt32(split[2])) * 64f), false, false)
{
layerDepth = num
});
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_addBigProp(GameLocation location, GameTime time, string[] split)
{
this.props.Add(new Object(this.OffsetTile(new Vector2((float) Convert.ToInt32(split[1]), (float) Convert.ToInt32(split[2]))), Convert.ToInt32(split[3])));
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_addFloorProp(GameLocation location, GameTime time, string[] split) => this.command_addProp(location, time, split);
public virtual void command_addProp(GameLocation location, GameTime time, string[] split)
{
int tileX1 = this.OffsetTileX(Convert.ToInt32(split[2]));
int tileY1 = this.OffsetTileY(Convert.ToInt32(split[3]));
int int32_1 = Convert.ToInt32(split[1]);
int tilesWideSolid = split.Length > 4 ? Convert.ToInt32(split[4]) : 1;
int tilesHighDraw = split.Length > 5 ? Convert.ToInt32(split[5]) : 1;
int tilesHighSolid = split.Length > 6 ? Convert.ToInt32(split[6]) : tilesHighDraw;
bool solid = !split[0].Contains("Floor");
this.festivalProps.Add(new Prop(this.festivalTexture, int32_1, tilesWideSolid, tilesHighSolid, tilesHighDraw, tileX1, tileY1, solid));
if (split.Length > 7)
{
int int32_2 = Convert.ToInt32(split[7]);
for (int tileX2 = tileX1 + int32_2; tileX2 != tileX1; tileX2 -= Math.Sign(int32_2))
this.festivalProps.Add(new Prop(this.festivalTexture, int32_1, tilesWideSolid, tilesHighSolid, tilesHighDraw, tileX2, tileY1, solid));
}
if (split.Length > 8)
{
int int32_3 = Convert.ToInt32(split[8]);
for (int tileY2 = tileY1 + int32_3; tileY2 != tileY1; tileY2 -= Math.Sign(int32_3))
this.festivalProps.Add(new Prop(this.festivalTexture, int32_1, tilesWideSolid, tilesHighSolid, tilesHighDraw, tileX1, tileY2, solid));
}
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_addToTable(GameLocation location, GameTime time, string[] split)
{
if (location is FarmHouse)
(location as FarmHouse).furniture[0].heldObject.Value = new Object(Vector2.Zero, Convert.ToInt32(split[3]), 1);
else
location.objects[this.OffsetTile(new Vector2((float) Convert.ToInt32(split[1]), (float) Convert.ToInt32(split[2])))].heldObject.Value = new Object(Vector2.Zero, Convert.ToInt32(split[3]), 1);
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_removeObject(GameLocation location, GameTime time, string[] split)
{
Vector2 other = this.OffsetPosition(new Vector2((float) Convert.ToInt32(split[1]), (float) Convert.ToInt32(split[2])) * 64f);
for (int index = location.temporarySprites.Count - 1; index >= 0; --index)
{
if (location.temporarySprites[index].position.Equals(other))
{
location.temporarySprites.RemoveAt(index);
break;
}
}
++this.CurrentCommand;
this.checkForNextCommand(location, time);
}
public virtual void command_glow(GameLocation location, GameTime time, string[] split)
{
bool hold = false;
if (split.Length > 4 && split[4].Equals("true"))
hold = true;
Game1.screenGlowOnce(new Microsoft.Xna.Framework.Color(Convert.ToInt32(split[1]), Convert.ToInt32(split[2]), Convert.ToInt32(split[3])), hold);
++this.CurrentCommand;
}
public virtual void command_stopGlowing(GameLocation location, GameTime time, string[] split)
{
Game1.screenGlowUp = false;
Game1.screenGlowHold = false;
++this.CurrentCommand;
}
public virtual void command_addQuest(GameLocation location, GameTime time, string[] split)
{
Game1.player.addQuest(Convert.ToInt32(split[1]));
++this.CurrentCommand;
}
public virtual void command_removeQuest(GameLocation location, GameTime time, string[] split)
{
Game1.player.removeQuest(Convert.ToInt32(split[1]));
++this.CurrentCommand;
}
public virtual void command_awardFestivalPrize(
GameLocation location,
GameTime time,
string[] split)
{