forked from Genhis/KRPC.MechJeb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AscentPVG.cs
68 lines (57 loc) · 1.99 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
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 omitCoast;
// Instance objects
private object pitchStartVelocity;
private object pitchRate;
private object desiredApoapsis;
internal static new void InitType(Type type) {
pitchStartVelocityField = type.GetCheckedField("pitchStartVelocity");
pitchRateField = type.GetCheckedField("pitchRate");
desiredApoapsisField = type.GetCheckedField("desiredApoapsis");
omitCoast = type.GetCheckedField("omitCoast");
}
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);
}
[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 OmitCoast {
get => (bool)omitCoast.GetValue(this.instance);
set => omitCoast.SetValue(this.instance, value);
}
}
}