public void TransferSome(int amount, ReagentContainer targetContainer) { ReagentContainer taken = TakeSome(amount, false); targetContainer.AddMultiple(taken.CurrentReagents); }
// Takes x units of fluid, taking from overall composition public ReagentContainer TakeSome(int amount, bool justSampling = true) { ReagentContainer outReagents = new ReagentContainer(); // Get the proportion of total fluid each reagent contributes, rounding up. // Then take that much from the container and put it into the output, if not sampling foreach(KeyValuePair<Reagent, int> currentReagent in CurrentReagents) { float currentReagentProportion = (float)currentReagent.Value / (float)CurrentFluidAmt; currentReagentProportion = (float)Math.Ceiling(currentReagentProportion); // Add to outgoing list outReagents.AddReagent(currentReagent.Key, (int)currentReagentProportion); // Destroy if not sampling if(!justSampling) { RemoveReagent(currentReagent.Key, (int)currentReagentProportion); } } return outReagents; }