-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathModuleBiomeScannerIndicator.cs
More file actions
78 lines (69 loc) · 2.21 KB
/
Copy pathModuleBiomeScannerIndicator.cs
File metadata and controls
78 lines (69 loc) · 2.21 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
using UnityEngine;
namespace IndicatorLights
{
/// <summary>
/// Indicates whether the current biome can be surface-scanned or not.
/// </summary>
class ModuleBiomeScannerIndicator : ModuleSourceIndicator<ModuleBiomeScanner>, IToggle
{
private IColorSource readySource;
private IColorSource inactiveSource;
/// <summary>
/// The color to display when it's ready to take a biome scan.
/// </summary>
[KSPField]
[ColorSourceIDField]
public string readyColor = string.Empty;
/// <summary>
/// The color to display when it's inactive (either this biome has already been
/// scanned, or else it's not in a usable situation).
/// </summary>
[KSPField]
[ColorSourceIDField]
public string inactiveColor = Colors.ToString(DefaultColor.Off);
public override void ParseIDs()
{
base.ParseIDs();
readySource = FindColorSource(readyColor);
inactiveSource = FindColorSource(inactiveColor);
}
public override bool HasColor
{
get
{
return CurrentSource.HasColor;
}
}
public override Color OutputColor
{
get
{
return CurrentSource.OutputColor;
}
}
private IColorSource CurrentSource
{
get
{
return ToggleStatus ? readySource : inactiveSource;
}
}
/// <summary>
/// IToggle implementation.
/// </summary>
public bool ToggleStatus
{
get
{
// If we're in the editor, or not landed, then it's inactive.
if (!HighLogic.LoadedSceneIsFlight
|| (vessel == null)
|| !vessel.LandedOrSplashed)
return false;
// Figure out what biome we're in
string biomeName = vessel.GetCurrentBiome() ?? vessel.situation.ToString();
return !ResourceMap.Instance.IsBiomeUnlocked(vessel.mainBody.flightGlobalsIndex, biomeName);
}
}
}
}