-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathInput2.cs
93 lines (79 loc) · 3.95 KB
/
Input2.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
using StardewValley;
using StardewValley.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Starbot
{
public class Input2 : IInputSimulator
{
public static bool Installed { get; set;
}
public Input2()
{
}
public void Update()
{
}
public void InstallSimulator()
{
Mod.instance.Monitor.Log("Input simulator installed.", StardewModdingAPI.LogLevel.Info);
Installed = true;
typeof(Game1).GetField("inputSimulator", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, this);
}
public void UninstallSimulator()
{
Mod.instance.Monitor.Log("Input simulator uninstalled.", StardewModdingAPI.LogLevel.Info);
Installed = false;
typeof(Game1).GetField("inputSimulator", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, null);
}
public void StartActionButton() { ActionButtonPressed = true; }
public void StopActionButton() { ActionButtonPressed = false; }
public void StartSwitchTool() { SwitchToolButtonPressed = true; }
public void StopSwitchTool() { SwitchToolButtonPressed = false; }
public void StartUseTool() { UseToolButtonPressed = true; UseToolButtonReleased = false; }
public void StopUseTool() { UseToolButtonPressed = false; UseToolButtonReleased = true; }
public void StartMoveLeft(){MoveLeftHeld = true;}
public void StopMoveLeft(){MoveLeftHeld = false;}
public void StartMoveRight(){MoveRightHeld = true;}
public void StopMoveRight(){MoveRightHeld = false;}
public void StartMoveUp() { MoveUpHeld = true; }
public void StopMoveUp() { MoveUpHeld = false; }
public void StartMoveDown() { MoveDownHeld = true; }
public void StopMoveDown() { MoveDownHeld = false; }
private bool ActionButtonPressed = false;
private bool SwitchToolButtonPressed = false;
private bool UseToolButtonPressed = false;
private bool UseToolButtonReleased = false;
private bool AddItemToInventoryButtonPressed = false;
private bool CancelButtonPressed = false;
private bool MoveDownHeld = false;
private bool MoveUpHeld = false;
private bool MoveRightHeld = false;
private bool MoveLeftHeld = false;
public void SimulateInput(ref bool actionButtonPressed, ref bool switchToolButtonPressed, ref bool useToolButtonPressed, ref bool useToolButtonReleased, ref bool addItemToInventoryButtonPressed, ref bool cancelButtonPressed, ref bool moveUpPressed, ref bool moveRightPressed, ref bool moveLeftPressed, ref bool moveDownPressed, ref bool moveUpReleased, ref bool moveRightReleased, ref bool moveLeftReleased, ref bool moveDownReleased, ref bool moveUpHeld, ref bool moveRightHeld, ref bool moveLeftHeld, ref bool moveDownHeld)
{
actionButtonPressed = ActionButtonPressed;
switchToolButtonPressed = SwitchToolButtonPressed;
useToolButtonPressed = UseToolButtonPressed;
useToolButtonReleased = UseToolButtonReleased;
addItemToInventoryButtonPressed = AddItemToInventoryButtonPressed;
cancelButtonPressed = CancelButtonPressed;
moveUpPressed = false;// MoveUpPressed;
moveRightPressed = false;// MoveRightPressed;
moveLeftPressed = false;// MoveLeftPressed;
moveDownPressed = false;// MoveDownPressed;
moveUpReleased = false;// MoveUpReleased;
moveRightReleased = false;// MoveRightReleased;
moveLeftReleased = false;// MoveLeftReleased;
moveDownReleased = false;// MoveDownReleased;
moveUpHeld = MoveUpHeld;
moveRightHeld = MoveRightHeld;
moveLeftHeld = MoveLeftHeld;
moveDownHeld = MoveDownHeld;
}
}
}