コード例 #1
0
    public static List <Part> CreateBuildParts(Vector3 createPos, Build.BuildSave toLaunch, PartDatabase partDatabase)
    {
        List <Part>       list  = new List <Part>();
        List <PlacedPart> list2 = Build.BuildSave.PlacedPartSave.FromSave(toLaunch.parts, partDatabase);

        foreach (PlacedPart current in list2)
        {
            Part component = UnityEngine.Object.Instantiate <Transform>(current.partData.prefab, createPos + (Vector3)current.position, Quaternion.identity).GetComponent <Part>();
            component.orientation = current.orientation.DeepCopy();
            Orientation.ApplyOrientation(component.transform, current.orientation);
            list.Add(component);
        }
        for (int i = 0; i < list2.Count; i++)
        {
            for (int j = 0; j < list2[i].partData.attachmentSurfaces.Length; j++)
            {
                for (int k = i + 1; k < list2.Count; k++)
                {
                    for (int l = 0; l < list2[k].partData.attachmentSurfaces.Length; l++)
                    {
                        if (PlacedPart.SurfacesConnect(list2[i], list2[i].partData.attachmentSurfaces[j], list2[k], list2[k].partData.attachmentSurfaces[l]) > 0f)
                        {
                            bool fuelFlow = list2[i].partData.attachmentSurfaces[j].fuelFlow && list2[k].partData.attachmentSurfaces[l].fuelFlow;
                            new Part.Joint(list2[k].position - list2[i].position, list[i], list[k], j, l, fuelFlow);
                        }
                    }
                }
            }
        }
        for (int m = 0; m < list.Count; m++)
        {
            list[m].UpdateConnected();
        }
        return(list);
    }
コード例 #2
0
    public static List <Part> CreateBuildParts(Vector3 createPos, Build.BuildSave toLaunch, PartDatabase partDatabase)
    {
        List <Part>       list  = new List <Part>();
        List <PlacedPart> list2 = Build.BuildSave.PlacedPartSave.FromSave(toLaunch.parts, partDatabase);

        for (int i = 0; i < list2.Count; i++)
        {
            if (list2[i].partData == null || list2[i].partData.prefab == null || (!Ref.hasPartsExpansion && list2[i].partData.inFull))
            {
                list2.RemoveAt(i);
                i--;
            }
            else
            {
                for (int j = i + 1; j < list2.Count; j++)
                {
                    if (PlacedPart.IsOverplaing(list2[i], list2[j]))
                    {
                        list2.RemoveAt(i);
                        i--;
                    }
                }
            }
        }
        foreach (PlacedPart placedPart in list2)
        {
            Part component = UnityEngine.Object.Instantiate <Transform>(placedPart.partData.prefab, createPos + (Vector3)placedPart.position, Quaternion.identity).GetComponent <Part>();
            component.orientation = placedPart.orientation.DeepCopy();
            Orientation.ApplyOrientation(component.transform, placedPart.orientation);
            list.Add(component);
        }
        for (int k = 0; k < list2.Count; k++)
        {
            for (int l = 0; l < list2[k].partData.attachmentSurfaces.Length; l++)
            {
                for (int m = k + 1; m < list2.Count; m++)
                {
                    for (int n = 0; n < list2[m].partData.attachmentSurfaces.Length; n++)
                    {
                        if (PlacedPart.SurfacesConnect(list2[k], list2[k].partData.attachmentSurfaces[l], list2[m], list2[m].partData.attachmentSurfaces[n]) > 0f)
                        {
                            bool fuelFlow = list2[k].partData.attachmentSurfaces[l].fuelFlow && list2[m].partData.attachmentSurfaces[n].fuelFlow;
                            new Part.Joint(list2[m].position - list2[k].position, list[k], list[m], l, n, fuelFlow);
                        }
                    }
                }
            }
        }
        return(list);
    }
コード例 #3
0
 public MyPartCreatedHook(PlacedPart targetPart)
 {
     this.target = targetPart;
 }
コード例 #4
0
 public MyPartDragHook(PlacedPart part, Vector3 newPos)
 {
     this.target = part;
     this.pos    = newPos;
 }