Beispiel #1
0
        private bool _checkLineOfSight(ModuleAutoStrutter target)
        {
            var rayres = Utilities.PerformRaycast(HeadTransform.position, target.HeadTransform.position,
                                                  part.transform.up, part);

            return(rayres.HitResult && rayres.HittedPart != null && rayres.HittedPart == target.part &&
                   rayres.RayAngle <= Config.Instance.MaxAngleAutostrutter);
        }
Beispiel #2
0
 private bool CheckGroup(ModuleAutoStrutter possibleTarget)
 {
     if (Config.Instance.AutoStrutterConnectToOwnGroup)
     {
         return(Group == possibleTarget.Group);
     }
     return(Group != possibleTarget.Group);
 }
Beispiel #3
0
 public void FixedUpdate()
 {
     if (!HighLogic.LoadedSceneIsFlight)
     {
         return;
     }
     if (connected)
     {
         if (!Enabled ||
             partner == null ||
             !partner.Enabled ||
             partner.vessel == null ||
             vessel == null ||
             partner.vessel != vessel ||
             !CheckGroup(partner))
         {
             Unlink();
             return;
         }
         OrientHeadTransformToTarget();
         OrientMountTransformToTarget();
         if (joint == null)
         {
             CreateJoint();
         }
     }
     if (isOrigin)
     {
         AlignStrut();
     }
     if (wait > 0)
     {
         wait--;
         return;
     }
     wait = WAIT_INTERVAL;
     UpdateGui();
     UpdateLights();
     if (!connected && Enabled)
     {
         var nearestStrutter = FindNearestAutoStrutterOnVessel();
         if (nearestStrutter != null)
         {
             connected = true;
             nearestStrutter.connected = true;
             partner = nearestStrutter;
             nearestStrutter.partner = this;
             isOrigin = true;
             nearestStrutter.isOrigin = false;
             CreateJoint();
         }
     }
 }
Beispiel #4
0
 private void Unlink()
 {
     if (joint != null)
     {
         Destroy(joint);
     }
     strut.transform.localScale = Vector3.zero;
     strut.SetActive(false);
     if (partner != null && isOrigin)
     {
         partner.Unlink();
     }
     partner   = null;
     connected = isOrigin = false;
 }