private void CropDeath() { if (plantData.PlantTrays.Contains(PlantTrays.Weed_Adaptation)) { nutritionLevel = nutritionLevel + plantData.Potency; if (nutritionLevel > 100) { nutritionLevel = 100; } } if (plantData.PlantTrays.Contains(PlantTrays.Fungal_Vitality)) { Dictionary <string, float> reagent = new Dictionary <string, float> { ["water"] = plantData.Potency }; reagentContainer.AddReagents(reagent); } SyncGrowingPlantStage(0); plantSubStage = 0; plantHealth = 100; readyToHarvest = false; numberOfUpdatesAlive = 0; SyncStage(PlantSpriteStage.Dead); plantData = null; hasPlant = false; readyProduce.Clear(); SyncHarvest(false); }
private void CropDeath() { if (plantData.PlantTrays.Contains(PlantTrays.Weed_Adaptation)) { nutritionLevel = nutritionLevel + plantData.Potency; if (nutritionLevel > 100) { nutritionLevel = 100; } } if (plantData.PlantTrays.Contains(PlantTrays.Fungal_Vitality)) { Dictionary <string, float> reagent = new Dictionary <string, float> { ["water"] = plantData.Potency }; reagentContainer.AddReagents(reagent); } UpdatePlantGrowthStage(growingPlantStage, 0); UpdatePlantStage(plantCurrentStage, PlantSpriteStage.Dead); plantData = null; readyProduce.Clear(); UpdateHarvestFlag(harvestNotifier, false); }
private static ReagentContainer GetContainer(int maxCapacity, Dictionary <string, float> contents) { GameObject obj = new GameObject(); obj.AddComponent <ReagentContainer>(); ReagentContainer container = obj.GetComponent <ReagentContainer>(); container.MaxCapacity = maxCapacity; container.AddReagents(contents); return(container); }
public void SetupChemicalContents() { if (plantData.ReagentProduction.Count > 0) { var ChemicalDictionary = new Dictionary <string, float>(); foreach (var Chemical in plantData.ReagentProduction) { ChemicalDictionary[Chemical.Name] = (Chemical.Ammount * (plantData.Potency / 100f)); } reagentContainer.AddReagents(ChemicalDictionary); } }
public void MoveReagentsTo(int Amount, ReagentContainer To = null) { float Using = new float(); CurrentCapacity = AmountOfReagents(Contents); if (To != null) { if ((To.CurrentCapacity + Amount) > To.MaxCapacity) { Using = To.MaxCapacity - To.CurrentCapacity; } else { Using = Amount; } } else { Using = Amount; } double DivideAmount = Using / CurrentCapacity; Dictionary <string, float> Transfering = new Dictionary <string, float> (); List <string> keys = new List <string>(Contents.Keys); for (int i = 0; i < keys.Count; i++) { if ((Contents[keys[i]] * DivideAmount) > Contents[keys[i]]) { Transfering[keys[i]] = Contents[keys[i]]; Contents[keys[i]] = 0; } else { Transfering[keys[i]] = (float)(Contents[keys[i]] * DivideAmount); Contents[keys[i]] = Contents[keys[i]] - Transfering[keys[i]]; } } if (To != null) { To.AddReagents(Transfering, Temperature); } CurrentCapacity = AmountOfReagents(Contents); CheckForEmptys(); }
public void MoveReagentsTo(int Amount, ReagentContainer To = null) { float Using = new float(); CurrentCapacity = AmountOfReagents(Contents); if (To != null) { if ((To.CurrentCapacity + Amount) > To.MaxCapacity) { Using = To.MaxCapacity - To.CurrentCapacity; } else { Using = Amount; } } else { Using = Amount; } double DivideAmount = Using / CurrentCapacity; Dictionary <string, float> Transfering = new Dictionary <string, float> (); Dictionary <string, float> BrokenCS = new Dictionary <string, float> (Contents); foreach (KeyValuePair <string, float> Chemical in BrokenCS) { if ((Chemical.Value * DivideAmount) > Contents [Chemical.Key]) { Transfering [Chemical.Key] = Contents [Chemical.Key]; Contents [Chemical.Key] = 0; } else { Transfering [Chemical.Key] = (float)(Chemical.Value * DivideAmount); Contents [Chemical.Key] = Contents [Chemical.Key] - Transfering [Chemical.Key]; } } if (To != null) { To.AddReagents(Transfering, Temperature); } CurrentCapacity = AmountOfReagents(Contents); CheckForEmptys(); }
public void MoveReagentsTo(int amount, ReagentContainer target = null) { CurrentCapacity = AmountOfReagents(Contents); float toMove = target == null ? amount : Math.Min(target.MaxCapacity - target.CurrentCapacity, amount); float divideAmount = toMove / CurrentCapacity; var transfering = Contents.ToDictionary( reagent => reagent.Key, reagent => divideAmount > 1 ? reagent.Value : (reagent.Value * divideAmount) ); foreach (var reagent in transfering) { Contents[reagent.Key] -= reagent.Value; } Contents = Calculations.RemoveEmptyReagents(Contents); CurrentCapacity = AmountOfReagents(Contents); target?.AddReagents(transfering, Temperature); }
public void MoveReagentsTo(int amount, ReagentContainer target = null) { CurrentCapacity = AmountOfReagents(Contents); float toMove = target == null ? amount : Math.Min(target.MaxCapacity - target.CurrentCapacity, amount); float divideAmount = toMove / CurrentCapacity; var transfering = Contents.ToDictionary( chemical => chemical.Key, chemical => divideAmount > 1 ? chemical.Value : (chemical.Value * divideAmount) ); foreach (var chemical in transfering) { Contents[chemical.Key] -= chemical.Value; } RemoveEmptyChemicals(); CurrentCapacity = AmountOfReagents(Contents); target?.AddReagents(transfering, Temperature); }