-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathAscentPVG.cs
124 lines (107 loc) · 4.13 KB
/
AscentPVG.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
using System;
using System.Reflection;
using KRPC.MechJeb.ExtensionMethods;
using KRPC.Service.Attributes;
namespace KRPC.MechJeb {
/// <summary>
/// The Primer Vector Guidance (RSS/RO) profile.
/// </summary>
[KRPCClass(Service = "MechJeb")]
public class AscentPVG : AscentBase {
internal new const string MechJebType = "MuMech.MechJebModuleAscentPVG";
// Fields and methods
private static FieldInfo pitchStartVelocityField;
private static FieldInfo pitchRateField;
private static FieldInfo desiredApoapsisField;
private static FieldInfo attachAltFlag;
private static FieldInfo desiredAttachAltField;
private static FieldInfo dynamicPressureTriggerField;
private static FieldInfo stagingTriggerField;
private static FieldInfo stagingTriggerFlag;
private static FieldInfo fixedCoast;
private static FieldInfo fixedCoastLengthField;
// Instance objects
private object pitchStartVelocity;
private object pitchRate;
private object desiredApoapsis;
private object desiredAttachAlt;
private object dynamicPressureTrigger;
private object stagingTrigger;
private object fixedCoastLength;
internal static new void InitType(Type type) {
pitchStartVelocityField = type.GetCheckedField("PitchStartVelocity");
pitchRateField = type.GetCheckedField("PitchRate");
desiredApoapsisField = type.GetCheckedField("DesiredApoapsis");
attachAltFlag = type.GetCheckedField("AttachAltFlag");
desiredAttachAltField = type.GetCheckedField("DesiredAttachAlt");
dynamicPressureTriggerField = type.GetCheckedField("DynamicPressureTrigger");
stagingTriggerField = type.GetCheckedField("StagingTrigger");
stagingTriggerFlag = type.GetCheckedField("StagingTriggerFlag");
fixedCoast = type.GetCheckedField("FixedCoast");
fixedCoastLengthField = type.GetCheckedField("FixedCoastLength");
}
protected internal override void InitInstance(object instance) {
base.InitInstance(instance);
this.pitchStartVelocity = pitchStartVelocityField.GetInstanceValue(instance);
this.pitchRate = pitchRateField.GetInstanceValue(instance);
this.desiredApoapsis = desiredApoapsisField.GetInstanceValue(instance);
this.desiredAttachAlt = desiredAttachAltField.GetInstanceValue(instance);
this.dynamicPressureTrigger = dynamicPressureTriggerField.GetInstanceValue(instance);
this.stagingTrigger = stagingTriggerField.GetInstanceValue(instance);
this.fixedCoastLength = fixedCoastLengthField.GetInstanceValue(instance);
}
[KRPCProperty]
public double PitchStartVelocity {
get => EditableDouble.Get(this.pitchStartVelocity);
set => EditableDouble.Set(this.pitchStartVelocity, value);
}
[KRPCProperty]
public double PitchRate {
get => EditableDouble.Get(this.pitchRate);
set => EditableDouble.Set(this.pitchRate, value);
}
/// <summary>
/// The target apoapsis in meters.
/// </summary>
[KRPCProperty]
public double DesiredApoapsis {
get => EditableDouble.Get(this.desiredApoapsis);
set => EditableDouble.Set(this.desiredApoapsis, value);
}
[KRPCProperty]
public bool AttachAltFlag {
get => (bool)attachAltFlag.GetValue(this.instance);
set => attachAltFlag.SetValue(this.instance, value);
}
[KRPCProperty]
public double DesiredAttachAlt {
get => EditableDouble.Get(this.desiredAttachAlt);
set => EditableDouble.Set(this.desiredAttachAlt, value);
}
[KRPCProperty]
public double DynamicPressureTrigger {
get => EditableDouble.Get(this.dynamicPressureTrigger);
set => EditableDouble.Set(this.dynamicPressureTrigger, value);
}
[KRPCProperty]
public int StagingTrigger {
get => EditableInt.Get(this.stagingTrigger);
set => EditableInt.Set(this.stagingTrigger, value);
}
[KRPCProperty]
public bool StagingTriggerFlag {
get => (bool)stagingTriggerFlag.GetValue(this.instance);
set => stagingTriggerFlag.SetValue(this.instance, value);
}
[KRPCProperty]
public bool FixedCoast {
get => (bool)fixedCoast.GetValue(this.instance);
set => fixedCoast.SetValue(this.instance, value);
}
[KRPCProperty]
public double FixedCoastLength {
get => EditableDouble.Get(this.fixedCoastLength);
set => EditableDouble.Set(this.fixedCoastLength, value);
}
}
}