internal static void Prefix(ConduitFlowVisualizer __instance, int cell, ref float conductivity, ConduitFlow ___flowManager) { Pressurized pressure = Integration.GetPressurizedAt(cell, (ConduitType)conduitType.GetValue(___flowManager)); if (!Pressurized.IsDefault(pressure)) { conductivity = 1f; } }
internal static void Postfix(ConduitFlowVisualizer __instance, int cell, ConduitFlow ___flowManager, bool ___showContents, ref Color32 __result) { Pressurized pressure = Integration.GetPressurizedAt(cell, (ConduitType)conduitType.GetValue(___flowManager)); if (!Pressurized.IsDefault(pressure)) { __result = ___showContents ? pressure.Info.FlowOverlayTint : pressure.Info.FlowTint; } }
//Change the overlay tint for the pipe if it is a pressurized pipe. private static Color32 PatchThermalColor(Color32 original, SaveLoadRoot layerTarget) { Pressurized pressurized = layerTarget.GetComponent <Pressurized>(); if (pressurized != null && pressurized.Info != null && !pressurized.Info.IsDefault) { return(pressurized.Info.OverlayTint); } else { return(original); } }
//If the mass originates from a pressurized conduit, change the mass to fit within the default range. private static float ModifyApparentMass(float originalMass, int cell, ConduitType type) { try { Pressurized pressure = Integration.GetPressurizedAt(cell, type); if (!Pressurized.IsDefault(pressure)) { return(originalMass / pressure.Info.IncreaseMultiplier); } return(originalMass); } catch (Exception e) { Debug.LogError($"[Pressurized] Error caught in ModifyApparentMass ->\n{e.Message}"); } return(originalMass); }
private static ConduitFlow.ConduitContents SetMaxFlow(ConduitFlow.ConduitContents contents, ConduitBridge bridge, ConduitFlow manager) { //If the bridge is broken, prevent the bridge from operating by limiting what it sees. if (bridge.GetComponent <BuildingHP>().HitPoints == 0) { //does not actually remove mass from the conduit, just causes the bridge to assume there is no mass available to move. contents.RemoveMass(contents.mass); return(contents); } GameObject outputObject; int outputCell = (int)bridgeOutputCell.GetValue(bridge); float targetCapacity = Integration.GetMaxCapacityWithObject(outputCell, bridge.type, out outputObject, false); if (outputObject == null) { return(contents); } float capacity = Pressurized.GetMaxCapacity(bridge.GetComponent <Pressurized>()); //If the ConduitBridge is not supposed to support the amount of fluid currently in the contents, only make the bridge's intended max visible //Also immediately deal damage if the current contents are higher than 110% of the intended max (110% is set because at 100%, a system with no pressurized pipes would seem to randomly deal damage as if the contents // were barely over 100% if (contents.mass > capacity) { if (contents.mass > capacity * 1.1) { Integration.DoPressureDamage(bridge.gameObject); } float initial = contents.mass; float removed = contents.RemoveMass(initial - capacity); float ratio = removed / initial; contents.diseaseCount = (int)((float)contents.diseaseCount * ratio); } if (contents.mass > targetCapacity * 2 && UnityEngine.Random.Range(0f, 1f) < 0.33f) { Integration.DoPressureDamage(outputObject); } return(contents); }