public void UpdateFertilization(float dt) { if (base.def.consumedElements != null && !((Object)storage == (Object)null)) { bool value = true; bool value2 = false; List <GameObject> items = storage.items; for (int i = 0; i < base.def.consumedElements.Length; i++) { PlantElementAbsorber.ConsumeInfo consumeInfo = base.def.consumedElements[i]; float num = 0f; for (int j = 0; j < items.Count; j++) { GameObject gameObject = items[j]; if (gameObject.HasTag(consumeInfo.tag)) { num += gameObject.GetComponent <PrimaryElement>().Mass; } else if (gameObject.HasTag(base.def.wrongFertilizerTestTag)) { value2 = true; } } total_available_mass = num; if (num < consumeInfo.massConsumptionRate * dt) { value = false; break; } } base.sm.hasCorrectFertilizer.Set(value, base.smi); base.sm.hasIncorrectFertilizer.Set(value2, base.smi); } }
public void SetStorage(object obj) { storage = (Storage)obj; base.sm.resourceStorage.Set(storage, base.smi); DumpIncorrectFertilizers(storage, base.smi.gameObject); ManualDeliveryKG[] components = base.smi.gameObject.GetComponents <ManualDeliveryKG>(); foreach (ManualDeliveryKG manualDeliveryKG in components) { bool flag = false; PlantElementAbsorber.ConsumeInfo[] consumedElements = base.def.consumedElements; for (int j = 0; j < consumedElements.Length; j++) { PlantElementAbsorber.ConsumeInfo consumeInfo = consumedElements[j]; if (manualDeliveryKG.requestedItemTag == consumeInfo.tag) { flag = true; break; } } if (flag) { manualDeliveryKG.SetStorage(storage); manualDeliveryKG.enabled = !storage.gameObject.GetComponent <PlantablePlot>().has_liquid_pipe_input; } } }
public void SetStorage(object obj) { storage = (Storage)obj; base.sm.fertilizerStorage.Set(storage, base.smi); IrrigationMonitor.Instance.DumpIncorrectFertilizers(storage, base.smi.gameObject); ManualDeliveryKG[] components = base.smi.gameObject.GetComponents <ManualDeliveryKG>(); foreach (ManualDeliveryKG manualDeliveryKG in components) { bool flag = false; PlantElementAbsorber.ConsumeInfo[] consumedElements = base.def.consumedElements; for (int j = 0; j < consumedElements.Length; j++) { PlantElementAbsorber.ConsumeInfo consumeInfo = consumedElements[j]; if (manualDeliveryKG.requestedItemTag == consumeInfo.tag) { flag = true; break; } } if (flag) { manualDeliveryKG.SetStorage(storage); manualDeliveryKG.enabled = true; } } }
public static GameObject ExtendPlantToIrrigated(GameObject template, PlantElementAbsorber.ConsumeInfo info) { return(ExtendPlantToIrrigated(template, new PlantElementAbsorber.ConsumeInfo[1] { info })); }
public static GameObject ExtendPlantToFertilizable(GameObject template, PlantElementAbsorber.ConsumeInfo[] fertilizers) { HashedString idHash = Db.Get().ChoreTypes.FarmFetch.IdHash; for (int i = 0; i < fertilizers.Length; i++) { PlantElementAbsorber.ConsumeInfo consumeInfo = fertilizers[i]; ManualDeliveryKG manualDeliveryKG = template.AddComponent <ManualDeliveryKG>(); manualDeliveryKG.RequestedItemTag = consumeInfo.tag; manualDeliveryKG.capacity = consumeInfo.massConsumptionRate * 600f * 3f; manualDeliveryKG.refillMass = consumeInfo.massConsumptionRate * 600f * 0.5f; manualDeliveryKG.minimumMass = consumeInfo.massConsumptionRate * 600f * 0.5f; manualDeliveryKG.operationalRequirement = FetchOrder2.OperationalRequirement.Functional; manualDeliveryKG.choreTypeIDHash = idHash; } KPrefabID component = template.GetComponent <KPrefabID>(); FertilizationMonitor.Def def = template.AddOrGetDef <FertilizationMonitor.Def>(); def.wrongFertilizerTestTag = GameTags.Solid; def.consumedElements = fertilizers; component.prefabInitFn += delegate(GameObject inst) { ManualDeliveryKG[] components = inst.GetComponents <ManualDeliveryKG>(); foreach (ManualDeliveryKG manualDeliveryKG2 in components) { manualDeliveryKG2.Pause(true, "init"); } }; return(template); }
public void UpdateIrrigation(float dt) { if (base.def.consumedElements != null) { Storage storage = base.sm.resourceStorage.Get <Storage>(base.smi); bool flag = true; bool value = false; bool flag2 = true; if ((Object)storage != (Object)null) { List <GameObject> items = storage.items; for (int i = 0; i < base.def.consumedElements.Length; i++) { float num = 0f; PlantElementAbsorber.ConsumeInfo consumeInfo = base.def.consumedElements[i]; for (int j = 0; j < items.Count; j++) { GameObject gameObject = items[j]; if (gameObject.HasTag(consumeInfo.tag)) { num += gameObject.GetComponent <PrimaryElement>().Mass; } else if (gameObject.HasTag(base.def.wrongIrrigationTestTag)) { value = true; } } total_available_mass = num; if (num < consumeInfo.massConsumptionRate * dt) { flag = false; break; } if (num < consumeInfo.massConsumptionRate * (dt * 30f)) { flag2 = false; break; } } } else { flag = false; flag2 = false; value = false; } base.sm.hasCorrectLiquid.Set(flag, base.smi); base.sm.hasIncorrectLiquid.Set(value, base.smi); base.sm.enoughCorrectLiquidToRecover.Set(flag2 && flag, base.smi); } }
private string GetFertilizationLabel(GameObject go) { FertilizationMonitor.Instance sMI = go.GetSMI <FertilizationMonitor.Instance>(); string text = Db.Get().Amounts.Fertilization.Name; PlantElementAbsorber.ConsumeInfo[] consumedElements = sMI.def.consumedElements; for (int i = 0; i < consumedElements.Length; i++) { PlantElementAbsorber.ConsumeInfo consumeInfo = consumedElements[i]; string text2 = text; text = text2 + "\n • " + ElementLoader.GetElement(consumeInfo.tag).name + " " + GameUtil.GetFormattedMass(consumeInfo.massConsumptionRate, GameUtil.TimeSlice.PerCycle, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}"); } return(text); }
public List <Descriptor> GetDescriptors(GameObject obj) { if (consumedElements.Length > 0) { List <Descriptor> list = new List <Descriptor>(); PlantElementAbsorber.ConsumeInfo[] array = consumedElements; for (int i = 0; i < array.Length; i++) { PlantElementAbsorber.ConsumeInfo consumeInfo = array[i]; list.Add(new Descriptor(string.Format(UI.GAMEOBJECTEFFECTS.IDEAL_FERTILIZER, consumeInfo.tag.ProperName(), GameUtil.GetFormattedMass(0f - consumeInfo.massConsumptionRate, GameUtil.TimeSlice.PerCycle, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")), string.Format(UI.GAMEOBJECTEFFECTS.TOOLTIPS.IDEAL_FERTILIZER, consumeInfo.tag.ProperName(), GameUtil.GetFormattedMass(consumeInfo.massConsumptionRate, GameUtil.TimeSlice.PerCycle, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")), Descriptor.DescriptorType.Requirement, false)); } return(list); } return(null); }
private static void DumpIncorrectFertilizers(Storage storage, PlantElementAbsorber.ConsumeInfo[] consumed_infos, bool validate_solids) { if (!((Object)storage == (Object)null)) { for (int num = storage.items.Count - 1; num >= 0; num--) { GameObject gameObject = storage.items[num]; if (!((Object)gameObject == (Object)null)) { PrimaryElement component = gameObject.GetComponent <PrimaryElement>(); if (!((Object)component == (Object)null) && !((Object)gameObject.GetComponent <ElementChunk>() == (Object)null)) { if (validate_solids) { if (!component.Element.IsSolid) { continue; } } else if (!component.Element.IsLiquid) { continue; } bool flag = false; KPrefabID component2 = component.GetComponent <KPrefabID>(); if (consumed_infos != null) { for (int i = 0; i < consumed_infos.Length; i++) { PlantElementAbsorber.ConsumeInfo consumeInfo = consumed_infos[i]; if (component2.HasTag(consumeInfo.tag)) { flag = true; break; } } } if (!flag) { storage.Drop(gameObject, true); } } } } } }
public static GameObject ExtendPlantToIrrigated(GameObject template, PlantElementAbsorber.ConsumeInfo[] consume_info) { HashedString idHash = Db.Get().ChoreTypes.FarmFetch.IdHash; for (int i = 0; i < consume_info.Length; i++) { PlantElementAbsorber.ConsumeInfo consumeInfo = consume_info[i]; ManualDeliveryKG manualDeliveryKG = template.AddComponent <ManualDeliveryKG>(); manualDeliveryKG.RequestedItemTag = consumeInfo.tag; manualDeliveryKG.capacity = consumeInfo.massConsumptionRate * 600f * 3f; manualDeliveryKG.refillMass = consumeInfo.massConsumptionRate * 600f * 0.5f; manualDeliveryKG.minimumMass = consumeInfo.massConsumptionRate * 600f * 0.5f; manualDeliveryKG.operationalRequirement = FetchOrder2.OperationalRequirement.Functional; manualDeliveryKG.choreTypeIDHash = idHash; } IrrigationMonitor.Def def = template.AddOrGetDef <IrrigationMonitor.Def>(); def.wrongIrrigationTestTag = GameTags.Liquid; def.consumedElements = consume_info; return(template); }