Esempio n. 1
0
        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());
            }
        }
Esempio n. 2
0
            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);
            }
Esempio n. 3
0
            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;
                }
            }
Esempio n. 4
0
            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;
                }
            }
Esempio n. 5
0
        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)));
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
            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);
                }
            }
Esempio n. 8
0
            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();
                }
            }
Esempio n. 9
0
        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));
            }
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
 public static bool IsDefault(Pressurized pressure)
 {
     return(pressure == null || pressure.Info == null || pressure.Info.IsDefault || pressure.Info.Capacity <= 0f);
 }