protected override void OnCompleteWork(Worker worker) { float num = 0f; float num2 = 0f; bool flag = true; foreach (GameObject item in storage.items) { if (!((UnityEngine.Object)item == (UnityEngine.Object)null)) { PrimaryElement component = item.GetComponent <PrimaryElement>(); if (!((UnityEngine.Object)component == (UnityEngine.Object)null)) { num += component.Mass; num2 += component.Temperature * component.Mass; flag = (flag && component.HasTag(GameTags.Liquifiable)); } } } if (num <= 0f) { DebugUtil.LogWarningArgs(base.gameObject, "uhhh this constructable is about to generate a nan", "Item Count: ", storage.items.Count); } else { if (flag) { initialTemperature = Mathf.Min(num2 / num, 318.15f); } else { initialTemperature = Mathf.Clamp(num2 / num, 288.15f, 318.15f); } KAnimGraphTileVisualizer component2 = GetComponent <KAnimGraphTileVisualizer>(); UtilityConnections connections = (!((UnityEngine.Object)component2 == (UnityEngine.Object)null)) ? component2.Connections : ((UtilityConnections)0); if (IsReplacementTile) { int cell = Grid.PosToCell(base.transform.GetLocalPosition()); GameObject replacementCandidate = building.Def.GetReplacementCandidate(cell); if ((UnityEngine.Object)replacementCandidate != (UnityEngine.Object)null) { SimCellOccupier component3 = replacementCandidate.GetComponent <SimCellOccupier>(); if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { component3.DestroySelf(delegate { if ((UnityEngine.Object) this != (UnityEngine.Object)null && (UnityEngine.Object)base.gameObject != (UnityEngine.Object)null) { FinishConstruction(connections); } }); } else { Conduit component4 = replacementCandidate.GetComponent <Conduit>(); if ((UnityEngine.Object)component4 != (UnityEngine.Object)null) { ConduitFlow flowManager = component4.GetFlowManager(); flowManager.MarkForReplacement(cell); } BuildingComplete component5 = replacementCandidate.GetComponent <BuildingComplete>(); if ((UnityEngine.Object)component5 != (UnityEngine.Object)null) { component5.Subscribe(-21016276, delegate { FinishConstruction(connections); }); } else { Debug.LogWarning("Why am I trying to replace a: " + replacementCandidate.name); FinishConstruction(connections); } } KAnimGraphTileVisualizer component6 = replacementCandidate.GetComponent <KAnimGraphTileVisualizer>(); if ((UnityEngine.Object)component6 != (UnityEngine.Object)null) { component6.skipCleanup = true; } PrimaryElement component7 = replacementCandidate.GetComponent <PrimaryElement>(); float mass = component7.Mass; float temperature = component7.Temperature; byte diseaseIdx = component7.DiseaseIdx; int diseaseCount = component7.DiseaseCount; Debug.Assert(component7.Element != null && component7.Element.tag != (Tag)null); Deconstructable.SpawnItem(component7.transform.GetPosition(), component7.GetComponent <Building>().Def, component7.Element.tag, mass, temperature, diseaseIdx, diseaseCount); replacementCandidate.Trigger(1606648047, building.Def.TileLayer); replacementCandidate.DeleteObject(); } } else { FinishConstruction(connections); } PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Building, GetComponent <KSelectable>().GetName(), base.transform, 1.5f, false); } }