public static GameObject CreateOreEntity(SimHashes elementID, CollisionShape shape, float width, float height, List <Tag> additionalTags = null, float default_temperature = 293f) { Element element = ElementLoader.FindElementByHash(elementID); GameObject gameObject = Object.Instantiate(baseOreTemplate); gameObject.name = element.name; Object.DontDestroyOnLoad(gameObject); KPrefabID kPrefabID = gameObject.AddOrGet <KPrefabID>(); kPrefabID.PrefabTag = element.tag; if (additionalTags != null) { foreach (Tag additionalTag in additionalTags) { kPrefabID.AddTag(additionalTag, false); } } if (element.lowTemp < 296.15f && element.highTemp > 296.15f) { kPrefabID.AddTag(GameTags.PedestalDisplayable, false); } PrimaryElement primaryElement = gameObject.AddOrGet <PrimaryElement>(); primaryElement.SetElement(elementID); primaryElement.Mass = 1f; primaryElement.Temperature = default_temperature; Pickupable pickupable = gameObject.AddOrGet <Pickupable>(); pickupable.SetWorkTime(5f); pickupable.sortOrder = element.buildMenuSort; KSelectable kSelectable = gameObject.AddOrGet <KSelectable>(); kSelectable.SetName(element.name); KBatchedAnimController kBatchedAnimController = gameObject.AddOrGet <KBatchedAnimController>(); kBatchedAnimController.AnimFiles = new KAnimFile[1] { element.substance.anim }; kBatchedAnimController.sceneLayer = Grid.SceneLayer.Front; kBatchedAnimController.initialAnim = "idle1"; kBatchedAnimController.isMovable = true; return(AddCollision(gameObject, shape, width, height)); }
public static void Postfix(Toilet __instance, ref Worker worker) { Element element = ElementLoader.FindElementByHash(__instance.solidWastePerUse.elementID); byte index = Db.Get().Diseases.GetIndex(__instance.diseaseId); Storage massConsumptionTracker = worker.GetComponents <Storage>()[1]; GameObject go = element.substance.SpawnResource(__instance.transform.GetPosition(), massConsumptionTracker.MassStored(), __instance.solidWasteTemperature, index, __instance.diseasePerFlush, true, false, false); Traverse.Create(__instance).Field("storage").Method("Store", go, false, false, true, false).GetValue <GameObject>(); PrimaryElement component = worker.GetComponent <PrimaryElement>(); component.AddDisease(index, __instance.diseaseOnDupePerFlush, "Toilet.Flush"); PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, string.Format(DUPLICANTS.DISEASES.ADDED_POPFX, Db.Get().Diseases[(int)index].Name, __instance.diseasePerFlush + __instance.diseaseOnDupePerFlush), __instance.transform, Vector3.up, 1.5f, false, false); __instance.FlushesUsed++; Traverse.Create(__instance).Field("meter").Method("SetPositionPercent", (float)__instance.FlushesUsed / (float)__instance.maxFlushes).GetValue(); Tutorial.Instance.TutorialMessage(Tutorial.TutorialMessages.TM_LotsOfGerms, true); }
public void ReleaseGasPressure(float dt) { PrimaryElement primaryElement = storage.FindPrimaryElement(gasElement); if ((Object)primaryElement != (Object)null && primaryElement.Mass > 0f) { float num = releaseGasRate * dt; if ((Object)base.worker != (Object)null) { num *= GetEfficiencyMultiplier(base.worker); } num = Mathf.Min(num, primaryElement.Mass); SimUtil.DiseaseInfo percentOfDisease = SimUtil.GetPercentOfDisease(primaryElement, num / primaryElement.Mass); primaryElement.Mass -= num; Game.Instance.accumulators.Accumulate(accumulator, num); SimMessages.AddRemoveSubstance(Grid.PosToCell(this), ElementLoader.GetElementIndex(gasElement), null, num, primaryElement.Temperature, percentOfDisease.idx, percentOfDisease.count, true, -1); } UpdatePressurePercent(); }
private static Pickupable OnTake(HandleVector <int> .Handle handle, float amount) { ElementSplitter data = GameComps.ElementSplitters.GetData(handle); Pickupable component = data.primaryElement.GetComponent <Pickupable>(); Pickupable pickupable = component; Storage storage = component.storage; PrimaryElement component2 = component.GetComponent <PrimaryElement>(); pickupable = component2.Element.substance.SpawnResource(component.transform.GetPosition(), amount, component2.Temperature, byte.MaxValue, 0, true, false, false).GetComponent <Pickupable>(); component.TotalAmount -= amount; pickupable.Trigger(1335436905, component); CopyRenderSettings(component.GetComponent <KBatchedAnimController>(), pickupable.GetComponent <KBatchedAnimController>()); if ((UnityEngine.Object)storage != (UnityEngine.Object)null) { storage.Trigger(-1697596308, data.primaryElement.gameObject); storage.Trigger(-778359855, null); } return(pickupable); }
private bool IsValidDigCell(int cell, object arg = null) { if (Grid.IsValidCell(cell) && Grid.Solid[cell]) { if (!Grid.HasDoor[cell] && !Grid.Foundation[cell]) { byte index = Grid.ElementIdx[cell]; Element element = ElementLoader.elements[index]; return(Grid.Element[cell].hardness < 150 && !element.HasTag(GameTags.RefinedMetal)); } GameObject gameObject = Grid.Objects[cell, 1]; if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null) { PrimaryElement component = gameObject.GetComponent <PrimaryElement>(); return(Grid.Element[cell].hardness < 150 && !component.Element.HasTag(GameTags.RefinedMetal)); } } return(false); }
public static bool Prefix(AutoDisinfectable __instance, PrimaryElement ___primaryElement, ref Chore ___chore) { if (KMonoBehaviour.isLoadingScene) { return(true); } if (___primaryElement.DiseaseIdx != RadiationGerms.Index) { return(true); } if (___chore != null) { ___chore.Cancel("AutoDisinfect Radiation"); ___chore = null; } return(false); }
protected override void ConduitUpdate(float dt) { int cell = Grid.PosToCell(this); SolidConduitFlow.ConduitContents contents = Game.Instance.solidConduitFlow.GetContents(cell); if (contents.pickupableHandle.IsValid()) { Pickupable pickupable = Game.Instance.solidConduitFlow.GetPickupable(contents.pickupableHandle); PrimaryElement primaryElement = pickupable.GetComponent <PrimaryElement>(); if (primaryElement != null) { this.currentValue = primaryElement.DiseaseCount; } else { return; } } else { return; } // spawn code should never toggle as it crashes on load if (dt < 0) { return; } if (this.activateAboveThreshold) { if ((this.currentValue > this.threshold && !base.IsSwitchedOn) || (this.currentValue <= this.threshold && base.IsSwitchedOn)) { this.Toggle(); } } else if ((this.currentValue > this.threshold && base.IsSwitchedOn) || (this.currentValue <= this.threshold && !base.IsSwitchedOn)) { this.Toggle(); } }
protected void ConvertToElement() { PrimaryElement component = base.smi.master.GetComponent <PrimaryElement>(); float mass = component.Mass; float temperature = component.Temperature; if (mass <= 0f) { Util.KDestroyGameObject(base.gameObject); } else { SimHashes hash = SimHashes.ToxicSand; Substance substance = ElementLoader.FindElementByHash(hash).substance; GameObject gameObject = substance.SpawnResource(base.smi.master.transform.GetPosition(), mass, temperature, byte.MaxValue, 0, false, false, false); PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Resource, ElementLoader.FindElementByHash(hash).name, gameObject.transform, 1.5f, false); Util.KDestroyGameObject(base.smi.gameObject); } }
private PrimaryElement GetFirstPrimaryElement() { Storage component1 = GetComponent <Storage>(); for (int idx = 0; idx < component1.Count; ++idx) { GameObject gameObject = component1[idx]; if (!(gameObject == null)) { PrimaryElement component2 = gameObject.GetComponent <PrimaryElement>(); if (!(component2 == null)) { component2.KeepZeroMassObject = false; } return(component2); } } return(null); }
public static void SpawnGas(GameObject go, byte germIdx, float maxBonus, SimHashes gasHash) { int higherGerms = Numbers.GetGermCount(go, germIdx); float bonus = Numbers.PercentOfMaxGerms(higherGerms); float amount = bonus * maxBonus; PrimaryElement goPrimary = go.GetComponent <PrimaryElement>(); if (goPrimary == null) { return; } float temperature = goPrimary.Temperature; Element element = ElementLoader.FindElementByHash(gasHash); if (amount > 0) { SimMessages.AddRemoveSubstance(Grid.PosToCell(go), (int)element.idx, CellEventLogger.Instance.ElementConsumerSimUpdate, amount, temperature, germIdx, higherGerms); } }
private void Update() { List <FoodBit> list = new List <FoodBit>(); if ((Object)WorldInventory.Instance != (Object)null) { List <Pickupable> pickupables = WorldInventory.Instance.GetPickupables(GameTags.Edible); if (pickupables == null) { return; } foreach (Pickupable item in pickupables) { Edible component = item.GetComponent <Edible>(); if ((Object)component != (Object)null) { PrimaryElement component2 = component.GetComponent <PrimaryElement>(); list.Add(new FoodBit { name = component.name, rations = component.Calories / 1000f / 1000f, disease = component2.DiseaseCount }); } } } if (list.Count != 0) { list.Sort((FoodBit a, FoodBit b) => a.DiseasePerRation.CompareTo(b.DiseasePerRation)); FoodBit foodBit = list[0]; minText.text = "Min: " + foodBit.ToString(); FoodBit foodBit2 = list[list.Count - 1]; maxText.text = "Max: " + foodBit2.ToString(); FoodBit foodBit3 = list[list.Count / 2]; medianText.text = "Median: " + foodBit3.ToString(); float num = (from b in list select b.rations).Sum(); int num2 = (from b in list select b.disease).Sum(); avgText.text = "Average: " + ((float)num2 / num).ToString(); } }
public void Sim33ms(float dt) { EntombedItemVisualizer component = Game.Instance.GetComponent <EntombedItemVisualizer>(); HashSetPool <Pickupable, EntombedItemManager> .PooledHashSet pooledHashSet = HashSetPool <Pickupable, EntombedItemManager> .Allocate(); foreach (Pickupable pickupable in pickupables) { if (CanEntomb(pickupable)) { pooledHashSet.Add(pickupable); } } pickupables.Clear(); foreach (Pickupable item in pooledHashSet) { int num = Grid.PosToCell(item); PrimaryElement component2 = item.GetComponent <PrimaryElement>(); SimHashes elementID = component2.ElementID; float mass = component2.Mass; float temperature = component2.Temperature; byte diseaseIdx = component2.DiseaseIdx; int diseaseCount = component2.DiseaseCount; Element element = Grid.Element[num]; if (elementID == element.id && mass > 0.0100000007f && Grid.Mass[num] + mass < element.maxMass) { SimMessages.AddRemoveSubstance(num, ElementLoader.FindElementByHash(elementID).idx, CellEventLogger.Instance.ElementConsumerSimUpdate, mass, temperature, diseaseIdx, diseaseCount, true, -1); } else { component.AddItem(num); cells.Add(num); elementIds.Add((int)elementID); masses.Add(mass); temperatures.Add(temperature); diseaseIndices.Add(diseaseIdx); diseaseCounts.Add(diseaseCount); } Util.KDestroyGameObject(item.gameObject); } pooledHashSet.Recycle(); }
public static void DoStateTransition(int sim_handle) { SimTemperatureTransfer value = null; if (handleInstanceMap.TryGetValue(sim_handle, out value) && !((UnityEngine.Object)value == (UnityEngine.Object)null) && !value.HasTag(GameTags.Sealed)) { PrimaryElement component = value.GetComponent <PrimaryElement>(); Element element = component.Element; if (element.highTempTransitionTarget != SimHashes.Unobtanium) { if (component.Mass > 0f) { int gameCell = Grid.PosToCell(value.transform.GetPosition()); SimMessages.AddRemoveSubstance(gameCell, element.highTempTransitionTarget, CellEventLogger.Instance.OreMelted, component.Mass, component.Temperature, component.DiseaseIdx, component.DiseaseCount, true, -1); } value.OnCleanUp(); Util.KDestroyGameObject(value.gameObject); } } }
private PrimaryElement FindSuitableElement() { List <GameObject> items = storage.items; int count = items.Count; for (int i = 0; i < count; i++) { int index = (i + ElementOutputOffset) % count; PrimaryElement component = items[index].GetComponent <PrimaryElement>(); if (component != null && component.Mass > 0f && MatchesConduit(component)) { if (ElementFilter == null || ElementFilter.Length == 0 || MatchesFilter(component.ElementID)) { ElementOutputOffset = (ElementOutputOffset + 1) % count; return(component); } } } return(null); }
/// <summary> /// Swap the dupes facing before starting the reactable /// </summary> static void Prefix(GameObject new_reactor, Navigator.ActiveTransition transition) { PrimaryElement dupe = new_reactor?.GetComponent <PrimaryElement>(); if (dupe != null) { Navigator navigator = dupe.GetComponent <Navigator>(); if (navigator != null) { NavGrid.Transition nextTransition = navigator.GetNextTransition(); if (nextTransition.x < 0) { // Mirror dupes facing direction to the initial direction dupe.GetComponent <Facing>()?.SetFacing(true); } } } }
public Instance(IStateMachineTarget master, Def def) : base(master, def) { pickupable = base.gameObject.RequireComponent <Pickupable>(); base.master.Subscribe(-2064133523, OnAbsorb); base.master.Subscribe(1335436905, OnSplitFromChunk); primaryElement = base.gameObject.GetComponent <PrimaryElement>(); Amounts amounts = master.gameObject.GetAmounts(); RotAmountInstance = amounts.Add(new AmountInstance(Db.Get().Amounts.Rot, master.gameObject)); RotAmountInstance.maxAttribute.ClearModifiers(); RotAmountInstance.maxAttribute.Add(new AttributeModifier("Rot", def.spoilTime, null, false, false, true)); RotAmountInstance.SetValue(def.spoilTime); base.sm.rotParameter.Set(RotAmountInstance.value, base.smi); UnrefrigeratedModifier = new AttributeModifier("Rot", 0f, DUPLICANTS.MODIFIERS.ROTTEMPERATURE.NAME, false, false, false); ContaminatedAtmosphere = new AttributeModifier("Rot", 0f, DUPLICANTS.MODIFIERS.ROTATMOSPHERE.NAME, false, false, false); RotAmountInstance.deltaAttribute.Add(UnrefrigeratedModifier); RotAmountInstance.deltaAttribute.Add(ContaminatedAtmosphere); RefreshModifiers(0f); }
private PrimaryElement FindSuitableElement() { List <GameObject> items = storage.items; int count = items.Count; for (int i = 0; i < count; i++) { int index = (i + elementOutputOffset) % count; PrimaryElement component = items[index].GetComponent <PrimaryElement>(); if (component != null && component.Mass > 0 && (portInfo.conduitType != ConduitType.Liquid ? component.Element.IsGas : component.Element.IsLiquid) && IsAllowedElement(component.ElementID)) { elementOutputOffset = (elementOutputOffset + 1) % count; return(component); } } return(null); }
private bool IsReady(StatesInstance smi) { PrimaryElement primaryElement = smi.GetComponent <Storage>().FindPrimaryElement(SimHashes.Water); if ((Object)primaryElement == (Object)null) { return(false); } if (primaryElement.Mass < WATER_MASS_PER_USE) { return(false); } float amountAvailable = smi.GetComponent <Storage>().GetAmountAvailable(INGREDIENT_TAG); if (amountAvailable < INGREDIENT_MASS_PER_USE) { return(false); } return(true); }
public override List <Descriptor> AdditionalEffectsForRecipe(ComplexRecipe recipe) { List <Descriptor> list = base.AdditionalEffectsForRecipe(recipe); GameObject prefab = Assets.GetPrefab(recipe.results[0].material); PrimaryElement component = prefab.GetComponent <PrimaryElement>(); PrimaryElement primaryElement = inStorage.FindFirstWithMass(coolantTag); string format = UI.BUILDINGEFFECTS.TOOLTIPS.REFINEMENT_ENERGY_HAS_COOLANT; if ((Object)primaryElement == (Object)null) { GameObject prefab2 = Assets.GetPrefab(GameTags.Water); primaryElement = prefab2.GetComponent <PrimaryElement>(); format = UI.BUILDINGEFFECTS.TOOLTIPS.REFINEMENT_ENERGY_NO_COOLANT; } float num = 0f - GameUtil.CalculateEnergyDeltaForElementChange(component.Element.specificHeatCapacity, recipe.results[0].amount, component.Element.highTemp, outputTemperature); float temp = GameUtil.CalculateTemperatureChange(primaryElement.Element.specificHeatCapacity, minCoolantMass, num * thermalFudge); list.Add(new Descriptor(string.Format(UI.BUILDINGEFFECTS.REFINEMENT_ENERGY, GameUtil.GetFormattedJoules(num, "F1", GameUtil.TimeSlice.None)), string.Format(format, GameUtil.GetFormattedJoules(num, "F1", GameUtil.TimeSlice.None), primaryElement.GetProperName(), GameUtil.GetFormattedTemperature(temp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Relative, true, false)), Descriptor.DescriptorType.Effect, false)); return(list); }
private bool EmitCommon(int cell, PrimaryElement primary_element, EmitDelegate emit) { if (primary_element.Mass <= 0.0) { return(false); } int disease_to_item1; int disease_to_item2; CalculateDiseaseTransfer(exhaustPE, primary_element, 0.05f, out disease_to_item1, out disease_to_item2); primary_element.ModifyDiseaseCount(-disease_to_item1, "Exhaust transfer"); primary_element.AddDisease(exhaustPE.DiseaseIdx, disease_to_item2, "Exhaust transfer"); exhaustPE.ModifyDiseaseCount(-disease_to_item2, "Exhaust transfer"); exhaustPE.AddDisease(primary_element.DiseaseIdx, disease_to_item1, "Exhaust transfer"); emit(cell, primary_element); primary_element.KeepZeroMassObject = true; primary_element.Mass = 0.0f; primary_element.ModifyDiseaseCount(int.MinValue, "Exhaust.SimUpdate"); return(true); }
private void Emit(EnergyGenerator.OutputItem output, float dt, PrimaryElement root_pe) { Element element = ElementLoader.FindElementByHash(output.element); float num = output.creationRate * dt; if (output.store) { if (element.IsGas) { this.storage.AddGasChunk(output.element, num, root_pe.Temperature, 255, 0, true, true); } else if (element.IsLiquid) { this.storage.AddLiquid(output.element, num, root_pe.Temperature, 255, 0, true, true); } else { GameObject go = element.substance.SpawnResource(base.transform.GetPosition(), num, root_pe.Temperature, 255, 0, false, false, false); this.storage.Store(go, true, false, true, false); } } else { int cell = Grid.PosToCell(base.transform.GetPosition()); int num2 = Grid.OffsetCell(cell, output.emitOffset); float temperature = Mathf.Max(root_pe.Temperature, output.minTemperature); if (element.IsGas) { SimMessages.ModifyMass(num2, num, 255, 0, CellEventLogger.Instance.EnergyGeneratorModifyMass, temperature, output.element); } else if (element.IsLiquid) { int elementIndex = ElementLoader.GetElementIndex(output.element); FallingWater.instance.AddParticle(num2, (byte)elementIndex, num, temperature, 255, 0, true, false, false, false); } else { element.substance.SpawnResource(Grid.CellToPosCCC(num2, Grid.SceneLayer.Front), num, temperature, 255, 0, true, false, false); } } }
public static GameObject ConfigBasicEntity(GameObject template, string id, string name, string desc, float mass, bool unitMass, KAnimFile anim, string initialAnim, Grid.SceneLayer sceneLayer, SimHashes element = SimHashes.Creature, List <Tag> additionalTags = null, float defaultTemperature = 293f) { ConfigEntity(template, id, name, true); KPrefabID kPrefabID = template.AddOrGet <KPrefabID>(); if (additionalTags != null) { foreach (Tag additionalTag in additionalTags) { kPrefabID.AddTag(additionalTag, false); } } KBatchedAnimController kBatchedAnimController = template.AddOrGet <KBatchedAnimController>(); kBatchedAnimController.AnimFiles = new KAnimFile[1] { anim }; kBatchedAnimController.sceneLayer = sceneLayer; kBatchedAnimController.initialAnim = initialAnim; template.AddOrGet <StateMachineController>(); PrimaryElement primaryElement = template.AddOrGet <PrimaryElement>(); primaryElement.ElementID = element; primaryElement.Temperature = defaultTemperature; if (unitMass) { primaryElement.MassPerUnit = mass; primaryElement.Units = 1f; GameTags.DisplayAsUnits.Add(kPrefabID.PrefabTag); } else { primaryElement.Mass = mass; } InfoDescription infoDescription = template.AddOrGet <InfoDescription>(); infoDescription.description = desc; template.AddOrGet <Notifier>(); return(template); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (Coding != null) { Coding.ForEach(elem => result.AddRange(elem.Validate())); } if (TextElement != null) { result.AddRange(TextElement.Validate()); } if (PrimaryElement != null) { result.AddRange(PrimaryElement.Validate()); } return(result); }
private void CheckStorage() { //var bleachStoneTag = SimHashes.BleachStone.CreateTag(); for (int i = 0; i < storage.items.Count; i++) { GameObject storageItem = storage.items[i]; if (storageItem != null) { if (storageItem.HasTag(GameTags.AnyWater)) { continue; } i--; storage.Remove(storageItem); PrimaryElement element = storageItem.GetComponent <PrimaryElement>(); int disease_count = (int)(element.DiseaseCount * element.Mass); SimMessages.AddRemoveSubstance(Grid.PosToCell(transform.GetPosition()), element.Element.id, CellEventLogger.Instance.ConduitConsumerWrongElement, element.Mass, element.Temperature, element.DiseaseIdx, disease_count); } } }
public bool UpdateFullnessState() { float num = 0f; ListPool <GameObject, FlushToilet> .PooledList pooledList = ListPool <GameObject, FlushToilet> .Allocate(); base.master.storage.Find(WaterTag, pooledList); foreach (GameObject item in pooledList) { PrimaryElement component = item.GetComponent <PrimaryElement>(); num += component.Mass; } pooledList.Recycle(); bool flag = num >= base.master.massConsumedPerUse; base.master.conduitConsumer.enabled = !flag; float positionPercent = Mathf.Clamp01(num / base.master.massConsumedPerUse); base.master.fillMeter.SetPositionPercent(positionPercent); return(flag); }
private void MakeIce(StatesInstance smi, float dt) { float num = heatRemovalRate * dt / (float)waterStorage.items.Count; foreach (GameObject item in waterStorage.items) { PrimaryElement component = item.GetComponent <PrimaryElement>(); GameUtil.DeltaThermalEnergy(component, 0f - num, smi.master.targetTemperature); } for (int num2 = waterStorage.items.Count; num2 > 0; num2--) { GameObject gameObject = waterStorage.items[num2 - 1]; if ((bool)gameObject && gameObject.GetComponent <PrimaryElement>().Temperature < gameObject.GetComponent <PrimaryElement>().Element.lowTemp) { PrimaryElement component2 = gameObject.GetComponent <PrimaryElement>(); waterStorage.AddOre(component2.Element.lowTempTransitionTarget, component2.Mass, component2.Temperature, component2.DiseaseIdx, component2.DiseaseCount, false, true); waterStorage.ConsumeIgnoringDisease(gameObject); } } smi.UpdateIceState(); }
private PrimaryElement FindSuitableElement() { List <GameObject> items = this.storage.items; int count = items.Count; int MaxAmountIndex = -1; float MaxAmount = -1f; for (int i = 0; i < count; i++) { int index = (i + this.elementOutputOffset) % count; PrimaryElement component = items[index].GetComponent <PrimaryElement>(); if (component != null && component.Mass > 0f && ((this.conduitType != ConduitType.Liquid) ? component.Element.IsGas : component.Element.IsLiquid) && (this.elementFilter == null || this.elementFilter.Length == 0 || (!this.invertElementFilter && this.IsFilteredElement(component.ElementID)) || (this.invertElementFilter && !this.IsFilteredElement(component.ElementID)))) { if (component.Mass >= this.pipeCapacity) { this.elementOutputOffset = (this.elementOutputOffset + 1) % count; return(component); } if (component.Mass > MaxAmount) { MaxAmount = component.Mass; MaxAmountIndex = index; } } } if (storage.MassStored() > this.outputThreshold) { if (MaxAmountIndex != -1) { PrimaryElement component = items[MaxAmountIndex].GetComponent <PrimaryElement>(); this.elementOutputOffset = MaxAmountIndex; return(component); } } return(null); }
private void ItemCardDisease(HoverTextDrawer hoverTextDrawer, KSelectable selectable) { if (!modeIsDisease) { return; } PrimaryElement primaryElement = selectable.GetComponent <PrimaryElement>(); string text13 = UI.OVERLAYS.DISEASE.NO_DISEASE; if (primaryElement != null && primaryElement.DiseaseIdx != 255) { text13 = GameUtil.GetFormattedDisease(primaryElement.DiseaseIdx, primaryElement.DiseaseCount, true); } Storage storage = selectable.GetComponent <Storage>(); if (storage != null && storage.showInUI) { foreach (GameObject item in storage.items) { if (item == null) { continue; } PrimaryElement itemElement = item.GetComponent <PrimaryElement>(); if (itemElement.DiseaseIdx != 255) { text13 += string.Format( UI.OVERLAYS.DISEASE.CONTAINER_FORMAT, item.GetComponent <KSelectable>().GetProperName(), GameUtil.GetFormattedDisease(itemElement.DiseaseIdx, itemElement.DiseaseCount, true) ); } } } hoverTextDrawer.NewLine(26); hoverTextDrawer.DrawIcon(__this.iconDash, 18); hoverTextDrawer.DrawText(text13, __this.Styles_Values.Property.Standard); }
protected override void OnCompleteWork(Worker worker) { base.OnCompleteWork(worker); if (this.session == null) { return; } Storage component1 = worker.GetComponent <Storage>(); float consumedAmount = this.session.GetConsumedAmount(); if ((double)consumedAmount > 0.0) { SubstanceChunk source = this.session.GetSource(); SimUtil.DiseaseInfo diseaseInfo = this.session != null?this.session.GetDiseaseInfo() : SimUtil.DiseaseInfo.Invalid; PrimaryElement component2 = source.GetComponent <PrimaryElement>(); Pickupable component3 = LiquidSourceManager.Instance.CreateChunk(component2.Element, consumedAmount, this.session.GetTemperature(), diseaseInfo.idx, diseaseInfo.count, this.transform.GetPosition()).GetComponent <Pickupable>(); component3.TotalAmount = consumedAmount; component3.Trigger(1335436905, (object)source.GetComponent <Pickupable>()); worker.workCompleteData = (object)component3; ///remove the emission for (int index = 0; index < component1.items.Count; ++index) { GameObject go = component1.items[index]; if (!((UnityEngine.Object)go == (UnityEngine.Object)null) && go.HasTag(component2.Element.tag)) { go.GetComponent <PrimaryElement>().Mass -= consumedAmount; } } //End remove emission if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { component1.Store(component3.gameObject, false, false, true, false); } } this.session.Cleanup(); this.session = (BottleFiller.WorkSession)null; }
protected override List <GameObject> SpawnOrderProduct(ComplexRecipe recipe) { List <GameObject> list = base.SpawnOrderProduct(recipe); foreach (GameObject item in list) { PrimaryElement component = item.GetComponent <PrimaryElement>(); if ((Object)component != (Object)null) { if (item.PrefabID() == (Tag)"MushBar") { byte index = Db.Get().Diseases.GetIndex("FoodPoisoning"); component.AddDisease(index, 1000, "Made of mud"); } if (item.GetComponent <PrimaryElement>().DiseaseCount > 0) { Tutorial.Instance.TutorialMessage(Tutorial.TutorialMessages.TM_DiseaseCooking, true); } } } return(list); }