forked from E-riCA0/StawdewValley
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDelayedAction.cs
More file actions
221 lines (193 loc) · 7.4 KB
/
DelayedAction.cs
File metadata and controls
221 lines (193 loc) · 7.4 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
// Decompiled with JetBrains decompiler
// Type: StardewValley.DelayedAction
// 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;
namespace StardewValley
{
public class DelayedAction
{
public int timeUntilAction;
public float floatData;
public string stringData;
public Point pointData;
public NPC character;
public GameLocation location;
public DelayedAction.delayedBehavior behavior;
public Game1.afterFadeFunction afterFadeBehavior;
public bool waitUntilMenusGone;
public TemporaryAnimatedSprite temporarySpriteData;
public DelayedAction(int timeUntilAction)
{
this.timeUntilAction = timeUntilAction;
}
public DelayedAction(int timeUntilAction, DelayedAction.delayedBehavior behavior)
{
this.timeUntilAction = timeUntilAction;
this.behavior = behavior;
}
public bool update(GameTime time)
{
if (!this.waitUntilMenusGone || Game1.activeClickableMenu == null)
{
this.timeUntilAction = this.timeUntilAction - time.ElapsedGameTime.Milliseconds;
if (this.timeUntilAction <= 0)
this.behavior();
}
return this.timeUntilAction <= 0;
}
public static void warpAfterDelay(string nameToWarpTo, Point pointToWarp, int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.warp);
delayedAction.stringData = nameToWarpTo;
delayedAction.pointData = pointToWarp;
Game1.delayedActions.Add(delayedAction);
}
public static void addTemporarySpriteAfterDelay(TemporaryAnimatedSprite t, GameLocation l, int timer, bool waitUntilMenusGone = false)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.addTempSprite);
delayedAction.temporarySpriteData = t;
delayedAction.location = l;
delayedAction.waitUntilMenusGone = waitUntilMenusGone;
Game1.delayedActions.Add(delayedAction);
}
public static void playSoundAfterDelay(string soundName, int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.playSound);
delayedAction.stringData = soundName;
Game1.delayedActions.Add(delayedAction);
}
public static void removeTemporarySpriteAfterDelay(GameLocation location, float idOfTempSprite, int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.removeTemporarySprite);
delayedAction.location = location;
delayedAction.floatData = idOfTempSprite;
Game1.delayedActions.Add(delayedAction);
}
public static void playMusicAfterDelay(string musicName, int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.changeMusicTrack);
delayedAction.stringData = musicName;
Game1.delayedActions.Add(delayedAction);
}
public static void textAboveHeadAfterDelay(string text, NPC who, int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.showTextAboveHead);
delayedAction.stringData = text;
delayedAction.character = who;
Game1.delayedActions.Add(delayedAction);
}
public static void stopFarmerGlowing(int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.stopGlowing);
Game1.delayedActions.Add(delayedAction);
}
public static void showDialogueAfterDelay(string dialogue, int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.showDialogue);
delayedAction.stringData = dialogue;
Game1.delayedActions.Add(delayedAction);
}
public static void screenFlashAfterDelay(float intensity, int timer, string sound = "")
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.screenFlash);
delayedAction.stringData = sound;
delayedAction.floatData = intensity;
Game1.delayedActions.Add(delayedAction);
}
public static void removeTileAfterDelay(int x, int y, int timer, GameLocation l, string whichLayer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.removeBuildingsTile);
delayedAction.pointData = new Point(x, y);
delayedAction.location = l;
delayedAction.stringData = whichLayer;
Game1.delayedActions.Add(delayedAction);
}
public static void fadeAfterDelay(Game1.afterFadeFunction behaviorAfterFade, int timer)
{
DelayedAction delayedAction = new DelayedAction(timer);
delayedAction.behavior = new DelayedAction.delayedBehavior(delayedAction.doGlobalFade);
delayedAction.afterFadeBehavior = behaviorAfterFade;
Game1.delayedActions.Add(delayedAction);
}
public void doGlobalFade()
{
Game1.globalFadeToBlack(this.afterFadeBehavior, 0.02f);
}
public void showTextAboveHead()
{
if (this.character == null || this.stringData == null)
return;
this.character.showTextAboveHead(this.stringData, -1, 2, 3000, 0);
}
public void addTempSprite()
{
if (this.location == null || this.temporarySpriteData == null)
return;
this.location.TemporarySprites.Add(this.temporarySpriteData);
}
public void stopGlowing()
{
Game1.player.stopGlowing();
Game1.player.stopJittering();
Game1.screenGlowHold = false;
if (!Game1.isFestival() || !Game1.currentSeason.Equals("fall"))
return;
Game1.changeMusicTrack("fallFest");
}
public void showDialogue()
{
Game1.drawObjectDialogue(this.stringData);
}
public void warp()
{
if (this.stringData == null)
return;
Point pointData = this.pointData;
Game1.warpFarmer(this.stringData, this.pointData.X, this.pointData.Y, false);
}
public void removeBuildingsTile()
{
Point pointData = this.pointData;
if (this.location == null || this.stringData == null)
return;
this.location.removeTile(this.pointData.X, this.pointData.Y, this.stringData);
}
public void removeTemporarySprite()
{
if (this.location == null)
return;
this.location.removeTemporarySpritesWithID(this.floatData);
}
public void playSound()
{
if (this.stringData == null)
return;
Game1.playSound(this.stringData);
}
public void changeMusicTrack()
{
if (this.stringData == null)
return;
Game1.changeMusicTrack(this.stringData);
}
public void screenFlash()
{
if (this.stringData != null && this.stringData.Length > 0)
Game1.playSound(this.stringData);
Game1.flashAlpha = this.floatData;
}
public delegate void delayedBehavior();
}
}