public void Render(int layer)
 {
     for (int i = 0; i < elementChunks.Count; i++)
     {
         ElementChunk elementChunk = elementChunks[i];
         elementChunk.Render(layer, ElementLoader.FindElementByHash(elementChunk.element).substance.idx);
     }
 }
        private ElementChunk GetElementChunk(SimHashes elementID, Dictionary <SimHashes, Materials> materials)
        {
            ElementChunk elementChunk = null;

            for (int i = 0; i < elementChunks.Count; i++)
            {
                if (elementChunks[i].element == elementID)
                {
                    elementChunk = elementChunks[i];
                    break;
                }
            }
            if (elementChunk == null)
            {
                elementChunk = new ElementChunk(elementID, materials);
                elementChunks.Add(elementChunk);
            }
            return(elementChunk);
        }
示例#3
0
    public static bool CanEntomb(Pickupable pickupable)
    {
        if ((Object)pickupable == (Object)null)
        {
            return(false);
        }
        if ((Object)pickupable.storage != (Object)null)
        {
            return(false);
        }
        int num = Grid.PosToCell(pickupable);

        if (!Grid.IsValidCell(num))
        {
            return(false);
        }
        if (!Grid.Solid[num])
        {
            return(false);
        }
        if ((Object)Grid.Objects[num, 9] != (Object)null)
        {
            return(false);
        }
        PrimaryElement component = pickupable.GetComponent <PrimaryElement>();

        if (component.Element.IsSolid)
        {
            ElementChunk component2 = pickupable.GetComponent <ElementChunk>();
            if ((Object)component2 != (Object)null)
            {
                return(true);
            }
        }
        return(false);
    }
    private void RefreshDetails()
    {
        detailsPanel.SetActive(true);
        detailsPanel.GetComponent <CollapsibleDetailContentPanel>().HeaderLabel.text = UI.DETAILTABS.DETAILS.GROUPNAME_DETAILS;
        PrimaryElement      component  = selectedTarget.GetComponent <PrimaryElement>();
        CellSelectionObject component2 = selectedTarget.GetComponent <CellSelectionObject>();
        float   mass;
        float   temperature;
        Element element;
        byte    diseaseIdx;
        int     diseaseCount;

        if ((Object)component != (Object)null)
        {
            mass         = component.Mass;
            temperature  = component.Temperature;
            element      = component.Element;
            diseaseIdx   = component.DiseaseIdx;
            diseaseCount = component.DiseaseCount;
        }
        else
        {
            if (!((Object)component2 != (Object)null))
            {
                return;
            }
            mass         = component2.Mass;
            temperature  = component2.temperature;
            element      = component2.element;
            diseaseIdx   = component2.diseaseIdx;
            diseaseCount = component2.diseaseCount;
        }
        bool             flag = element.id == SimHashes.Vacuum || element.id == SimHashes.Void;
        float            specificHeatCapacity = element.specificHeatCapacity;
        float            highTemp             = element.highTemp;
        float            lowTemp    = element.lowTemp;
        BuildingComplete component3 = selectedTarget.GetComponent <BuildingComplete>();
        float            num        = (!((Object)component3 != (Object)null)) ? (-1f) : component3.creationTime;
        LogicPorts       component4 = selectedTarget.GetComponent <LogicPorts>();
        EnergyConsumer   component5 = selectedTarget.GetComponent <EnergyConsumer>();
        Operational      component6 = selectedTarget.GetComponent <Operational>();
        Battery          component7 = selectedTarget.GetComponent <Battery>();
        float            num2;
        float            num3;
        float            num4;

        if ((Object)component6 != (Object)null && ((Object)component4 != (Object)null || (Object)component5 != (Object)null || (Object)component7 != (Object)null))
        {
            num2 = component6.GetUptimeForTimeSpan(10f);
            num3 = component6.GetUptimeForTimeSpan(600f);
            num4 = component6.GetUptimeForTimeSpan(6000f);
        }
        else
        {
            num2 = -1f;
            num3 = -1f;
            num4 = -1f;
        }
        drawer.NewLabel(drawer.Format(UI.ELEMENTAL.PRIMARYELEMENT.NAME, element.name)).Tooltip(drawer.Format(UI.ELEMENTAL.PRIMARYELEMENT.TOOLTIP, element.name)).NewLabel(drawer.Format(UI.ELEMENTAL.MASS.NAME, GameUtil.GetFormattedMass(mass, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")))
        .Tooltip(drawer.Format(UI.ELEMENTAL.MASS.TOOLTIP, GameUtil.GetFormattedMass(mass, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}")));
        if (num > 0f)
        {
            drawer.NewLabel(drawer.Format(UI.ELEMENTAL.AGE.NAME, Util.FormatTwoDecimalPlace((GameClock.Instance.GetTime() - num) / 600f))).Tooltip(drawer.Format(UI.ELEMENTAL.AGE.TOOLTIP, Util.FormatTwoDecimalPlace((GameClock.Instance.GetTime() - num) / 600f)));
        }
        else
        {
            drawer.NewLabel(drawer.Format(UI.ELEMENTAL.AGE.NAME, UI.ELEMENTAL.AGE.UNKNOWN)).Tooltip(UI.ELEMENTAL.AGE.UNKNOWN_TOOLTIP);
        }
        if (num2 >= 0f)
        {
            string text = UI.ELEMENTAL.UPTIME.NAME;
            text = text.Replace("{0}", GameUtil.GetFormattedTime(10f));
            text = text.Replace("{1}", GameUtil.GetFormattedTime(600f));
            text = text.Replace("{2}", GameUtil.GetFormattedTime(6000f));
            text = text.Replace("{3}", GameUtil.GetFormattedPercent(num2 * 100f, GameUtil.TimeSlice.None));
            text = text.Replace("{4}", GameUtil.GetFormattedPercent(num3 * 100f, GameUtil.TimeSlice.None));
            text = text.Replace("{5}", GameUtil.GetFormattedPercent(num4 * 100f, GameUtil.TimeSlice.None));
            drawer.NewLabel(text);
        }
        if (!flag)
        {
            bool     flag2      = false;
            float    num5       = element.thermalConductivity;
            Building component8 = selectedTarget.GetComponent <Building>();
            if ((Object)component8 != (Object)null)
            {
                num5 *= component8.Def.ThermalConductivity;
                flag2 = (component8.Def.ThermalConductivity < 1f);
            }
            string temperatureUnitSuffix = GameUtil.GetTemperatureUnitSuffix();
            float  shc   = specificHeatCapacity * 1f;
            string text2 = string.Format(UI.ELEMENTAL.SHC.NAME, GameUtil.GetDisplaySHC(shc).ToString("0.000"));
            string text3 = UI.ELEMENTAL.SHC.TOOLTIP;
            text3 = text3.Replace("{SPECIFIC_HEAT_CAPACITY}", text2 + GameUtil.GetSHCSuffix());
            text3 = text3.Replace("{TEMPERATURE_UNIT}", temperatureUnitSuffix);
            string text4 = string.Format(UI.ELEMENTAL.THERMALCONDUCTIVITY.NAME, GameUtil.GetDisplayThermalConductivity(num5).ToString("0.000"));
            string text5 = UI.ELEMENTAL.THERMALCONDUCTIVITY.TOOLTIP;
            text5 = text5.Replace("{THERMAL_CONDUCTIVITY}", text4 + GameUtil.GetThermalConductivitySuffix());
            text5 = text5.Replace("{TEMPERATURE_UNIT}", temperatureUnitSuffix);
            drawer.NewLabel(drawer.Format(UI.ELEMENTAL.TEMPERATURE.NAME, GameUtil.GetFormattedTemperature(temperature, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))).Tooltip(drawer.Format(UI.ELEMENTAL.TEMPERATURE.TOOLTIP, GameUtil.GetFormattedTemperature(temperature, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))).NewLabel(drawer.Format(UI.ELEMENTAL.DISEASE.NAME, GameUtil.GetFormattedDisease(diseaseIdx, diseaseCount, false)))
            .Tooltip(drawer.Format(UI.ELEMENTAL.DISEASE.TOOLTIP, GameUtil.GetFormattedDisease(diseaseIdx, diseaseCount, true)))
            .NewLabel(text2)
            .Tooltip(text3)
            .NewLabel(text4)
            .Tooltip(text5);
            if (flag2)
            {
                drawer.NewLabel(UI.GAMEOBJECTEFFECTS.INSULATED.NAME).Tooltip(UI.GAMEOBJECTEFFECTS.INSULATED.TOOLTIP);
            }
        }
        if (element.IsSolid)
        {
            drawer.NewLabel(drawer.Format(UI.ELEMENTAL.MELTINGPOINT.NAME, GameUtil.GetFormattedTemperature(highTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))).Tooltip(drawer.Format(UI.ELEMENTAL.MELTINGPOINT.TOOLTIP, GameUtil.GetFormattedTemperature(highTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)));
            ElementChunk component9 = selectedTarget.GetComponent <ElementChunk>();
            if ((Object)component9 != (Object)null)
            {
                AttributeModifier attributeModifier = component.Element.attributeModifiers.Find((AttributeModifier m) => m.AttributeId == Db.Get().BuildingAttributes.OverheatTemperature.Id);
                if (attributeModifier != null)
                {
                    drawer.NewLabel(drawer.Format(UI.ELEMENTAL.OVERHEATPOINT.NAME, attributeModifier.GetFormattedString(selectedTarget.gameObject))).Tooltip(drawer.Format(UI.ELEMENTAL.OVERHEATPOINT.TOOLTIP, attributeModifier.GetFormattedString(selectedTarget.gameObject)));
                }
            }
        }
        else if (element.IsLiquid)
        {
            drawer.NewLabel(drawer.Format(UI.ELEMENTAL.FREEZEPOINT.NAME, GameUtil.GetFormattedTemperature(lowTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))).Tooltip(drawer.Format(UI.ELEMENTAL.FREEZEPOINT.TOOLTIP, GameUtil.GetFormattedTemperature(lowTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))).NewLabel(drawer.Format(UI.ELEMENTAL.VAPOURIZATIONPOINT.NAME, GameUtil.GetFormattedTemperature(highTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)))
            .Tooltip(drawer.Format(UI.ELEMENTAL.VAPOURIZATIONPOINT.TOOLTIP, GameUtil.GetFormattedTemperature(highTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)));
        }
        else if (!flag)
        {
            drawer.NewLabel(drawer.Format(UI.ELEMENTAL.DEWPOINT.NAME, GameUtil.GetFormattedTemperature(lowTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false))).Tooltip(drawer.Format(UI.ELEMENTAL.DEWPOINT.TOOLTIP, GameUtil.GetFormattedTemperature(lowTemp, GameUtil.TimeSlice.None, GameUtil.TemperatureInterpretation.Absolute, true, false)));
        }
        Attributes attributes = selectedTarget.GetAttributes();

        if (attributes != null)
        {
            for (int i = 0; i < attributes.Count; i++)
            {
                AttributeInstance attributeInstance = attributes.AttributeTable[i];
                if (attributeInstance.Attribute.ShowInUI == Attribute.Display.Details || attributeInstance.Attribute.ShowInUI == Attribute.Display.Expectation)
                {
                    drawer.NewLabel(attributeInstance.modifier.Name + ": " + attributeInstance.GetFormattedValue()).Tooltip(attributeInstance.GetAttributeValueTooltip());
                }
            }
        }
        List <Descriptor> detailDescriptors = GameUtil.GetDetailDescriptors(GameUtil.GetAllDescriptors(selectedTarget, false));

        for (int j = 0; j < detailDescriptors.Count; j++)
        {
            Descriptor descriptor = detailDescriptors[j];
            drawer.NewLabel(descriptor.text).Tooltip(descriptor.tooltipText);
        }
    }
 private void GetEntities <T>(IEnumerable <T> component_collection, int rootX, int rootY, ref List <Prefab> _primaryElementOres, ref List <Prefab> _otherEntities, ref HashSet <GameObject> _excludeEntities)
 {
     foreach (T item2 in component_collection)
     {
         if (!_excludeEntities.Contains((item2 as KMonoBehaviour).gameObject) && (item2 as KMonoBehaviour).gameObject.activeSelf)
         {
             int num = Grid.PosToCell(item2 as KMonoBehaviour);
             if (SelectedCells.Contains(num) && !(bool)(item2 as KMonoBehaviour).gameObject.GetComponent <MinionBrain>())
             {
                 Grid.CellToXY(num, out int x, out int y);
                 x -= rootX;
                 y -= rootY;
                 SimHashes      simHashes = SimHashes.Void;
                 float          num2      = 280f;
                 float          num3      = 1f;
                 string         text      = null;
                 int            num4      = 0;
                 PrimaryElement component = (item2 as KMonoBehaviour).gameObject.GetComponent <PrimaryElement>();
                 if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                 {
                     simHashes = component.ElementID;
                     num3      = component.Units;
                     num2      = component.Temperature;
                     text      = ((component.DiseaseIdx == 255) ? null : ((ResourceSet <Disease>)Db.Get().Diseases)[(int)component.DiseaseIdx].Id);
                     num4      = component.DiseaseCount;
                 }
                 List <Prefab.template_amount_value> list = new List <Prefab.template_amount_value>();
                 if ((item2 as KMonoBehaviour).gameObject.GetAmounts() != null)
                 {
                     foreach (AmountInstance item3 in (Modifications <Amount, AmountInstance>)(item2 as KMonoBehaviour).gameObject.GetAmounts())
                     {
                         list.Add(new Prefab.template_amount_value(item3.amount.Id, item3.value));
                     }
                 }
                 ElementChunk component2 = (item2 as KMonoBehaviour).gameObject.GetComponent <ElementChunk>();
                 if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                 {
                     string      name          = (item2 as KMonoBehaviour).PrefabID().Name;
                     Prefab.Type type          = Prefab.Type.Ore;
                     int         loc_x         = x;
                     int         loc_y         = y;
                     SimHashes   element       = simHashes;
                     float       temperature   = num2;
                     float       units         = num3;
                     string      disease       = text;
                     int         disease_count = num4;
                     Prefab.template_amount_value[] amount_values = list.ToArray();
                     Prefab item = new Prefab(name, type, loc_x, loc_y, element, temperature, units, disease, disease_count, Orientation.Neutral, amount_values, null, 0);
                     _primaryElementOres.Add(item);
                     _excludeEntities.Add((item2 as KMonoBehaviour).gameObject);
                 }
                 else
                 {
                     string      disease       = (item2 as KMonoBehaviour).PrefabID().Name;
                     Prefab.Type type          = Prefab.Type.Other;
                     int         disease_count = x;
                     int         loc_y         = y;
                     SimHashes   element       = simHashes;
                     float       units         = num2;
                     float       temperature   = num3;
                     string      name          = text;
                     int         loc_x         = num4;
                     Prefab.template_amount_value[] amount_values = list.ToArray();
                     Prefab item = new Prefab(disease, type, disease_count, loc_y, element, units, temperature, name, loc_x, Orientation.Neutral, amount_values, null, 0);
                     _otherEntities.Add(item);
                     _excludeEntities.Add((item2 as KMonoBehaviour).gameObject);
                 }
             }
         }
     }
 }
    private TemplateContainer GetSelectionAsAsset()
    {
        List <Cell>          list  = new List <Cell>();
        List <Prefab>        list2 = new List <Prefab>();
        List <Prefab>        list3 = new List <Prefab>();
        List <Prefab>        _primaryElementOres = new List <Prefab>();
        List <Prefab>        _otherEntities      = new List <Prefab>();
        HashSet <GameObject> _excludeEntities    = new HashSet <GameObject>();
        float num  = 0f;
        float num2 = 0f;

        foreach (int selectedCell in SelectedCells)
        {
            float    num3     = num;
            Vector2I vector2I = Grid.CellToXY(selectedCell);
            num = num3 + (float)vector2I.x;
            float    num4      = num2;
            Vector2I vector2I2 = Grid.CellToXY(selectedCell);
            num2 = num4 + (float)vector2I2.y;
        }
        float x    = num / (float)SelectedCells.Count;
        float y    = num2 /= (float)SelectedCells.Count;
        int   cell = Grid.PosToCell(new Vector3(x, y, 0f));

        Grid.CellToXY(cell, out int x2, out int y2);
        for (int i = 0; i < SelectedCells.Count; i++)
        {
            int i2 = SelectedCells[i];
            Grid.CellToXY(SelectedCells[i], out int x3, out int y3);
            Element element     = ElementLoader.elements[Grid.ElementIdx[i2]];
            string  diseaseName = (Grid.DiseaseIdx[i2] == 255) ? null : Db.Get().Diseases[Grid.DiseaseIdx[i2]].Id;
            list.Add(new Cell(x3 - x2, y3 - y2, element.id, Grid.Temperature[i2], Grid.Mass[i2], diseaseName, Grid.DiseaseCount[i2], Grid.PreventFogOfWarReveal[SelectedCells[i]]));
        }
        for (int j = 0; j < Components.BuildingCompletes.Count; j++)
        {
            BuildingComplete buildingComplete = Components.BuildingCompletes[j];
            if (!_excludeEntities.Contains(buildingComplete.gameObject))
            {
                Grid.CellToXY(Grid.PosToCell(buildingComplete), out int x4, out int y4);
                if (SaveAllBuildings || SelectedCells.Contains(Grid.PosToCell(buildingComplete)))
                {
                    int[]  placementCells = buildingComplete.PlacementCells;
                    string diseaseName2;
                    foreach (int num5 in placementCells)
                    {
                        Grid.CellToXY(num5, out int x5, out int y5);
                        diseaseName2 = ((Grid.DiseaseIdx[num5] == 255) ? null : Db.Get().Diseases[Grid.DiseaseIdx[num5]].Id);
                        list.Add(new Cell(x5 - x2, y5 - y2, Grid.Element[num5].id, Grid.Temperature[num5], Grid.Mass[num5], diseaseName2, Grid.DiseaseCount[num5], false));
                    }
                    Orientation rotation  = Orientation.Neutral;
                    Rotatable   component = buildingComplete.gameObject.GetComponent <Rotatable>();
                    if ((UnityEngine.Object)component != (UnityEngine.Object)null)
                    {
                        rotation = component.GetOrientation();
                    }
                    SimHashes element2 = SimHashes.Void;
                    float     value    = 280f;
                    diseaseName2 = null;
                    int            disease_count = 0;
                    PrimaryElement component2    = buildingComplete.GetComponent <PrimaryElement>();
                    if ((UnityEngine.Object)component2 != (UnityEngine.Object)null)
                    {
                        element2      = component2.ElementID;
                        value         = component2.Temperature;
                        diseaseName2  = ((component2.DiseaseIdx == 255) ? null : Db.Get().Diseases[component2.DiseaseIdx].Id);
                        disease_count = component2.DiseaseCount;
                    }
                    List <Prefab.template_amount_value> list4 = new List <Prefab.template_amount_value>();
                    List <Prefab.template_amount_value> list5 = new List <Prefab.template_amount_value>();
                    foreach (AmountInstance amount in buildingComplete.gameObject.GetAmounts())
                    {
                        list4.Add(new Prefab.template_amount_value(amount.amount.Id, amount.value));
                    }
                    float   num6       = 0f;
                    Battery component3 = buildingComplete.GetComponent <Battery>();
                    if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
                    {
                        num6 = component3.JoulesAvailable;
                        list5.Add(new Prefab.template_amount_value("joulesAvailable", num6));
                    }
                    float      num7       = 0f;
                    Unsealable component4 = buildingComplete.GetComponent <Unsealable>();
                    if ((UnityEngine.Object)component4 != (UnityEngine.Object)null)
                    {
                        num7 = (float)(component4.facingRight ? 1 : 0);
                        list5.Add(new Prefab.template_amount_value("sealedDoorDirection", num7));
                    }
                    float       num8       = 0f;
                    LogicSwitch component5 = buildingComplete.GetComponent <LogicSwitch>();
                    if ((UnityEngine.Object)component5 != (UnityEngine.Object)null)
                    {
                        num8 = (float)(component5.IsSwitchedOn ? 1 : 0);
                        list5.Add(new Prefab.template_amount_value("switchSetting", num8));
                    }
                    x4   -= x2;
                    y4   -= y2;
                    value = Mathf.Clamp(value, 1f, 99999f);
                    Prefab  prefab     = new Prefab(buildingComplete.PrefabID().Name, Prefab.Type.Building, x4, y4, element2, value, 0f, diseaseName2, disease_count, rotation, list4.ToArray(), list5.ToArray(), 0);
                    Storage component6 = buildingComplete.gameObject.GetComponent <Storage>();
                    if ((UnityEngine.Object)component6 != (UnityEngine.Object)null)
                    {
                        foreach (GameObject item2 in component6.items)
                        {
                            float          units          = 0f;
                            SimHashes      element3       = SimHashes.Vacuum;
                            float          temp           = 280f;
                            string         disease        = null;
                            int            disease_count2 = 0;
                            bool           isOre          = false;
                            PrimaryElement component7     = item2.GetComponent <PrimaryElement>();
                            if ((UnityEngine.Object)component7 != (UnityEngine.Object)null)
                            {
                                units          = component7.Units;
                                element3       = component7.ElementID;
                                temp           = component7.Temperature;
                                disease        = ((component7.DiseaseIdx == 255) ? null : Db.Get().Diseases[component7.DiseaseIdx].Id);
                                disease_count2 = component7.DiseaseCount;
                            }
                            float             rotAmount = 0f;
                            Rottable.Instance sMI       = item2.gameObject.GetSMI <Rottable.Instance>();
                            if (sMI != null)
                            {
                                rotAmount = sMI.RotValue;
                            }
                            ElementChunk component8 = item2.GetComponent <ElementChunk>();
                            if ((UnityEngine.Object)component8 != (UnityEngine.Object)null)
                            {
                                isOre = true;
                            }
                            StorageItem storageItem = new StorageItem(item2.PrefabID().Name, units, temp, element3, disease, disease_count2, isOre);
                            if (sMI != null)
                            {
                                storageItem.rottable.rotAmount = rotAmount;
                            }
                            prefab.AssignStorage(storageItem);
                            _excludeEntities.Add(item2);
                        }
                    }
                    list2.Add(prefab);
                    _excludeEntities.Add(buildingComplete.gameObject);
                }
            }
        }
        for (int l = 0; l < list2.Count; l++)
        {
            Prefab prefab2 = list2[l];
            int    x6      = prefab2.location_x + x2;
            int    y6      = prefab2.location_y + y2;
            int    cell2   = Grid.XYToCell(x6, y6);
            switch (prefab2.id)
            {
            default:
                prefab2.connections = 0;
                break;

            case "Wire":
            case "InsulatedWire":
            case "HighWattageWire":
                prefab2.connections = (int)Game.Instance.electricalConduitSystem.GetConnections(cell2, true);
                break;

            case "GasConduit":
            case "InsulatedGasConduit":
                prefab2.connections = (int)Game.Instance.gasConduitSystem.GetConnections(cell2, true);
                break;

            case "LiquidConduit":
            case "InsulatedLiquidConduit":
                prefab2.connections = (int)Game.Instance.liquidConduitSystem.GetConnections(cell2, true);
                break;

            case "LogicWire":
                prefab2.connections = (int)Game.Instance.logicCircuitSystem.GetConnections(cell2, true);
                break;
            }
        }
        for (int m = 0; m < Components.Pickupables.Count; m++)
        {
            if (Components.Pickupables[m].gameObject.activeSelf)
            {
                Pickupable pickupable = Components.Pickupables[m];
                if (!_excludeEntities.Contains(pickupable.gameObject))
                {
                    int num9 = Grid.PosToCell(pickupable);
                    if ((SaveAllPickups || SelectedCells.Contains(num9)) && !(bool)Components.Pickupables[m].gameObject.GetComponent <MinionBrain>())
                    {
                        Grid.CellToXY(num9, out int x7, out int y7);
                        x7 -= x2;
                        y7 -= y2;
                        SimHashes         element4       = SimHashes.Void;
                        float             temperature    = 280f;
                        float             units2         = 1f;
                        string            disease2       = null;
                        int               disease_count3 = 0;
                        float             rotAmount2     = 0f;
                        Rottable.Instance sMI2           = pickupable.gameObject.GetSMI <Rottable.Instance>();
                        if (sMI2 != null)
                        {
                            rotAmount2 = sMI2.RotValue;
                        }
                        PrimaryElement component9 = pickupable.gameObject.GetComponent <PrimaryElement>();
                        if ((UnityEngine.Object)component9 != (UnityEngine.Object)null)
                        {
                            element4       = component9.ElementID;
                            units2         = component9.Units;
                            temperature    = component9.Temperature;
                            disease2       = ((component9.DiseaseIdx == 255) ? null : Db.Get().Diseases[component9.DiseaseIdx].Id);
                            disease_count3 = component9.DiseaseCount;
                        }
                        ElementChunk component10 = pickupable.gameObject.GetComponent <ElementChunk>();
                        if ((UnityEngine.Object)component10 != (UnityEngine.Object)null)
                        {
                            Prefab item = new Prefab(pickupable.PrefabID().Name, Prefab.Type.Ore, x7, y7, element4, temperature, units2, disease2, disease_count3, Orientation.Neutral, null, null, 0);
                            _primaryElementOres.Add(item);
                        }
                        else
                        {
                            Prefab item = new Prefab(pickupable.PrefabID().Name, Prefab.Type.Pickupable, x7, y7, element4, temperature, units2, disease2, disease_count3, Orientation.Neutral, null, null, 0);
                            item.rottable           = new TemplateClasses.Rottable();
                            item.rottable.rotAmount = rotAmount2;
                            list3.Add(item);
                        }
                        _excludeEntities.Add(pickupable.gameObject);
                    }
                }
            }
        }
        GetEntities(Components.Crops.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities(Components.Health.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities(Components.Harvestables.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities(Components.Edibles.Items, x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities <Geyser>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities <OccupyArea>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        GetEntities <FogOfWarMask>(x2, y2, ref _primaryElementOres, ref _otherEntities, ref _excludeEntities);
        TemplateContainer templateContainer = new TemplateContainer();

        templateContainer.Init(list, list2, list3, _primaryElementOres, _otherEntities);
        return(templateContainer);
    }
        public void Rebuild(GroundMasks.BiomeMaskData[] biomeMasks, Dictionary <SimHashes, Materials> materials)
        {
            foreach (ElementChunk elementChunk3 in elementChunks)
            {
                elementChunk3.Clear();
            }
            Vector2I vector2I  = new Vector2I(chunkX * 16, chunkY * 16);
            Vector2I vector2I2 = new Vector2I(Math.Min(Grid.WidthInCells, (chunkX + 1) * 16), Math.Min(Grid.HeightInCells, (chunkY + 1) * 16));

            for (int i = vector2I.y; i < vector2I2.y; i++)
            {
                int num  = Math.Max(0, i - 1);
                int num2 = i;
                for (int j = vector2I.x; j < vector2I2.x; j++)
                {
                    int num3 = Math.Max(0, j - 1);
                    int num4 = j;
                    int num5 = num * Grid.WidthInCells + num3;
                    int num6 = num * Grid.WidthInCells + num4;
                    int num7 = num2 * Grid.WidthInCells + num3;
                    int num8 = num2 * Grid.WidthInCells + num4;
                    elements[0]       = Grid.Element[num5];
                    elements[1]       = Grid.Element[num6];
                    elements[2]       = Grid.Element[num7];
                    elements[3]       = Grid.Element[num8];
                    substances[0]     = ((!Grid.RenderedByWorld[num5] || !elements[0].IsSolid) ? (-1) : elements[0].substance.idx);
                    substances[1]     = ((!Grid.RenderedByWorld[num6] || !elements[1].IsSolid) ? (-1) : elements[1].substance.idx);
                    substances[2]     = ((!Grid.RenderedByWorld[num7] || !elements[2].IsSolid) ? (-1) : elements[2].substance.idx);
                    substances[3]     = ((!Grid.RenderedByWorld[num8] || !elements[3].IsSolid) ? (-1) : elements[3].substance.idx);
                    uniqueElements[0] = elements[0];
                    InsertSorted(elements[1], uniqueElements, 1);
                    InsertSorted(elements[2], uniqueElements, 2);
                    InsertSorted(elements[3], uniqueElements, 3);
                    int num9     = -1;
                    int cell     = i * Grid.WidthInCells + j;
                    int biomeIdx = GetBiomeIdx(cell);
                    GroundMasks.BiomeMaskData biomeMaskData = biomeMasks[biomeIdx];
                    for (int k = 0; k < uniqueElements.Length; k++)
                    {
                        Element element = uniqueElements[k];
                        if (element.IsSolid)
                        {
                            int idx = element.substance.idx;
                            if (idx != num9)
                            {
                                num9 = idx;
                                int num10 = (((substances[2] >= idx) ? 1 : 0) << 3) | (((substances[3] >= idx) ? 1 : 0) << 2) | (((substances[0] >= idx) ? 1 : 0) << 1) | (((substances[1] >= idx) ? 1 : 0) << 0);
                                if (num10 > 0)
                                {
                                    GroundMasks.UVData[] variationUVs = biomeMaskData.tiles[num10].variationUVs;
                                    float staticRandom              = GetStaticRandom(j, i);
                                    int   num11                     = Mathf.Min(variationUVs.Length - 1, (int)((float)variationUVs.Length * staticRandom));
                                    GroundMasks.UVData uvs          = variationUVs[num11 % variationUVs.Length];
                                    ElementChunk       elementChunk = GetElementChunk(element.id, materials);
                                    if (num10 == 15)
                                    {
                                        elementChunk.AddOpaqueQuad(j, i, uvs);
                                    }
                                    else
                                    {
                                        elementChunk.AddAlphaQuad(j, i, uvs);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            foreach (ElementChunk elementChunk4 in elementChunks)
            {
                elementChunk4.Build();
            }
            for (int num12 = elementChunks.Count - 1; num12 >= 0; num12--)
            {
                ElementChunk elementChunk2 = elementChunks[num12];
                if (elementChunk2.tileCount == 0)
                {
                    int index = elementChunks.Count - 1;
                    elementChunks[num12] = elementChunks[index];
                    elementChunks.RemoveAt(index);
                }
            }
        }