public ReagentMix(Reagent reagent, float amount, float temperature = TemperatureUtils.ZERO_CELSIUS_IN_KELVIN) { Temperature = temperature; reagents = new DictionaryReagentFloat { [reagent] = amount }; }
public void DispenseChemical(Chemistry.Reagent reagent) { if (ChemistryDispenser.Container != null) { if (ChemistryDispenser.ThisState == PowerStates.On || ChemistryDispenser.ThisState == PowerStates.LowVoltage || ChemistryDispenser.ThisState == PowerStates.OverVoltage) { //Logger.Log (Chemical); if (dispensableReagents.Contains(reagent)) //Checks if the the dispenser can dispense this chemical { float OutDispensedNumber = 0; switch (ChemistryDispenser.ThisState) { case (PowerStates.OverVoltage): OutDispensedNumber = DispensedNumber * 2; break; case (PowerStates.LowVoltage): OutDispensedNumber = DispensedNumber * 0.5f; break; default: OutDispensedNumber = DispensedNumber; break; } ChemistryDispenser.Container.Add(new ReagentMix(reagent, OutDispensedNumber, DispensedTemperatureCelsius)); } } } UpdateAll(); }
public ReagentMix(Reagent reagent, float amount, float temperature = TemperatureUtils.ZERO_CELSIUS_IN_KELVIN) { Temperature = temperature; reagents = new SerializableDictionary <Reagent, float> { [reagent] = amount }; }
public ContainerCustomSprite Get(Chemistry.Reagent reagent) { if (spritesData.ContainsKey(reagent)) { return(spritesData[reagent]); } return(null); }
public void TransferBufferToContainer(Reagent reagent, float amount) { ReagentMix tempTransfer = GetBufferMix(); //Container never gets swapped without clearing buffer, so we can assume there's space in container tempTransfer.Remove(reagent, amount); Container.CurrentReagentMix.Add(reagent, amount); TransferMixToBuffer(tempTransfer); UpdateGui(); }
public void RemoveFromBuffer(Reagent reagent, float amount) { ReagentMix tempTransfer = GetBufferMix(); //one removal, no math tempTransfer.Remove(reagent, amount); //part two of transfer: fill Buffer from tempTransfer Mix TransferMixToBuffer(tempTransfer); UpdateGui(); }
public void DispenseChemical(Chemistry.Reagent reagent) { if (ChemistryDispenser.Container != null) { //Logger.Log (Chemical); if (dispensableReagents.Contains(reagent)) //Checks if the the dispenser can dispense this chemical { ChemistryDispenser.Container.Add(new ReagentMix(reagent, DispensedNumber, DispensedTemperatureCelsius)); } } UpdateAll(); }
public void TransferSpecifiedTo(MixAndVolume toTransfer, Gas?SpecifiedGas = null, Chemistry.Reagent Reagent = null, Vector2?amount = null) { if (SpecifiedGas != null) { float ToRemovegas = 0; var Gas = SpecifiedGas.GetValueOrDefault(Atmospherics.Gas.Oxygen); if (amount != null) { ToRemovegas = amount.Value.y; } else { ToRemovegas = gasMix.Gases[Gas]; } float TransferredEnergy = ToRemovegas * Gas.MolarHeatCapacity * gasMix.Temperature; gasMix.RemoveGas(Gas, ToRemovegas); float CachedInternalEnergy = toTransfer.InternalEnergy + TransferredEnergy; //- TransferredEnergy; toTransfer.gasMix.AddGas(Gas, ToRemovegas); toTransfer.gasMix.InternalEnergy = CachedInternalEnergy; } if (Reagent != null) { float ToRemovegas = 0; if (amount != null) { ToRemovegas = amount.Value.x; } else { ToRemovegas = Mix[Reagent]; } float TransferredEnergy = ToRemovegas * Reagent.heatDensity * Mix.Temperature; float CachedInternalEnergy = Mix.InternalEnergy; Mix.Subtract(Reagent, ToRemovegas); Mix.InternalEnergy = CachedInternalEnergy - TransferredEnergy; CachedInternalEnergy = toTransfer.Mix.InternalEnergy; toTransfer.Mix.Add(Reagent, ToRemovegas); CachedInternalEnergy += TransferredEnergy; toTransfer.Mix.InternalEnergy = CachedInternalEnergy; } }
/// <summary> /// Players can check the remaining microwave time or insert something into the microwave. /// </summary> public void ServerPerformInteraction(HandApply interaction) { if (interaction.HandObject != null) { // Check if the player is holding food that can be ground up ItemAttributesV2 attr = interaction.HandObject.GetComponent <ItemAttributesV2>(); Ingredient ingredient = new Ingredient(attr.ArticleName); Chemistry.Reagent meal = CraftingManager.Grind.FindReagentRecipe(new List <Ingredient> { ingredient }); int count = CraftingManager.Grind.FindReagentAmount(new List <Ingredient> { ingredient }); if (meal) { grinder.SetServerStackAmount(count); grinder.ServerSetOutputMeal(meal.name); Despawn.ServerSingle(interaction.HandObject); Chat.AddExamineMsgFromServer(interaction.Performer, $"You grind the {attr.ArticleName}."); GetComponent <AIOGrinder>().GrindFood(); } else { Chat.AddExamineMsgFromServer(interaction.Performer, $"Your {attr.ArticleName} can not be ground up."); } } else { if (!grinderStorage.IsEmpty) { if (grinderStorage.ReagentMixTotal == grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent)) { Chat.AddExamineMsgFromServer(interaction.Performer, $"The grinder currently contains {grinderStorage.ReagentMixTotal} " + $"of {grinderStorage.MajorMixReagent}."); } else if (grinderStorage.ReagentMixTotal != grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent)) { Chat.AddExamineMsgFromServer(interaction.Performer, $"The grinder currently contains {grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent)} " + $"of {grinderStorage.MajorMixReagent}, as well as " + $"{grinderStorage.ReagentMixTotal - grinderStorage.AmountOfReagent(grinderStorage.MajorMixReagent)} of various other things."); } } else { Chat.AddExamineMsgFromServer(interaction.Performer, "The grinder is empty."); } } }
private void OnMixChanged() { // Check if major reagent changed in a mix var newMajorReagent = serverContainer.MajorMixReagent; if (newMajorReagent != majorReagent) { // get major reagent name var majorReagentName = newMajorReagent ? newMajorReagent.Name : ""; // now send it to all clients as string hash majorReagentNameHash = majorReagentName.GetStableHashCode(); majorReagent = newMajorReagent; } }
public void RemoveFromBuffer(Reagent reagent, float amount) { ReagentMix tempTransfer = GetBufferMix(); //one removal, no math tempTransfer.Remove(reagent, amount); //remove listing if empty if (tempTransfer.reagents[reagent] <= 0) { tempTransfer.reagentKeys.Remove(reagent); } //part two of transfer: fill Buffer from tempTransfer Mix TransferMixToBuffer(tempTransfer); UpdateGui(); }
public void TransferContainerToBuffer(Reagent reagent, float amount) { float capacity = 0; ReagentMix tempTransfer = GetBufferMix(); float currentTotal = tempTransfer.Total; if (BufferslotOne != null) { capacity += BufferslotOne.MaxCapacity; } if (BufferslotTwo != null) { capacity += BufferslotTwo.MaxCapacity; } //math float space = capacity - currentTotal; Logger.LogTrace($"Buffer| capacity:{capacity} total:{currentTotal} space:{space}", Category.Chemistry); //part one of transfer: isolate reagents, add to tempTransfer Mix if (space > 0) { Logger.LogTrace($"BEFORE| Mix:{Container.CurrentReagentMix}", Category.Chemistry); if (amount < space) { Container.CurrentReagentMix.Remove(reagent, amount); tempTransfer.Add(reagent, amount); } else { Container.CurrentReagentMix.Remove(reagent, space); tempTransfer.Add(reagent, space); } Logger.LogTrace($"AFTER|| Mix:{Container.CurrentReagentMix}", Category.Chemistry); } //part two of transfer: fill Buffer from tempTransfer Mix TransferMixToBuffer(tempTransfer); UpdateGui(); }
public void TransferBufferToContainer(Reagent reagent, float amount) { ReagentMix tempTransfer = GetBufferMix(); //Container never gets swapped without clearing buffer, so we can assume there's space in container tempTransfer.Remove(reagent, amount); Container.CurrentReagentMix.Add(reagent, amount); //remove listing if empty if (tempTransfer.reagents[reagent] <= 0) { lock (tempTransfer.reagents) { tempTransfer.reagents.m_dict.Remove(reagent); } } TransferMixToBuffer(tempTransfer); UpdateGui(); }
public float this[Reagent reagent] => reagents.m_dict.TryGetValue(reagent, out var amount) ? amount : 0;
/// <summary> /// Called when the implant receives the wrong reagent in the blood pumped too it. /// Returns the amount of blood reagent that remains after the pump event, in case it uses any of it. /// For example, maybe an organ is damaged by the wrong reagent. /// </summary> /// <param name="bloodReagent"></param> /// <param name="amount"></param> /// <returns></returns> public virtual float HandleWrongBloodReagent(Chemistry.Reagent bloodReagent, float amount) { return(amount); }