-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnloadOverride.cs
54 lines (47 loc) · 1.45 KB
/
UnloadOverride.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
public class UnloadOverride : PartModule
{
[KSPField(isPersistant = true)]
public bool overrideControl = false;
[KSPField]
public float overrideDistance = 300000;
[KSPField(guiActive = true, guiName = "Unload override is ")]
public string overrideState = "Disabled";
[KSPEvent(guiActive = true, guiName = "Toggle Override", guiActiveUnfocused = true, unfocusedRange = 0)]
public void toggleUnloadOverride ()
{
overrideControl = !overrideControl;
}
[KSPAction("Toggle Unload")]
public void ToggleAction(KSPActionParam param)
{
overrideControl = !overrideControl;
}
public void FixedUpdate()
{
if (HighLogic.LoadedSceneIsFlight == true) {
if (overrideControl == true) {
overrideState = "Enabled";
this.vessel.distancePackThreshold = overrideDistance;
this.vessel.distanceLandedPackThreshold = overrideDistance;
Vessel.unloadDistance = overrideDistance - 250;
Vessel.loadDistance = overrideDistance;
} else {
overrideState = "Disabled";
this.vessel.distancePackThreshold = 2500;
this.vessel.distanceLandedPackThreshold = 350;
Vessel.unloadDistance = 2250;
Vessel.loadDistance = 2500;
}
}
}
public override void OnStart(StartState state)
{
print ("default landed unload distance : " + vessel.distanceLandedPackThreshold);
print ("default unload distance : " + vessel.distancePackThreshold);
}
}