Exemple #1
0
        private void DockingPortExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
        {
            var module = part.Module <ModuleDockingNode>();

            if (string.IsNullOrEmpty(module.referenceAttachNode))
            {
                return;
            }
            var an = part.FindAttachNode(module.referenceAttachNode);

            if (!an.attachedPart)
            {
                return;
            }
            var  distance = o.valueParam;
            Part partToBeMoved;

            if (an.attachedPart == part.parent)
            {
                distance     *= -1;
                partToBeMoved = part;
            }
            else
            {
                partToBeMoved = an.attachedPart;
            }
            partToBeMoved.transform.Translate(module.nodeTransform.forward * distance, Space.World);
        }
Exemple #2
0
 private void KASConnectorPortExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     if (hasMod("KAS"))
     {
         var module = part.Module <KASModulePort>(); //this creates KAS Dependancy.
         if (string.IsNullOrEmpty(module.attachNode))
         {
             return;
         }
         var an = part.FindAttachNode(module.attachNode);
         if (!an.attachedPart)
         {
             return;
         }
         var  distance = o.valueParam;
         Part partToBeMoved;
         if (an.attachedPart == part.parent)
         {
             distance     *= -1;
             partToBeMoved = part;
         }
         else
         {
             partToBeMoved = an.attachedPart;
         }
         partToBeMoved.transform.Translate(module.portNode.forward * distance, Space.World);
     }
 }
Exemple #3
0
        private void StackDecouplerExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
        {
            var module = part.Module <ModuleDecouple>();

            if (module.isDecoupled)
            {
                return;
            }
            if (!module.staged)
            {
                return;
            }
            if (!part.parent)
            {
                return;
            }
            Vector3 dir;

            if (module.isOmniDecoupler)
            {
                foreach (var c in part.children)
                {
                    dir = Vector3.Normalize(c.transform.position - part.transform.position);
                    c.transform.Translate(dir * o.valueParam, Space.World);
                }
            }
            dir = Vector3.Normalize(part.transform.position - part.parent.transform.position);
            part.transform.Translate(dir * o.valueParam, Space.World);
        }
Exemple #4
0
 private void PartHideRecursive(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     foreach (var r in part.GetComponentsInChildren <Renderer>())
     {
         r.enabled = false;
     }
 }
Exemple #5
0
        private void EngineFairingHide(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
        {
            var module = part.Module <ModuleJettison>();

            if (module.jettisonTransform)
            {
                foreach (var r in module.jettisonTransform.gameObject.GetComponentsInChildren <Renderer>())
                {
                    r.enabled = false;
                }
            }
        }
Exemple #6
0
        private void EngineFairingExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
        {
            var module = part.Module <ModuleJettison>();

            if (!module.isJettisoned)
            {
                if (!module.isFairing)
                {
                    module.jettisonTransform.Translate(module.jettisonDirection * o.valueParam);
                }
            }
        }
Exemple #7
0
 private void ProcFairingExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
 {
     if (hasMod("ProceduralFairings"))
     {
         var nct = part.FindModelTransform("nose_collider");
         if (!nct)
         {
             return;
         }
         procFairingOffset = o.valueParam;
         var extents = new Vector3(o.valueParam, o.valueParam, o.valueParam);
         part.transform.Translate(Vector3.Scale(nct.right, extents), Space.World);
     }
 }
Exemple #8
0
        private void RadialDecouplerExplode(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
        {
            var module = part.Module <ModuleAnchoredDecoupler>();

            if (module.isDecoupled)
            {
                return;
            }
            if (!module.staged)
            {
                return;
            }
            if (string.IsNullOrEmpty(module.explosiveNodeID))
            {
                return;
            }
            var an = module.explosiveNodeID == "srf" ? part.srfAttachNode : part.FindAttachNode(module.explosiveNodeID);

            if ((an == null) || (an.attachedPart == null))
            {
                return;
            }
            var distance = o.valueParam;

            if (part.name.Contains("FairingCone"))
            {
                distance *= -1;
            }
            Part partToBeMoved;

            if (an.attachedPart == part.parent)
            {
                distance     *= -1;
                partToBeMoved = part;
            }
            else
            {
                partToBeMoved = an.attachedPart;
            }
            partToBeMoved.transform.Translate(part.transform.right * distance, Space.World);
        }
Exemple #9
0
        private void ProcFairingHide(VesselElementViewOptions ol, VesselElementViewOption o, Part part)
        {
            if (hasMod("ProceduralFairings"))
            {
                var nct = part.FindModelTransform("nose_collider");
                if (!nct)
                {
                    return;
                }
                var forward = EditorLogic.RootPart.transform.forward;
                var right   = EditorLogic.RootPart.transform.right;

                if (Vector3.Dot(nct.right, -forward.normalized) > 0f)
                {
                    var renderer = part.GetComponentInChildren <Renderer>();
                    if (renderer)
                    {
                        renderer.enabled = false;
                    }
                }
            }
        }