-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathModuleDataTransmitterIndicator.cs
More file actions
85 lines (74 loc) · 2.52 KB
/
Copy pathModuleDataTransmitterIndicator.cs
File metadata and controls
85 lines (74 loc) · 2.52 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using UnityEngine;
namespace IndicatorLights
{
/// <summary>
/// Module that shows when an antenna is transmitting data.
/// </summary>
class ModuleDataTransmitterIndicator : ModuleSourceIndicator<ModuleDataTransmitter>, IToggle
{
private IColorSource busySource;
private IColorSource inactiveSource;
private ModuleDeployableAntenna deployable = null;
/// <summary>
/// The data rate of the transmitter, in mits/second.
/// </summary>
[StaticField]
private double dataRate;
/*
To put things in perspective, here are the data rates of the stock KSP antennas, as of KSP 1.2:
RA-2: 2.86
Communotron 16: 3.33
Communotron 16-S: 3.33
DTS-M1: 5.71
HG-5: 5.71
RA-15: 5.71
RA-100: 11.43
88-88: 20.00
HG-55: 20.00
*/
/// <summary>
/// The color to display when the transmitter is busy.
/// </summary>
[KSPField]
[ColorSourceIDField]
public string busyColor = ColorSources.Random(
ColorSources.Constant(DefaultColor.ToggleLED),
ColorSources.Constant(DefaultColor.Off),
100,
0.5)
.ColorSourceID;
/// <summary>
/// The color to display when the transmitter is idle.
/// </summary>
[KSPField]
[ColorSourceIDField]
public string inactiveColor = ColorSources.Constant(DefaultColor.Off).ColorSourceID;
public override void OnStart(StartState state)
{
base.OnStart(state);
deployable = part.FindModuleImplementing<ModuleDeployableAntenna>(); // may be null
}
public override void ParseIDs()
{
base.ParseIDs();
dataRate = (SourceModule == null) ? 0.0 : SourceModule.DataRate;
busySource = FindColorSource(busyColor);
inactiveSource = FindColorSource(inactiveColor);
}
public override Color OutputColor
{
get
{
return (ToggleStatus ? busySource : inactiveSource).OutputColor;
}
}
public bool ToggleStatus
{
get
{
return ((deployable == null) || (deployable.deployState == ModuleDeployablePart.DeployState.EXTENDED))
&& (SourceModule != null) && SourceModule.IsBusy();
}
}
}
}