PersistentTrails.CraftLoader.getParts C# (CSharp) Method

getParts() public static method

public static getParts ( Vessel vessel, bool fetchModel ) : List
vessel Vessel
fetchModel bool
return List
        public static List<PartValue> getParts(Vessel vessel, bool fetchModel)
        {
            List<PartValue> partList = new List<PartValue>();
            Vector3 rootPosition;
            Quaternion rootRotation;
            Transform referenceFrame = new GameObject().transform;
            Transform localTransform = new GameObject().transform;
            localTransform.parent = referenceFrame;
            if (vessel != null)
            {
                if (vessel.parts.Count > 0)
                {
                    //Debug.Log("vessel parts: " + vessel.parts.Count);
                    rootPosition = vessel.parts[0].transform.position;
                    rootRotation = vessel.parts[0].transform.rotation;
                    Quaternion worldUp = Quaternion.Euler((vessel.rigidbody.position - vessel.mainBody.position).normalized);
                    referenceFrame.position = vessel.transform.position;
                    referenceFrame.rotation = vessel.transform.rotation;
                    foreach (Part part in vessel.parts)
                    {
                        if (part.name == "launchClamp1" || part.partName == "StrutConnector" || part.partName == "FuelLine")
                        {
                            Utilities.debug.debugMessage("Excluding part from crf file: " + part.name);
                        }
                        else
                        {
                            PartValue newPartValue = new PartValue();
                            newPartValue.scale = 1f / part.scaleFactor;
                            localTransform.rotation = part.transform.rotation;
                            localTransform.position = part.transform.position;
                            newPartValue.position = localTransform.localPosition;
                            newPartValue.rotation = localTransform.localRotation;
                            newPartValue.partName = part.name.Split(' ')[0];
                            if (fetchModel) newPartValue.model = findPartModel(newPartValue.partName);
                            partList.Add(newPartValue);
                        }
                    }
                }
            }
            return partList;
        }