Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
BooleanSwitch.cs
Go to the documentation of this file.
1namespace System.Diagnostics;
2
3[SwitchLevel(typeof(bool))]
4public class BooleanSwitch : Switch
5{
6 public bool Enabled
7 {
8 get
9 {
10 if (base.SwitchSetting != 0)
11 {
12 return true;
13 }
14 return false;
15 }
16 set
17 {
18 base.SwitchSetting = (value ? 1 : 0);
19 }
20 }
21
22 public BooleanSwitch(string displayName, string? description)
23 : base(displayName, description)
24 {
25 }
26
27 public BooleanSwitch(string displayName, string? description, string defaultSwitchValue)
28 : base(displayName, description, defaultSwitchValue)
29 {
30 }
31
32 protected override void OnValueChanged()
33 {
34 if (bool.TryParse(base.Value, out var result))
35 {
36 base.SwitchSetting = (result ? 1 : 0);
37 }
38 else
39 {
40 base.OnValueChanged();
41 }
42 }
43}
BooleanSwitch(string displayName, string? description, string defaultSwitchValue)
BooleanSwitch(string displayName, string? description)