-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathModuleDockingStateIndicator.cs
More file actions
67 lines (58 loc) · 2.06 KB
/
Copy pathModuleDockingStateIndicator.cs
File metadata and controls
67 lines (58 loc) · 2.06 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
using UnityEngine;
namespace IndicatorLights
{
/// <summary>
/// Controls color based on the docking state (docked, undocked, engaged, disengaging).
/// </summary>
class ModuleDockingStateIndicator : ModuleSourceIndicator<ModuleDockingNode>, IToggle
{
private const string ACQUIRE = "Acquire";
private const string DISENGAGE = "Disengage";
[KSPField]
[ColorSourceIDField]
public string readyColor = string.Empty;
[KSPField]
[ColorSourceIDField]
public string acquireColor = string.Empty;
[KSPField]
[ColorSourceIDField]
public string disengageColor = string.Empty;
private IColorSource ready = null;
private IColorSource acquire = null;
private IColorSource disengage = null;
public override void ParseIDs()
{
base.ParseIDs();
ready = FindColorSource(readyColor);
acquire = FindColorSource(acquireColor);
disengage = FindColorSource(disengageColor);
}
public override Color OutputColor
{
get
{
if (SourceModule == null) return ready.OutputColor;
string state = SourceModule.state;
if (string.IsNullOrEmpty(state)) return ready.OutputColor;
if (state.StartsWith(ACQUIRE)) return acquire.OutputColor;
if (state.StartsWith(DISENGAGE)) return disengage.OutputColor;
return ready.OutputColor;
}
}
/// <summary>
/// IToggle implementation.
/// </summary>
public bool ToggleStatus
{
get
{
// Toggle is considered "on" when we're engaging or disengaging, off at all other times.
if (SourceModule == null) return false;
string state = SourceModule.state;
return string.IsNullOrEmpty(state)
|| state.StartsWith(ACQUIRE)
|| state.StartsWith(DISENGAGE);
}
}
}
}