forked from here-and-now/KRPC.MechJeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
StagingController.cs
139 lines (116 loc) · 4.96 KB
/
StagingController.cs
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Reflection;
using KRPC.MechJeb.ExtensionMethods;
using KRPC.Service.Attributes;
namespace KRPC.MechJeb {
[KRPCClass(Service = "MechJeb")]
public class StagingController : KRPCComputerModule {
internal new const string MechJebType = "MuMech.MechJebModuleStagingController";
// Fields and methods
private static FieldInfo autostagePreDelayField;
private static FieldInfo autostagePostDelayField;
private static FieldInfo autostageLimitField;
private static FieldInfo fairingMaxDynamicPressureField;
private static FieldInfo fairingMinAltitudeField;
private static FieldInfo clampAutoStageThrustPctField;
private static FieldInfo fairingMaxAerothermalFluxField;
private static FieldInfo hotStaging;
private static FieldInfo hotStagingLeadTimeField;
private static FieldInfo autostagingOnce;
// Instance objects
private object autostagePreDelay;
private object autostagePostDelay;
private object autostageLimit;
private object fairingMaxDynamicPressure;
private object fairingMinAltitude;
private object clampAutoStageThrustPct;
private object fairingMaxAerothermalFlux;
private object hotStagingLeadTime;
internal static new void InitType(Type type) {
autostagePreDelayField = type.GetCheckedField("autostagePreDelay");
autostagePostDelayField = type.GetCheckedField("autostagePostDelay");
autostageLimitField = type.GetCheckedField("autostageLimit");
fairingMaxDynamicPressureField = type.GetCheckedField("fairingMaxDynamicPressure");
fairingMinAltitudeField = type.GetCheckedField("fairingMinAltitude");
clampAutoStageThrustPctField = type.GetCheckedField("clampAutoStageThrustPct");
fairingMaxAerothermalFluxField = type.GetCheckedField("fairingMaxAerothermalFlux");
hotStaging = type.GetCheckedField("hotStaging");
hotStagingLeadTimeField = type.GetCheckedField("hotStagingLeadTime");
autostagingOnce = type.GetCheckedField("autostagingOnce");
}
protected internal override void InitInstance(object instance) {
base.InitInstance(instance);
this.autostagePreDelay = autostagePreDelayField.GetInstanceValue(instance);
this.autostagePostDelay = autostagePostDelayField.GetInstanceValue(instance);
this.autostageLimit = autostageLimitField.GetInstanceValue(instance);
this.fairingMaxDynamicPressure = fairingMaxDynamicPressureField.GetInstanceValue(instance);
this.fairingMinAltitude = fairingMinAltitudeField.GetInstanceValue(instance);
this.clampAutoStageThrustPct = clampAutoStageThrustPctField.GetInstanceValue(instance);
this.fairingMaxAerothermalFlux = fairingMaxAerothermalFluxField.GetInstanceValue(instance);
this.hotStagingLeadTime = hotStagingLeadTimeField.GetInstanceValue(instance);
}
/// <summary>
/// The autopilot will pause the actual staging before ? seconds for each stage.
/// </summary>
[KRPCProperty]
public double AutostagePreDelay {
get => EditableDouble.Get(this.autostagePreDelay);
set => EditableDouble.Set(this.autostagePreDelay, value);
}
/// <summary>
/// The autopilot will pause the actual staging after ? seconds for each stage.
/// </summary>
[KRPCProperty]
public double AutostagePostDelay {
get => EditableDouble.Get(this.autostagePostDelay);
set => EditableDouble.Set(this.autostagePostDelay, value);
}
/// <summary>
/// Stop at the selected stage - staging will not occur beyond this stage number.
/// </summary>
[KRPCProperty]
public int AutostageLimit {
get => EditableInt.Get(this.autostageLimit);
set => EditableInt.Set(this.autostageLimit, value);
}
[KRPCProperty]
public double FairingMaxDynamicPressure {
get => EditableDouble.Get(this.fairingMaxDynamicPressure);
set => EditableDouble.Set(this.fairingMaxDynamicPressure, value);
}
[KRPCProperty]
public double FairingMinAltitude {
get => EditableDouble.Get(this.fairingMinAltitude);
set => EditableDouble.Set(this.fairingMinAltitude, value);
}
[KRPCProperty]
public double ClampAutoStageThrustPct {
get => EditableDouble.Get(this.clampAutoStageThrustPct);
set => EditableDouble.Set(this.clampAutoStageThrustPct, value);
}
[KRPCProperty]
public double FairingMaxAerothermalFlux {
get => EditableDouble.Get(this.fairingMaxAerothermalFlux);
set => EditableDouble.Set(this.fairingMaxAerothermalFlux, value);
}
[KRPCProperty]
public bool HotStaging {
get => (bool)hotStaging.GetValue(this.instance);
set => hotStaging.SetValue(this.instance, value);
}
[KRPCProperty]
public double HotStagingLeadTime {
get => EditableDouble.Get(this.hotStagingLeadTime);
set => EditableDouble.Set(this.hotStagingLeadTime, value);
}
/// <summary>
/// The autostaging mode. If set to true, it will automatically disable itself after one staging action.
/// </summary>
/// <remarks>The controller needs to be enabled for this to work.</remarks>
[KRPCProperty]
public bool AutostagingOnce {
get => (bool)autostagingOnce.GetValue(this.instance);
set => autostagingOnce.SetValue(this.instance, value);
}
}
}