forked from here-and-now/KRPC.MechJeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RendezvousAutopilot.cs
49 lines (39 loc) · 1.45 KB
/
RendezvousAutopilot.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
using System;
using System.Reflection;
using KRPC.MechJeb.ExtensionMethods;
using KRPC.Service.Attributes;
namespace KRPC.MechJeb {
[KRPCClass(Service = "MechJeb")]
public class RendezvousAutopilot : KRPCComputerModule {
internal new const string MechJebType = "MuMech.MechJebModuleRendezvousAutopilot";
// Fields and methods
private static FieldInfo desiredDistanceField;
private static FieldInfo maxPhasingOrbitsField;
private static FieldInfo status;
// Instance objects
private object desiredDistance;
private object maxPhasingOrbits;
internal static new void InitType(Type type) {
desiredDistanceField = type.GetCheckedField("desiredDistance");
maxPhasingOrbitsField = type.GetCheckedField("maxPhasingOrbits");
status = type.GetCheckedField("status");
}
protected internal override void InitInstance(object instance) {
base.InitInstance(instance);
this.desiredDistance = desiredDistanceField.GetInstanceValue(instance);
this.maxPhasingOrbits = maxPhasingOrbitsField.GetInstanceValue(instance);
}
[KRPCProperty]
public double DesiredDistance {
get => EditableDouble.Get(this.desiredDistance);
set => EditableDouble.Set(this.desiredDistance, value);
}
[KRPCProperty]
public double MaxPhasingOrbits {
get => EditableDouble.Get(this.maxPhasingOrbits);
set => EditableDouble.Set(this.maxPhasingOrbits, value);
}
[KRPCProperty]
public string Status => status.GetValue(this.instance).ToString();
}
}