public static float GetMaxCapacityWithObject(int cell, ConduitType type, out GameObject obj, bool isBridge = false) { if (type != ConduitType.Gas && type != ConduitType.Liquid) { throw new System.ArgumentException($"[Pressurized] Invalid Conduit Type given to IntegrationHelper.GetMaxCapacityAt(): {type.ToString()} Type must be ConduitType.Gas or ConduitType.Liquid.", "type"); } ConduitFlow manager = Conduit.GetFlowManager(type); Pressurized pressurized = GetPressurizedAt(cell, type, isBridge); if (pressurized == null) { obj = null; } else { obj = pressurized.gameObject; } if (Pressurized.IsDefault(pressurized)) { return(manager.MaxMass()); } else { return(pressurized.Info.IncreaseMultiplier * manager.MaxMass()); } }
private static ConduitFlow.ConduitContents SetMaxFlow(ConduitFlow.ConduitContents contents, ConduitBridge bridge, ConduitFlow manager) { if (bridge.GetComponent <BuildingHP>().HitPoints == 0) { //does not actually remove mass from the conduit, just changes what the bridge sees contents.RemoveMass(contents.mass); return(contents); } int outputCell = (int)bridgeOutputCell.GetValue(bridge); GameObject outputObject = Grid.Objects[outputCell, Integration.layers[(int)bridge.type]]; if (outputObject == null) { return(contents); } Pressurized pressure = bridge.GetComponent <Pressurized>(); float capacity; if (!Pressurized.IsDefault(pressure)) { capacity = pressure.Info.Capacity; } else { capacity = (float)maxMass.GetValue(manager); } //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 the intended max. if (capacity < contents.mass) { float initial = contents.mass; float removed = contents.RemoveMass(initial - capacity); float ratio = removed / initial; contents.diseaseCount = (int)((float)contents.diseaseCount * ratio); BuildingHP.DamageSourceInfo damage = Integration.GetPressureDamage(); bridge.Trigger((int)GameHashes.DoBuildingDamage, damage); } { float targetCapacity; Pressurized outPressure = outputObject.GetComponent <Pressurized>(); if (!Pressurized.IsDefault(outPressure)) { targetCapacity = outPressure.Info.Capacity; } else { targetCapacity = (float)maxMass.GetValue(manager); } if (contents.mass > targetCapacity * 2) { BuildingHP.DamageSourceInfo damage = Integration.GetPressureDamage(); outputObject.Trigger((int)GameHashes.DoBuildingDamage, damage); } } return(contents); }
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; } }
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; } }
public static float GetMaxCapacityAt(int cell, ConduitType type, bool isBridge = false) { if (type != ConduitType.Gas && type != ConduitType.Liquid) { throw new System.ArgumentException($"[Pressurized] Invalid Conduit Type given to IntegrationHelper.GetMaxCapacityAt(): {type.ToString()} Type must be ConduitType.Gas or ConduitType.Liquid.", "type"); } ConduitFlow manager = Conduit.GetFlowManager(type); return(Pressurized.GetMaxCapacity(GetPressurizedAt(cell, type, isBridge))); }
private static float IntegratePressurized(float standardMax, ConduitType conduitType, int cell) { Pressurized pressure = GetPressurizedAt(cell, conduitType); if (!Pressurized.IsDefault(pressure)) { return(pressure.Info.Capacity); } return(standardMax); }
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); } }
internal static void Postfix(KBatchedAnimController controller) { Pressurized pressure = controller.GetComponent <Pressurized>(); if (!Pressurized.IsDefault(pressure)) { controller.TintColour = pressure.Info.KAnimTint; } else { controller.GetComponent <Tintable>()?.SetTint(); } }
private static void IntegrateOverpressure(ConduitFlow.GridNode sender, float standardMax, ConduitType conduitType, int cell) { Pressurized pressure = GetPressurizedAt(cell, conduitType); float receiverMax = Pressurized.IsDefault(pressure) ? standardMax : pressure.Info.Capacity; float senderMass = sender.contents.mass; if (senderMass >= receiverMax * 2f) { GameObject receiver = pressure != null ? pressure.gameObject : Grid.Objects[cell, layers[(int)conduitType]]; BuildingHP.DamageSourceInfo damage = GetPressureDamage(); queueDamages.Add(new QueueDamage(damage, receiver)); } }
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); }
public static bool IsDefault(Pressurized pressure) { return(pressure == null || pressure.Info == null || pressure.Info.IsDefault || pressure.Info.Capacity <= 0f); }