forked from Genhis/KRPC.MechJeb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
SmartRCS.cs
50 lines (40 loc) · 1.2 KB
/
SmartRCS.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
using System;
using System.Reflection;
using KRPC.MechJeb.ExtensionMethods;
using KRPC.Service.Attributes;
namespace KRPC.MechJeb {
[KRPCClass(Service = "MechJeb")]
public class SmartRCS : DisplayModule {
internal const string MechJebType = "MuMech.MechJebModuleSmartRcs";
// Fields and methods
private static FieldInfo target;
private static FieldInfo autoDisableSmartRCS;
private static MethodInfo engage;
internal static new void InitType(Type type) {
target = type.GetCheckedField("target");
autoDisableSmartRCS = type.GetCheckedField("autoDisableSmartRCS");
engage = type.GetCheckedMethod("Engage");
}
[KRPCProperty]
public bool AutoDisableSmartRCS {
get => (bool)autoDisableSmartRCS.GetValue(this.instance);
set => autoDisableSmartRCS.SetValue(this.instance, value);
}
[KRPCProperty]
public SmartRCSMode Mode {
get => (SmartRCSMode)target.GetValue(this.instance);
set {
target.SetValue(this.instance, (int)value);
engage.Invoke(this.instance, null);
}
}
[KRPCProperty]
public RCSController RCSController => MechJeb.RCSController;
}
[KRPCEnum(Service = "MechJeb")]
public enum SmartRCSMode {
Off,
ZeroRelativeVelocity,
ZeroVelocity
}
}