new public static RotorPartCollection Borrow(PartCollection parentCollection, Part originPart) { RotorPartCollection collection = BorrowWithoutAdding(parentCollection?.parentVessel, originPart); collection.parentCollection = parentCollection; collection.AddPart(originPart); return(collection); }
protected static void Reset(PartCollection obj) { SimulatedPart.Release(obj.parts); obj.parts.Clear(); SimulatedLiftingSurface.Release(obj.surfaces); obj.surfaces.Clear(); SimulatedControlSurface.Release(obj.ctrls); obj.ctrls.Clear(); SimulatedEngine.Release(obj.engines); obj.engines.Clear(); PartCollection.Release(obj.partCollections); obj.partCollections.Clear(); }
private void Init(IShipconstruct v) { totalMass = 0; dryMass = 0; CoM = Vector3.zero; CoM_dry = Vector3.zero; relativeWingArea = 0; stage = 0; List <Part> oParts = v.Parts; List <SimulatedPart> variableDragParts_ctrls = new List <SimulatedPart>(); count = oParts.Count; if (HighLogic.LoadedSceneIsEditor) { for (int i = 0; i < v.Parts.Count; i++) { Part p = v.Parts[i]; if (p.dragModel == Part.DragModel.CUBE && !p.DragCubes.None) { DragCubeList cubes = p.DragCubes; lock (cubes) { DragCubeList.CubeData p_drag_data = new DragCubeList.CubeData(); try { cubes.SetDragWeights(); cubes.SetPartOcclusion(); cubes.AddSurfaceDragDirection(-Vector3.forward, 0, ref p_drag_data); } catch (Exception) { cubes.SetDrag(Vector3.forward, 0); cubes.ForceUpdate(true, true); cubes.SetDragWeights(); cubes.SetPartOcclusion(); cubes.AddSurfaceDragDirection(-Vector3.forward, 0, ref p_drag_data); //Debug.Log(String.Format("Trajectories: Caught NRE on Drag Initialization. Should be fixed now. {0}", e)); } } } } } bool lgWarning = false; for (int i = 0; i < count; i++) { if (!lgWarning) { ModuleWheels.ModuleWheelDeployment gear = oParts[i].FindModuleImplementing <ModuleWheels.ModuleWheelDeployment>(); bool forcedRetract = !oParts[i].ShieldedFromAirstream && gear != null && gear.Position > 0; if (forcedRetract) { lgWarning = true; } } } // Recursively add all parts to collections // What a crazy change to make just to accomodate rotating parts! partCollection = PartCollection.Borrow(this, oParts[0]); CoM /= totalMass; CoM_dry /= dryMass; partCollection.origin = CoM; if (relativeWingArea == 0) { // I'm not sure what effect calling ScreenMessages from a background thread will be. // Fortunately, anyone using this mod probably has at least one wing. ScreenMessages.PostScreenMessage("No wings found, using a reference area of 1.", 5, ScreenMessageStyle.UPPER_CENTER); relativeWingArea = 1; } //if (lgWarning) //ScreenMessages.PostScreenMessage("Landing gear deployed, results may not be accurate.", 5, ScreenMessageStyle.UPPER_CENTER); }
private static void Reset(RotorPartCollection obj) { PartCollection.Reset(obj); }