public double RemoveQuantity(double amount, bool exactAmountOnly) { lock (_lock) { if (exactAmountOnly) { throw new ArgumentException("exactAmountOnly cannot be true"); } return(ConverterMatterToFuel.RemoveQuantity(amount, _cargo)); } }
//NOTE: There is only an add method. Any cargo added to this converter is burned off over time public bool Add(Cargo cargo) { lock (_lock) { //double sumVolume = this.UsedVolume + cargo.Volume; double sumVolume = _cargo.Sum(o => o.Volume) + cargo.Volume; // inlined this.UsedVolume because of the lock if (sumVolume <= this.MaxVolume || Math1D.IsNearValue(sumVolume, this.MaxVolume)) { ConverterMatterToFuel.Add(_cargo, cargo); return(true); } else { return(false); } } }
public ConverterMatterToEnergy(EditorOptions options, ItemOptions itemOptions, ShipPartDNA dna, IContainer energyTanks) : base(options, dna, itemOptions.MatterConverter_Damage.HitpointMin, itemOptions.MatterConverter_Damage.HitpointSlope, itemOptions.MatterConverter_Damage.Damage) { _itemOptions = itemOptions; _energyTanks = energyTanks; this.Design = new ConverterMatterToEnergyDesign(options, true); this.Design.SetDNA(dna); double volume; ConverterMatterToFuel.GetMass(out _dryMass, out volume, out _scaleActual, _itemOptions, dna); this.MaxVolume = volume; if (_energyTanks != null) { double scaleVolume = _scaleActual.X * _scaleActual.Y * _scaleActual.Z; // can't use volume from above, because that is the amount of matter that can be held. This is to get conversion ratios _converter = new Converter(this, _energyTanks, _itemOptions.MatterToEnergy_ConversionRate, _itemOptions.MatterToEnergy_AmountToDraw * scaleVolume); } this.Destroyed += ConverterMatterToEnergy_Destroyed; }