public Segment(MSSRB_Part p, float segHeight) { part = p; ratio = 0; segmentHeight = segHeight; }
bool CheckPartResources(MSSRB_Part part, bool max = true) { // Check the nextPart's resources and Modules // Check for the correct propellant and that it has the MSSRB_Fuel_Segment module // If so, add it to the segments list and accumulate some values for the motor // then update the propellant value amount in the fuel segment PartResourceList prl = part.Resources; PartModuleList pml = part.Modules; if (prl.Contains(ModSegSRBs.Propellant) && pml.Contains <MSSRB_Fuel_Segment>()) { Log.Info("CheckPartResources, " + ModSegSRBs.Propellant + " found, " + " MSSRB_Fuel_Segment found"); MSSRB_Fuel_Segment moduleFuelSegment = pml["MSSRB_Fuel_Segment"] as MSSRB_Fuel_Segment; if (max) { totalFuelMass += moduleFuelSegment.MaxSolidFuel(); // prl[ModSegSRBs.Propellant].maxAmount; } else { totalFuelMass += prl[ModSegSRBs.Propellant].amount; } totalMaxThrust += moduleFuelSegment.GetMaxThrust(); prl[ModSegSRBs.Propellant].amount = moduleFuelSegment.MaxSolidFuel(); prl[ModSegSRBs.BurnablePropellant].amount = 0; prl[ModSegSRBs.Propellant].maxAmount = prl[ModSegSRBs.BurnablePropellant].maxAmount = moduleFuelSegment.MaxSolidFuel(); Log.Info("totalMaxThrust: " + totalMaxThrust + ", totalFuelMass: " + totalFuelMass); return(true); } else { Log.Info("CheckPartResources, no Propellant found"); return(false); } }
bool CheckPartResources(MSSRB_Part part) { // Check the nextPart's resources and Modules // Check for the correct propellant and that it has the MSSRB_Fuel_Segment module // If so, add it to the segments list and accumulate some values for the motor // then update the propellant value amount in the fuel segment PartResourceList prl = part.Resources; PartModuleList pml = part.Modules; if (prl.Contains(ModSegSRBs.Propellant) && pml.Contains <MSSRB_Fuel_Segment>()) { Log.Info("CheckPartResources, Part: " + part.partInfo.title + ", " + ModSegSRBs.Propellant + " found, " + " MSSRB_Fuel_Segment found"); MSSRB_Fuel_Segment moduleFuelSegment = pml["MSSRB_Fuel_Segment"] as MSSRB_Fuel_Segment; segments.Add(new Segment(part, moduleFuelSegment.part.segmentHeight)); totalFuelMass += moduleFuelSegment.MaxSolidFuel(); // prl[ModSegSRBs.Propellant].maxAmount; totalMaxThrust += moduleFuelSegment.GetMaxThrust(); Log.Info("CheckPartResources, moduleFuelSegment.part.segmentHeight: " + moduleFuelSegment.part.segmentHeight); totalSegmentHeight += moduleFuelSegment.part.segmentHeight; Log.Info("CheckPartResources, totalFuelMass: " + totalFuelMass + ", totalMaxThrust: " + totalMaxThrust + ", totalSegmentHeight: " + totalSegmentHeight); if (totalSegmentHeight > 0) { invTotalSegmentHeight = 1 / totalSegmentHeight; } else { invTotalSegmentHeight = 0; } moduleFuelSegment.baseEngine = this; if (CoM == null && HighLogic.LoadedSceneIsEditor) { prl[ModSegSRBs.Propellant].amount = prl[ModSegSRBs.Propellant].maxAmount = 0; prl[ModSegSRBs.BurnablePropellant].amount = prl[ModSegSRBs.BurnablePropellant].maxAmount = moduleFuelSegment.MaxSolidFuel(); Log.Info("(2) Propellant Setting part.amount = 0, BurnablePropellant maxAmount set to: " + prl[ModSegSRBs.BurnablePropellant].maxAmount); } else { prl[ModSegSRBs.Propellant].amount = prl[ModSegSRBs.Propellant].maxAmount = moduleFuelSegment.MaxSolidFuel(); prl[ModSegSRBs.BurnablePropellant].amount = prl[ModSegSRBs.BurnablePropellant].maxAmount = 0; } Log.Info("totalMaxThrust: " + totalMaxThrust + ", totalFuelMass: " + totalFuelMass); // Set the baseEngine in the segment ends here, do it in a loop // because there can be either one or two ends foreach (var p in pml) { if (p is MSSRB_SegmentEnds) { MSSRB_SegmentEnds mssrb = p as MSSRB_SegmentEnds; mssrb.baseEngine = this; mssrb.maxThrust = this.maxThrust; mssrb.atmosphereCurve = this.atmosphereCurve; } } return(true); } else { Log.Info("CheckPartResources, no Propellant found"); return(false); } }
public new void Awake() { partInstantiatedFlag = this; base.Awake(); }