public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        GeneratedBuildings.MakeBuildingAlwaysOperational(go);
        BuildingConfigManager.Instance.IgnoreDefaultKComponent(typeof(RequiresFoundation), prefab_tag);
        ConduitBridge conduitBridge = go.AddOrGet <ConduitBridge>();

        conduitBridge.type = ConduitType.Gas;
    }
Ejemplo n.º 2
0
 internal static void Postfix(ConduitBridge __instance)
 {
     __instance.gameObject.AddOrGet <Pressurized>();
 }
Ejemplo n.º 3
0
            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);
            }
Ejemplo n.º 4
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);
            }