-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathConfigCommand.cs
155 lines (136 loc) · 7.28 KB
/
ConfigCommand.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
using Terraria;
using Terraria.ModLoader;
namespace MechScope
{
internal class ConfigCommand : ModCommand
{
public override string Command { get { return "msconfig"; } }
public override CommandType Type { get { return CommandType.World; } }
public override string Usage
{
get
{
return "/msconfig [setting]\n" +
"/msconfig [setting] [value]\nPossible settings: arate, smode, tvis\n" +
"Valid values for smode: single, wire, source, stage\n" +
"Valid values for tvis: wireskip, gatesdone, gatesnext, lamps, teleporters, pumps";
}
}
public override string Description { get { return "Sets various settings for MechScope"; } }
public override void Action(CommandCaller caller, string input, string[] args)
{
if (args.Length < 1)
{
Main.NewText("see '/help msconfig'");
return;
}
if (args.Length == 1)
{
string val;
switch (args[0])
{
case "arate": val = AutoStepWorld.Rate.ToString(); break;
case "smode": val = SuspendableWireManager.Mode.ToString(); break;
case "tvis": val = string.Format("wireskip = {0}; gatesdone = {1}; gatesnext = {2}, lamps = {3}, teleporters = {4}, pumps = {5}", VisualizerWorld.ShowWireSkip, VisualizerWorld.ShowGatesDone, VisualizerWorld.ShowUpcomingGates, VisualizerWorld.ShowTriggeredLamps, VisualizerWorld.ShowTeleporters, VisualizerWorld.ShowPumps); break;
default: val = "not a valid setting (see '/help msconfig')"; break;
}
Main.NewText(args[0] + " is " + val);
}
else
{
switch (args[0])
{
case "arate":
int newRate;
if (int.TryParse(args[1], out newRate) && newRate > 0)
{
AutoStepWorld.Rate = newRate;
Main.NewText(string.Format("Auto step now happens every {0} frames.", newRate));
}
else
{
Main.NewText(args[1] + " is not a valid number");
}
break;
case "smode":
switch (args[1])
{
case "single":
SuspendableWireManager.Mode = SuspendableWireManager.SuspendMode.perSingle;
Main.NewText("Now suspending after every wire search step");
break;
case "wire":
SuspendableWireManager.Mode = SuspendableWireManager.SuspendMode.perWire;
Main.NewText("Now suspending after each wire");
break;
case "source":
SuspendableWireManager.Mode = SuspendableWireManager.SuspendMode.perSource;
Main.NewText("Now suspending after every activation source");
break;
case "stage":
SuspendableWireManager.Mode = SuspendableWireManager.SuspendMode.perStage;
Main.NewText("Now suspending after every logic gate execution step");
break;
default:
Main.NewText("Valid modes: single, wire, source, step");
break;
}
break;
case "tvis":
switch (args[1])
{
case "wireskip":
VisualizerWorld.ShowWireSkip = !VisualizerWorld.ShowWireSkip;
if (VisualizerWorld.ShowWireSkip)
Main.NewText("Now marking tiles explicitly marked for skipping");
else
Main.NewText("Now not marking tiles explicitly marked for skipping");
break;
case "gatesdone":
VisualizerWorld.ShowGatesDone = !VisualizerWorld.ShowGatesDone;
if (VisualizerWorld.ShowGatesDone)
Main.NewText("Now marking gates that have already triggered in iteration");
else
Main.NewText("Now not marking gates that have already triggered in iteration");
break;
case "gatesnext":
VisualizerWorld.ShowUpcomingGates = !VisualizerWorld.ShowUpcomingGates;
if (VisualizerWorld.ShowUpcomingGates)
Main.NewText("Now marking gates queued up for triggering");
else
Main.NewText("Now not marking gates queued up for triggering");
break;
case "lamps":
VisualizerWorld.ShowTriggeredLamps = !VisualizerWorld.ShowTriggeredLamps;
if (VisualizerWorld.ShowTriggeredLamps)
Main.NewText("Now marking lamp that were triggered, but not checked yet");
else
Main.NewText("Now not marking lamp that were triggered, but not checked yet");
break;
case "teleporters":
VisualizerWorld.ShowTeleporters = !VisualizerWorld.ShowTeleporters;
if (VisualizerWorld.ShowTeleporters)
Main.NewText("Now marking teleporter trigger order");
else
Main.NewText("Now not marking teleporter trigger order");
break;
case "pumps":
VisualizerWorld.ShowPumps = !VisualizerWorld.ShowPumps;
if (VisualizerWorld.ShowPumps)
Main.NewText("Now marking pump trigger order");
else
Main.NewText("Now not marking pump trigger order");
break;
default:
Main.NewText("Valid values: wireskip, gatesdone, gatesnext, lamps, teleporters, pumps");
break;
}
break;
default:
Main.NewText(args[1] + " is not a valid setting (see '/help msconfig')");
break;
}
}
}
}
}