Skip to content

Commit 3018b4b

Browse files
committed
v7: re-built for KSP 1.02; some style fixes
1 parent cacedd9 commit 3018b4b

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
*.dll
44
*.tar*
55
*.zip
6+
*.mdb
67
NavBallDockingAlignmentIndicator

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ INSTALLDIR="$(KSP_DIR)"/GameData/$(NAME)
1212
$(DLL): $(SRC)
1313
@test "$(KSP_DIR)" || echo 'You need to set $$KSP_DIR'
1414
@test "$(KSP_DIR)"
15-
dmcs -r:"$(KSP_DIR)/KSP_Data/Managed/Assembly-CSharp.dll" -r:"$(KSP_DIR)/KSP_Data/Managed/UnityEngine.dll" -t:library $(SRC) -out:$(DLL)
15+
dmcs -debug -r:"$(KSP_DIR)/KSP_Data/Managed/Assembly-CSharp.dll" -r:"$(KSP_DIR)/KSP_Data/Managed/UnityEngine.dll" -t:library $(SRC) -out:$(DLL)
1616

1717
install: $(DLL)
1818
@test "$(KSP_DIR)" || echo 'You need to set $$KSP_DIR'

NavBallDockingAlignmentIndicator.cs

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,34 @@ public void Start()
1212
{
1313
PluginConfiguration cfg = KSP.IO.PluginConfiguration.CreateForType<NavBallDockingAlignmentIndicator>();
1414
cfg.load();
15-
Vector3 tmp = cfg.GetValue<Vector3>("alignmentmarkercolor", new Vector3(1f, 0f, 0f)); //default: red
15+
Vector3 tmp = cfg.GetValue<Vector3>("alignmentmarkercolor", new Vector3(1f, 0f, 0f)); // default: red
1616
Color alignmentmarkercolor = new Color(tmp.x, tmp.y, tmp.z);
17-
Vector2 alignmentmarkertexture = cfg.GetValue<Vector2>("alignmentmarkertexture", new Vector2(0f, 2f)); //default: prograde marker
17+
Vector2 alignmentmarkertexture = cfg.GetValue<Vector2>("alignmentmarkertexture", new Vector2(0f, 2f)); // default: prograde marker
1818
cfg.save();
1919
float texturescalefactor = 1f / 3f;
2020

21-
//get navball object
21+
// get navball object
2222
GameObject navBall = GameObject.Find("NavBall");
2323
Transform navBallVectorsPivotTransform = navBall.transform.FindChild("vectorsPivot");
2424
navBallBehaviour = navBall.GetComponent<NavBall>();
2525

26-
//get indicator texture (use the prograde marker, since it has a clear 'upwards' direction)
26+
// get indicator texture (use the prograde marker, since it has a clear 'upwards' direction)
2727
ManeuverGizmo maneuverGizmo = MapView.ManeuverNodePrefab.GetComponent<ManeuverGizmo>();
2828
ManeuverGizmoHandle maneuverGizmoHandle = maneuverGizmo.handleNormal;
2929
Transform transform = maneuverGizmoHandle.flag;
3030
Renderer renderer = transform.renderer;
3131
Material maneuverTexture = renderer.sharedMaterial;
3232

33-
//create alignment indicator game object
33+
// create alignment indicator game object
3434
indicator = Create2DObject(
3535
name: "navballalignmentindicator",
36-
size: 0.025f, //the same size as all other markers
36+
size: 0.025f, // the same size as all other markers
3737
col: alignmentmarkercolor,
3838
texture: maneuverTexture,
3939
textureScale: Vector2.one * texturescalefactor,
4040
textureOffset: alignmentmarkertexture * texturescalefactor,
4141
parentTransform: navBallVectorsPivotTransform,
42-
layer: 12 //the navball layer
42+
layer: 12 // the navball layer
4343
);
4444
}
4545

@@ -108,8 +108,9 @@ private GameObject Create2DObject(
108108

109109
public void LateUpdate()
110110
{
111-
if(FlightGlobals.ready == false)
111+
if(FlightGlobals.ready == false) {
112112
return;
113+
}
113114

114115
if(FlightGlobals.fetch != null) {
115116
if(FlightGlobals.fetch.VesselTarget != null) {
@@ -118,13 +119,13 @@ public void LateUpdate()
118119
Transform targetTransform = targetPort.GetTransform();
119120
Transform selfTransform = FlightGlobals.ActiveVessel.ReferenceTransform;
120121

121-
//indicator position
122+
// indicator position
122123
Vector3 targetPortOutVector = targetTransform.forward.normalized;
123124
Vector3 targetPortInVector = -targetPortOutVector;
124125
Vector3 rotatedTargetPortInVector = navBallBehaviour.attitudeGymbal * targetPortInVector;
125126
indicator.transform.localPosition = rotatedTargetPortInVector * navBallBehaviour.progradeVector.localPosition.magnitude;
126127

127-
//indicator rotation
128+
// indicator rotation
128129
Vector3 v1 = Vector3.Cross(selfTransform.up, -targetTransform.up);
129130
Vector3 v2 = Vector3.Cross(selfTransform.up, selfTransform.forward);
130131
float ang = Vector3.Angle(v1, v2);
@@ -133,15 +134,15 @@ public void LateUpdate()
133134
}
134135
indicator.transform.rotation = Quaternion.Euler(90 + ang, 90, 270);
135136

136-
//indicator visibility (invisible if on back half sphere)
137+
// indicator visibility (invisible if on back half sphere)
137138
indicator.SetActive(indicator.transform.localPosition.z > 0.0d);
138139

139140
return;
140141
}
141142
}
142143
}
143144

144-
//no docking port is currently selected
145+
// no docking port is currently selected
145146
indicator.SetActive(false);
146147
return;
147148
}

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ v6, 2014-12-19, KSP 0.90:
5050

5151
Updated for KSP 0.90, changed ZIP folder structure
5252

53+
v7, 2015-05-24, KSP 1.02:
54+
55+
Re-built for KSP 1.02 to fix issues some people reported
56+
5357
### URLs
5458

5559
- [Github](https://github.com/mic-e/kspnavballdockingalignmentindicator)

0 commit comments

Comments
 (0)