forked from E-riCA0/StawdewValley
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRumble.cs
82 lines (75 loc) · 2.96 KB
/
Rumble.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
// Decompiled with JetBrains decompiler
// Type: StardewValley.Rumble
// 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.Input;
namespace StardewValley
{
public static class Rumble
{
private static float rumbleTimerMax;
private static float rumbleTimerCurrent;
private static float rumbleDuringFade;
private static float maxRumbleDuringFade;
private static bool isRumbling;
private static bool fade;
public static void update(float milliseconds)
{
if (!Rumble.isRumbling || !Game1.options.gamepadControls)
return;
Rumble.rumbleTimerCurrent += milliseconds;
if (Rumble.fade)
{
if ((double) Rumble.rumbleTimerCurrent > (double) Rumble.rumbleTimerMax - 1000.0)
Rumble.rumbleDuringFade = Rumble.maxRumbleDuringFade - Rumble.maxRumbleDuringFade * (float) (((double) Rumble.rumbleTimerMax - (double) Rumble.rumbleTimerCurrent) / 1000.0);
GamePad.SetVibration(Game1.playerOneIndex, Rumble.rumbleDuringFade, Rumble.rumbleDuringFade);
}
if ((double) Rumble.rumbleTimerCurrent <= (double) Rumble.rumbleTimerMax)
return;
int num = 500;
while (!GamePad.SetVibration(Game1.playerOneIndex, 0.0f, 0.0f) && num > 0)
--num;
Rumble.isRumbling = false;
}
public static void stopRumbling()
{
int num = 0;
while (GamePad.GetState(Game1.playerOneIndex).IsConnected && !GamePad.SetVibration(Game1.playerOneIndex, 0.0f, 0.0f) && num < 5)
++num;
Rumble.isRumbling = false;
}
public static void rumble(float leftPower, float rightPower, float milliseconds)
{
if (Rumble.isRumbling || !Game1.options.gamepadControls || !Game1.options.rumble)
return;
Rumble.rumbleTimerCurrent = 0.0f;
Rumble.fade = false;
Rumble.rumbleTimerMax = milliseconds;
Rumble.isRumbling = true;
GamePad.SetVibration(Game1.playerOneIndex, leftPower, rightPower);
}
public static void rumble(float power, float milliseconds)
{
if (Rumble.isRumbling || !Game1.options.gamepadControls || !Game1.options.rumble)
return;
Rumble.fade = false;
Rumble.rumbleTimerCurrent = 0.0f;
Rumble.rumbleTimerMax = milliseconds;
Rumble.isRumbling = true;
GamePad.SetVibration(Game1.playerOneIndex, power, power);
}
public static void rumbleAndFade(float power, float milliseconds)
{
if (Rumble.isRumbling || !Game1.options.gamepadControls || !Game1.options.rumble)
return;
Rumble.rumbleTimerCurrent = 0.0f;
Rumble.rumbleTimerMax = milliseconds;
Rumble.isRumbling = true;
GamePad.SetVibration(Game1.playerOneIndex, power, power);
Rumble.fade = true;
Rumble.rumbleDuringFade = power;
Rumble.maxRumbleDuringFade = power;
}
}
}