public BuildListVessel(ProtoVessel pvessel, ConfigNode vesselNode, ListType listType = ListType.None) //For recovered vessels { Id = Guid.NewGuid(); ShipName = pvessel.vesselName; ShipNode = vesselNode; if (listType != ListType.None) { Type = listType; } Cost = Utilities.GetTotalVesselCost(ShipNode); EmptyCost = Utilities.GetTotalVesselCost(ShipNode, false); TotalMass = 0; EmptyMass = 0; HashSet <int> stages = new HashSet <int>(); foreach (ProtoPartSnapshot p in pvessel.protoPartSnapshots) { stages.Add(p.inverseStageIndex); if (p.partPrefab != null) { if (p.partPrefab.Modules.Contains <LaunchClamp>()) { continue; } ModuleTagList mTags = p.partPrefab.FindModuleImplementing <ModuleTagList>(); if (mTags != null && mTags.tags.Contains("PadInfrastructure")) { continue; } } TotalMass += p.mass; EmptyMass += p.mass; foreach (ProtoPartResourceSnapshot rsc in p.resources) { PartResourceDefinition def = PartResourceLibrary.Instance.GetDefinition(rsc.resourceName); if (def != null) { TotalMass += def.density * (float)rsc.amount; } } } CannotEarnScience = true; NumStages = stages.Count; // FIXME ignore stageable part count and cost - it'll be fixed when we put this back in the editor. BuildPoints = Utilities.GetBuildTime(ShipNode.GetNodes("PART").ToList()); Flag = HighLogic.CurrentGame.flagURL; Progress = BuildPoints; DistanceFromKSC = 0; // (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude)); RushBuildClicks = 0; }
public static void PrepVesselTeleport(this Vessel vessel) { if (vessel.Landed) { vessel.Landed = false; } if (vessel.Splashed) { vessel.Splashed = false; } if (vessel.landedAt != string.Empty) { vessel.landedAt = string.Empty; } var parts = vessel.parts; if (parts != null) { foreach (var part in parts) { bool kill = false; if (part.Modules.Contains <LaunchClamp>()) { kill = true; } else { ModuleTagList mTags = part.FindModuleImplementing <ModuleTagList>(); if (mTags != null && mTags.tags.Contains("PadInfrastructure")) { kill = true; } } if (kill) { part.Die(); } } } }