Example #1
0
 public void ThrowHook()
 {
     if (Config.Instance.ShowHelpTexts)
     {
         OSD.PostMessage(Config.Instance.FreeAttachHelpText, 5);
     }
     StartCoroutine(PreparePartForFreeAttach());
 }
Example #2
0
 public void IncreaseCableLength()
 {
     if (MaxDistance + WINCH_STEP_WIDTH < Config.Instance.MaxDistance)
     {
         MaxDistance += WINCH_STEP_WIDTH;
     }
     else
     {
         OSD.PostMessageLowerRightCorner("max tether length reached");
     }
 }
Example #3
0
 public void PullCloser()
 {
     if (MaxDistance - WINCH_STEP_WIDTH > MIN_TETHER_LENGTH)
     {
         MaxDistance -= WINCH_STEP_WIDTH;
     }
     else
     {
         OSD.PostMessageLowerRightCorner("min tether length reached");
     }
 }
Example #4
0
        private IEnumerator PreparePartForFreeAttach()
        {
            var newPart = PartFactory.SpawnPartInFlight("TetherHook", part, new Vector3(2, 2, 2),
                                                        part.transform.rotation);

            OSD.PostMessageLowerRightCorner("waiting for Unity to catch up...", 1.5f);
            while (!newPart.rigidbody)
            {
                Debug.Log("[IRAS] rigidbody not ready - waiting");
                try
                {
                    DestroyImmediate(newPart.collider);
                }
                catch (Exception)
                {
                    //sanity reason
                }
                try
                {
                    newPart.transform.position = part.transform.position;
                }
                catch (NullReferenceException)
                {
                    //sanity reason
                }
                try
                {
                    newPart.mass         = 0.000001f;
                    newPart.maximum_drag = 0f;
                    newPart.minimum_drag = 0f;
                }
                catch (NullReferenceException)
                {
                    //sanity reason
                }
                yield return(new WaitForFixedUpdate());
            }
            newPart.mass                            = 0.000001f;
            newPart.maximum_drag                    = 0f;
            newPart.minimum_drag                    = 0f;
            ActiveStrutsAddon.NewSpawnedPart        = newPart;
            ActiveStrutsAddon.CurrentKerbalTargeter = this;
            ActiveStrutsAddon.Mode                  = AddonMode.AttachKerbalHook;
        }