-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathModuleResourceEnabledIndicator.cs
More file actions
71 lines (63 loc) · 1.91 KB
/
Copy pathModuleResourceEnabledIndicator.cs
File metadata and controls
71 lines (63 loc) · 1.91 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
68
69
70
71
using UnityEngine;
namespace IndicatorLights
{
/// <summary>
/// A controller that sets the display based on whether a resource is enabled/disabled.
/// </summary>
class ModuleResourceEnabledIndicator : ModuleResourceIndicator, IToggle
{
private IColorSource enabledSource = null;
private IColorSource disabledSource = null;
/// <summary>
/// The color to display when the resource is enabled.
/// </summary>
[KSPField]
[ColorSourceIDField]
public string enabledColor = Colors.ToString(DefaultColor.ToggleLED.Value());
/// <summary>
/// The color to display when the resource is disabled.
/// </summary>
[KSPField]
[ColorSourceIDField]
public string disabledColor = ColorSources.Blink(
ColorSources.Constant(DefaultColor.ToggleLED),
900,
ColorSources.Constant(DefaultColor.Off),
300).ColorSourceID;
public override void ParseIDs()
{
base.ParseIDs();
enabledSource = FindColorSource(enabledColor);
disabledSource = FindColorSource(disabledColor);
}
public override bool HasColor
{
get
{
return base.HasColor && CurrentSource.HasColor;
}
}
public override Color OutputColor
{
get { return CurrentSource.OutputColor; }
}
private IColorSource CurrentSource
{
get
{
return ToggleStatus ? enabledSource : disabledSource;
}
}
/// <summary>
/// IToggle implementation.
/// </summary>
public bool ToggleStatus
{
get
{
PartResource resource = Resource;
return (resource != null) && resource.flowState;
}
}
}
}