forked from here-and-now/KRPC.MechJeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeployableController.cs
61 lines (51 loc) · 1.63 KB
/
DeployableController.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
using System;
using System.Reflection;
using KRPC.MechJeb.ExtensionMethods;
using KRPC.Service.Attributes;
namespace KRPC.MechJeb {
[KRPCClass(Service = "MechJeb")]
public class DeployableController : ComputerModule {
internal new const string MechJebType = "MuMech.MechJebModuleDeployableController";
// Fields and methods
private static FieldInfo autoDeploy;
private static MethodInfo extendAll;
private static MethodInfo retractAll;
private static MethodInfo allRetracted;
internal static new void InitType(Type type) {
autoDeploy = type.GetCheckedField("autoDeploy");
extendAll = type.GetCheckedMethod("ExtendAll");
retractAll = type.GetCheckedMethod("RetractAll");
allRetracted = type.GetCheckedMethod("AllRetracted");
}
/// <summary>
/// Automatically deploy modules of this type when controlled by a MechJeb autopilot
/// </summary>
[KRPCProperty]
public bool AutoDeploy {
get => (bool)autoDeploy.GetValue(this.instance);
set => autoDeploy.SetValue(this.instance, value);
}
/// <summary>
/// Extend all deployable modules of this type.
/// </summary>
[KRPCMethod]
public void ExtendAll() {
extendAll.Invoke(this.instance, null);
}
/// <summary>
/// Retract all deployable modules of this type.
/// </summary>
[KRPCMethod]
public void RetractAll() {
retractAll.Invoke(this.instance, null);
}
/// <summary>
/// Check if all deployable modules of this type are retracted.
/// </summary>
/// <returns>True if all modules are retracted; False otherwise</returns>
[KRPCMethod]
public bool AllRetracted() {
return (bool)allRetracted.Invoke(this.instance, null);
}
}
}