diff --git a/InfernalRobotics/InfernalRobotics/Module/ModuleIRServo.cs b/InfernalRobotics/InfernalRobotics/Module/ModuleIRServo.cs index 659d8137..bb8e17d4 100644 --- a/InfernalRobotics/InfernalRobotics/Module/ModuleIRServo.cs +++ b/InfernalRobotics/InfernalRobotics/Module/ModuleIRServo.cs @@ -33,7 +33,7 @@ public class ModuleIRServo : PartModule, IRescalable, IJointLockState //BEGIN Mechanism related KSPFields [KSPField(isPersistant = true)] public bool freeMoving = false; - [KSPField(isPersistant = true)] public bool isMotionLock; + [KSPField(isPersistant = true)] public bool isMotionLock = false; [KSPField(isPersistant = true)] public bool limitTweakable = false; [KSPField(isPersistant = true)] public bool limitTweakableFlag = false; @@ -487,6 +487,8 @@ public void OnVesselGoOffRails (Vessel v) Logger.Log ("[OnVesselGoOffRails] Started for "+ part.name, Logger.Level.Debug); + Logger.Log ("[OnVesselGoOffRails] Rebuilding Attachments", Logger.Level.Debug); + BuildAttachments (); if (joint) { @@ -561,7 +563,7 @@ public override void OnLoad(ConfigNode config) { Logger.Log("[OnLoad] Start", Logger.Level.Debug); - base.OnLoad (config); + //base.OnLoad (config); //save persistent rotation/translation data, because the joint will be initialized at current position. rotationDelta = rotation; @@ -569,9 +571,6 @@ public override void OnLoad(ConfigNode config) InitModule(); - Logger.Log ("[OnLoad] Rebuilding Attachments", Logger.Level.Debug); - BuildAttachments (); - Logger.Log("[OnLoad] End", Logger.Level.Debug); } /// @@ -637,6 +636,12 @@ protected virtual void AttachToParent() { Transform fix = FixedMeshTransform; //first revert position to part position + if (fix == null || part == null || part.transform == null || part.parent == null) + { + Logger.Log ("[AttachToParent] part, parent or transform is null", Logger.Level.Debug); + return; + } + fix.position = part.transform.position; fix.rotation = part.transform.rotation; @@ -704,10 +709,10 @@ protected virtual void BuildAttachments() AttachToParent (); } - var node = part.FindAttachNodeByPart (part.parent); + //var node = part.FindAttachNodeByPart (part.parent); - if(translateJoint && (node == null || !(node.id.Contains(bottomNode) || part.attachMode == AttachModes.SRF_ATTACH))) - translateAxis *= -1; + //if(translateJoint && (node == null || !(node.id.Contains(bottomNode) || part.attachMode == AttachModes.SRF_ATTACH))) + // translateAxis *= -1; ReparentFriction(part.transform); failedAttachment = false; @@ -767,7 +772,7 @@ public override void OnStart(StartState state) if (ModelTransform == null) Logger.Log("[MMT] OnStart ModelTransform is null", Logger.Level.Warning); - BuildAttachments(); + BuildAttachments(); if (limitTweakable) { @@ -1061,7 +1066,7 @@ public static float AngleSigned(Vector3 v1, Vector3 v2, Vector3 n) /// /// The real rotation. public float GetRealRotation() - { + { Vector3 v1, v2, n; if(rotateAxis == Vector3.forward || rotateAxis == Vector3.back) { @@ -1149,7 +1154,7 @@ protected virtual void UpdatePosition() Interpolator.Update(TimeWarp.fixedDeltaTime); float targetPos = Interpolator.GetPosition(); - float currentPos = rotateJoint ? GetRealRotation() : GetRealTranslation(); + float currentPos = rotateJoint ? rotation : translation;//rotateJoint ? GetRealRotation() : GetRealTranslation(); if (lastRealPosition == 0f) lastRealPosition = currentPos; diff --git a/InfernalRobotics/InfernalRobotics/Properties/AssemblyInfo.cs b/InfernalRobotics/InfernalRobotics/Properties/AssemblyInfo.cs index c4ae9728..a636ce07 100644 --- a/InfernalRobotics/InfernalRobotics/Properties/AssemblyInfo.cs +++ b/InfernalRobotics/InfernalRobotics/Properties/AssemblyInfo.cs @@ -35,5 +35,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.4.0")] -[assembly: AssemblyFileVersion("2.0.4.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.0.9.0")] +[assembly: AssemblyFileVersion("2.0.9.0")] \ No newline at end of file