Skip to content

Commit

Permalink
add option to not spawn crew related to PapaJoesSoup#17
Browse files Browse the repository at this point in the history
  • Loading branch information
gomker committed Jul 6, 2017
1 parent df8f3dd commit caa9688
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 17 deletions.
Binary file modified Distribution/GameData/VesselMover/Plugins/VesselMover.dll
Binary file not shown.
29 changes: 20 additions & 9 deletions VesselMoverToolbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ public class VesselMoverToolbar : MonoBehaviour
{
public static bool hasAddedButton = false;
public static bool toolbarGuiEnabled = false;
public static bool addCrewMembers = true;

Rect toolbarRect;
Rect toolbarRect;
float toolbarWidth = 280;
float toolbarHeight = 0;
float toolbarMargin = 6;
float toolbarLineHeight = 20;
float contentWidth;
Vector2 toolbarPosition;
Rect svRectScreenSpace;
bool showMoveHelp = false;
Rect svCrewScreenSpace;
bool showMoveHelp = false;
float helpHeight;

void Start()
Expand Down Expand Up @@ -66,17 +68,26 @@ void ToolbarWindow(int windowID)
{
VesselMove.instance.StartMove(FlightGlobals.ActiveVessel, true);
}
line += 0.2f;
line += 0.2f;

Rect spawnVesselRect = LineRect(ref line);
Rect spawnVesselRect = LineRect(ref line);
svRectScreenSpace = new Rect(spawnVesselRect);
svRectScreenSpace.x += toolbarRect.x;
svRectScreenSpace.y += toolbarRect.y;
if(GUI.Button(spawnVesselRect, "Spawn Vessel", HighLogic.Skin.button))
{
VesselSpawn.instance.StartVesselSpawn();
svRectScreenSpace.y += toolbarRect.y;

if (GUI.Button(spawnVesselRect, "Spawn Vessel", HighLogic.Skin.button))
{
VesselSpawn.instance.StartVesselSpawn();
}
showMoveHelp = false;

line += .75f;
Rect crewRect = LineRect(ref line);
svCrewScreenSpace = new Rect(crewRect);
svCrewScreenSpace.x += toolbarRect.x;
svCrewScreenSpace.y += toolbarRect.y;
addCrewMembers = GUI.Toggle(crewRect, addCrewMembers, "Spawn Crew");

showMoveHelp = false;
}
else
{
Expand Down
21 changes: 13 additions & 8 deletions VesselSpawn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public VesselData(VesselData vd)
pitch = vd.pitch;
roll = vd.roll;

foreach (CrewData cd in vd.crew)
{
crew.Add(new CrewData(cd));
}
foreach (CrewData cd in vd.crew)
{
crew.Add(new CrewData(cd));
}
}
}

Expand Down Expand Up @@ -289,7 +289,11 @@ void SpawnVesselFromCraftFile(string craftURL, Vector3d gpsCoords, float heading
newData.flagURL = HighLogic.CurrentGame.flagURL;
newData.owned = true;
newData.vesselType = VesselType.Ship;
newData.crew = new List<CrewData>();

if (VesselMoverToolbar.addCrewMembers)
{
newData.crew = new List<CrewData>();
}

SpawnVessel(newData);
}
Expand Down Expand Up @@ -373,8 +377,9 @@ void SpawnVessel(VesselData vesselData)
bool success = false;
Part part = shipConstruct.parts.Find(p => p.protoModuleCrew.Count < p.CrewCapacity);

// Add the crew member
if (part != null)
// Add the crew member

if (part != null && VesselMoverToolbar.addCrewMembers)
{
// Create the ProtoCrewMember
ProtoCrewMember crewMember = HighLogic.CurrentGame.CrewRoster.GetNewKerbal(ProtoCrewMember.KerbalType.Crew);
Expand Down Expand Up @@ -462,7 +467,7 @@ void SpawnVessel(VesselData vesselData)
crewArray[i++] = crewMember;
}

// Create part nodes
// Create part nodes
uint flightId = ShipConstruction.GetUniqueFlightID(HighLogic.CurrentGame.flightState);
partNodes = new ConfigNode[1];
partNodes[0] = ProtoVessel.CreatePartNode(vesselData.craftPart.name, flightId, crewArray);
Expand Down

0 comments on commit caa9688

Please sign in to comment.