public static List <VesselPart> PartsListFromBuildString(string buildstring)
    {
        string[]          inputWords = buildstring.Split(' ');
        List <VesselPart> parts      = new List <VesselPart>();

        for (int i = 0; i < inputWords.Length; i++)
        {
            string word     = inputWords[i];
            bool   bay      = word.Equals("-bay");
            bool   engine   = word.Equals("-engine");
            bool   launcher = word.Equals("-launcher");
            if (bay || engine || launcher)
            {
                float newSize     = float.Parse(inputWords[i + 1]);
                float newQuality1 = float.Parse(inputWords[i + 2]);
                float newQuality2 = float.Parse(inputWords[i + 3]);
                float xPos        = float.Parse(inputWords[i + 4]);
                float yPos        = float.Parse(inputWords[i + 5]);
                float newFacing   = float.Parse(inputWords[i + 6]);

                VesselPartType newPartType;
                if (bay)
                {
                    newPartType = VesselPartType.Bay;
                }
                else if (engine)
                {
                    newPartType = VesselPartType.Engine;
                }
                else
                {
                    newPartType = VesselPartType.Launcher;
                }

                VesselPart newPart = new VesselPart()
                {
                    partType = newPartType,
                    position = new Vector2(xPos, yPos),
                    facing   = newFacing,
                    size     = newSize,
                    quality1 = newQuality1,
                    quality2 = newQuality2
                };
                parts.Add(newPart);
            }
        }
        return(parts);
    }
    public void PlacePart(PixelGridButton button, VesselPart partToPlace)
    {
        if (buttonToPlacedPart.ContainsKey(button))
        {
            Debug.Log("Dictionary already contains key " + button.ToString());
            Debug.Log("There is already a part there.");
            return;
        }

        button.gameObject.transform.SetSiblingIndex(button.transform.parent.childCount - 1);

        GameObject    placedPart    = new GameObject("Placed Part");
        RectTransform rectTransform = placedPart.AddComponent <RectTransform>();

        placedPart.transform.SetParent(button.transform);
        rectTransform.anchorMin = Vector2.zero;
        rectTransform.anchorMax = Vector2.zero;
        float halfsize = partToPlace.size *
                         Vessel.partSizeFactor *
                         SpriteManager.SPRITE_SIZE *
                         PixelGridManager.Instance().GetSizeFactor() / 2;

        rectTransform.offsetMin   = Vector2.one * -1 * halfsize;
        rectTransform.offsetMax   = Vector2.one * halfsize;
        rectTransform.eulerAngles = new Vector3(0, 0, partToPlace.facing);
        UnityEngine.UI.Image image = placedPart.AddComponent <UnityEngine.UI.Image>();
        string spriteName;

        if (partToPlace.partType == VesselPartType.Bay)
        {
            spriteName = "square";
        }
        else if (partToPlace.partType == VesselPartType.Engine)
        {
            spriteName = "halfcircle";
        }
        else //(partInProgress.partType == VesselPartType.Launcher)
        {
            spriteName = "triangle";
        }
        image.sprite        = SpriteManager.Instance().SpriteFromName(spriteName);
        image.color         = Color.white * GetPartColor();
        image.raycastTarget = false;

        partToPlace.position = button.GetPosition();
        VesselPart newPart = partToPlace;

        buttonToPlacedPart[button] = newPart;

        GameObject deleter = new GameObject("Deleter");

        rectTransform = deleter.AddComponent <RectTransform>();
        deleter.transform.SetParent(button.transform);
        rectTransform.anchorMin = Vector2.zero;
        rectTransform.anchorMax = Vector2.one;
        rectTransform.offsetMin = Vector2.zero;
        rectTransform.offsetMax = Vector2.zero;
        image               = deleter.AddComponent <UnityEngine.UI.Image>();
        image.sprite        = SpriteManager.Instance().SpriteFromName("X");
        image.color         = new Color(0.75f, 0, 0);
        image.raycastTarget = false;
    }