private static bool UpdateStateCb(int cell, object data)
    {
        OilRefinery oilRefinery = data as OilRefinery;

        if (Grid.Element[cell].IsGas)
        {
            oilRefinery.cellCount   += 1f;
            oilRefinery.envPressure += Grid.Mass[cell];
        }
        return(true);
    }
Ejemplo n.º 2
0
        public static void Postfix(GameObject go)
        {
            OilRefinery oilRefinery = go.GetComponent <OilRefinery>();

            if (oilRefinery == null)
            {
                Debug.LogWarning("oilRefinery was null");
            }

            go.GetComponent <BuildingComplete>().isManuallyOperated = false;
            //go.GetComponent<OilRefinery>().enabled = false;
            UnityEngine.Object.DestroyImmediate(oilRefinery);

            go.AddOrGet <WaterPurifier>();
        }
Ejemplo n.º 3
0
        public static void Postfix(GameObject go)
        {
            if (!NoDupeHelper.CheckConfig(CustomizeBuildingsState.IDOilRefinery))
            {
                return;
            }

            OilRefinery oilRefinery = go.GetComponent <OilRefinery>();

            if (oilRefinery == null)
            {
                Debug.LogWarning("oilRefinery was null");
            }

            go.GetComponent <BuildingComplete>().isManuallyOperated = false;
            //go.GetComponent<OilRefinery>().enabled = false;
            UnityEngine.Object.DestroyImmediate(oilRefinery);

            go.AddOrGet <WaterPurifier>();
        }
Ejemplo n.º 4
0
    public override void ConfigureBuildingTemplate(GameObject go, Tag prefab_tag)
    {
        go.GetComponent <KPrefabID>().AddTag(RoomConstraints.ConstraintTags.IndustrialMachinery, false);
        go.AddOrGet <BuildingComplete>().isManuallyOperated = true;
        OilRefinery oilRefinery = go.AddOrGet <OilRefinery>();

        oilRefinery.overpressureWarningMass = 4.5f;
        oilRefinery.overpressureMass        = 5f;
        ConduitConsumer conduitConsumer = go.AddOrGet <ConduitConsumer>();

        conduitConsumer.conduitType          = ConduitType.Liquid;
        conduitConsumer.consumptionRate      = 10f;
        conduitConsumer.capacityTag          = SimHashes.CrudeOil.CreateTag();
        conduitConsumer.wrongElementResult   = ConduitConsumer.WrongElementResult.Dump;
        conduitConsumer.capacityKG           = 100f;
        conduitConsumer.forceAlwaysSatisfied = true;
        ConduitDispenser conduitDispenser = go.AddOrGet <ConduitDispenser>();

        conduitDispenser.conduitType         = ConduitType.Liquid;
        conduitDispenser.invertElementFilter = true;
        conduitDispenser.elementFilter       = new SimHashes[1]
        {
            SimHashes.CrudeOil
        };
        Storage storage = go.AddOrGet <Storage>();

        storage.showInUI = true;
        ElementConverter elementConverter = go.AddOrGet <ElementConverter>();

        elementConverter.consumedElements = new ElementConverter.ConsumedElement[1]
        {
            new ElementConverter.ConsumedElement(SimHashes.CrudeOil.CreateTag(), 10f)
        };
        elementConverter.outputElements = new ElementConverter.OutputElement[2]
        {
            new ElementConverter.OutputElement(5f, SimHashes.Petroleum, 348.15f, false, true, 0f, 1f, 1f, byte.MaxValue, 0),
            new ElementConverter.OutputElement(0.09f, SimHashes.Methane, 348.15f, false, false, 0f, 3f, 1f, byte.MaxValue, 0)
        };
        Prioritizable.AddRef(go);
    }
Ejemplo n.º 5
0
 public static void Postfix(OilRefinery __instance)
 {
     TryAddOwnable(__instance.gameObject);
 }
Ejemplo n.º 6
0
        public Task <List <OilRefinery> > ParseOilRefineries(string input, CancellationToken cancellationToken)
        {
            string[]           lines      = input.Split('\n');
            List <OilRefinery> refineries = new List <OilRefinery>();
            Regex refineryRegex           = new Regex("^(.+?),?\\s+(\\d[^\\s]+)", RegexOptions.Compiled);
            Regex commaDecimal            = new Regex(",\\d{2}\\s", RegexOptions.Compiled);
            Regex hasText = new Regex("\\w", RegexOptions.Compiled);

            string country   = "";
            string region    = "";
            string continent = "";

            foreach (string line in lines)
            {
                if (line.StartsWith("="))
                {
                    //location
                    int start = line.IndexOf(" ") + 1;
                    int end   = line.IndexOf("=", start) - 1;
                    if (start == 3)
                    {
                        continent = line.Substring(start, end - start);
                        country   = "";
                        region    = "";
                    }
                    else if (start == 4)
                    {
                        country = line.Substring(start, end - start);
                        region  = "";
                    }
                    else
                    {
                        region = line.Substring(start, end - start);
                    }
                }
                else if (country != "")
                {
                    OilRefinery refinery = new OilRefinery();
                    if (refineryRegex.IsMatch(line))
                    {
                        Match m = refineryRegex.Match(line);
                        foreach (Group g in m.Groups)
                        {
                            foreach (Capture c in g.Captures)
                            {
                                Console.WriteLine(c.Value);
                            }
                        }
                        refinery.Id = m.Groups[1].Captures[0].Value;
                        double capacity      = 0;
                        string capacityMatch = m.Groups[2].Captures[0].Value;
                        if (commaDecimal.IsMatch(capacityMatch))
                        {
                            capacityMatch = capacityMatch.Replace(',', '.');
                        }
                        double.TryParse(capacityMatch.Replace(",", ""), out capacity);
                        if (line.Contains("tonne/year") || line.Contains("MMTPA"))
                        {
                            capacity = capacity * 23150.68; // Convert from millions of tonne/year to bbl/d
                        }
                        refinery.Capacity = capacity;
                    }
                    else if (hasText.IsMatch(line))
                    {
                        // Assume a refinery without capacity
                        refinery.Id       = line;
                        refinery.Capacity = 0; //Default to 0 for refineries without defined capacities
                    }
                    if (refinery.Id != null)
                    {
                        refinery.Location = string.Join(", ", new string[] { region, country, continent }.SkipWhile(x => x.Length == 0));
                        refineries.Add(refinery);
                    }
                }
            }

            return(Task.FromResult(refineries));
        }