Exemple #1
0
        private static void ApplyColorToBuilding(BuildingComplete building, Color color)
        {
            TreeFilterable      treeFilterable;
            Ownable             ownable;
            KAnimControllerBase kAnimBase;

            if ((ownable = building.GetComponent <Ownable>()) != null)
            {
                Traverse.Create(ownable).Field("ownedTint").SetValue(color);
                Traverse.Create(ownable).Method("UpdateTint").GetValue();
            }
            else if ((treeFilterable = building.GetComponent <TreeFilterable>()) != null)
            {
                FilteredStorage filteredStorage = ExtractFilteredStorage(treeFilterable);

                if (filteredStorage != null)
                {
                    filteredStorage.filterTint = color;
                    filteredStorage.FilterChanged();
                }
            }
            else if ((kAnimBase = building.GetComponent <KAnimControllerBase>()) != null)
            {
                kAnimBase.TintColour = color;
            }
            else
            {
                State.Common.Logger.LogOnce("Invalid building <{building}> and its not a registered tile.");
            }
        }
Exemple #2
0
                private static void ApplyColorToBuilding(BuildingComplete building)
                {
                    if (building.name.ToString().StartsWith("BigLiquidStorage") || building.name.ToString().StartsWith("BigGasReservoir"))
                    {
                        KAnimControllerBase kanim = building.GetComponent <KAnimControllerBase>();
                        if (kanim != null)
                        {
                            kanim.TintColour = defaultColor;
                            CaiLib.Logger.Logger.Log(string.Concat("Updating Object Color:", building.name.ToString()));
                        }
                    }

                    if (building.name.ToString().StartsWith("BigSolidStorage") || building.name.ToString().StartsWith("BigBeautifulStorage"))
                    {
                        TreeFilterable treeFilterable = building.GetComponent <TreeFilterable>();
                        if (treeFilterable != null)
                        {
                            Traverse traverse = Traverse.Create(treeFilterable);
                            if (building.name.ToString().StartsWith("BigSolidStorage"))
                            {
                                traverse.Field("filterTint").SetValue(defaultColor);
                            }
                            if (building.name.ToString().StartsWith("BigBeautifulStorage"))
                            {
                                traverse.Field("filterTint").SetValue(beautifulColor);
                            }
                            Tag[] array = traverse.Field <List <Tag> >("acceptedTags").Value.ToArray();
                            treeFilterable.OnFilterChanged(array);
                        }
                    }
                }
Exemple #3
0
            public static void Postfix(BuildingComplete __instance)
            {
                // Tweaks Material colors diamond tinting, otherwise it makes the diamond statues bubblegum pink
                if (__instance.name == GlassSculptureConfig.ID + "Complete")
                {
                    //if(Mod.compatibleMods["MaterialColor"].IsPresent)
                    ///{
                    var kAnimController = __instance.GetComponent <KBatchedAnimController>();
                    if (kAnimController == null)
                    {
                        return;
                    }

                    var primaryElement = __instance.GetComponent <PrimaryElement>();
                    if (primaryElement == null)
                    {
                        return;
                    }

                    var element = primaryElement.Element;

                    if (element.id == SimHashes.Diamond)
                    {
                        var color = new Color32(241, 172, 255, 255);
                        kAnimController.TintColour = color;
                    }
                    //}

                    // Need to refresh the component, or the rendering order will be wrong
                    // maybe there is a better way?
                    if (Mod.Settings.GlassSculpturesFabUnicorns)
                    {
                        Artable artable = __instance.GetComponent <Artable>();
                        if (artable != null)
                        {
                            if (artable.CurrentStage == unicornStageName)
                            {
                                var fab = __instance.GetComponent <Fabulousness>();
                                if (fab == null)
                                {
                                    fab = __instance.gameObject.AddComponent <Fabulousness>();
                                }

                                fab.ForceToFront();

/*                                else
 *                              {
 *                                  var fab = __instance.GetComponent<Fabulousness>();
 *                                  fab.Deactivate();
 *                                  fab.Activate();
 *                              }*/
                            }
                        }
                    }
                }

                return;
            }
Exemple #4
0
 public static void Postfix(BuildingComplete __instance)
 {
     if (__instance.name != null)
     {
         if (__instance.name == "LogicGateDiodeComplete" && __instance.GetComponent <KAnimControllerBase>() != null)
         {
             __instance.GetComponent <KAnimControllerBase>().TintColour = new Color(0.8f, 0.1f, 0.7f);
         }
     }
 }
Exemple #5
0
 public static void Postfix(BuildingComplete __instance)
 {
     if (__instance.name != null)
     {
         if (__instance.name == "HydrogenDiffuserComplete" && __instance.GetComponent <KAnimControllerBase>() != null)
         {
             __instance.GetComponent <KAnimControllerBase>().TintColour = new Color(0.9f, 0.5f, 0.6f);
         }
     }
 }
 public static void Postfix(BuildingComplete __instance)
 {
     if (string.Compare(__instance.name, (GasPressureValveConfig.ID + "Complete")) == 0)
     {
         __instance.GetComponent <KAnimControllerBase>().TintColour = GasPressureValveConfig.Color();
     }
     else if (string.Compare(__instance.name, (LiquidPressureValveConfig.ID + "Complete")) == 0)
     {
         __instance.GetComponent <KAnimControllerBase>().TintColour = LiquidPressureValveConfig.Color();
     }
 }
Exemple #7
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (__instance.name == "WallpaperComplete")
                {
                    var primaryElement = __instance.GetComponent <PrimaryElement>();
                    var kAnimBase      = __instance.GetComponent <KAnimControllerBase>();

                    if (primaryElement != null && kAnimBase != null)
                    {
                        var color = primaryElement.Element.substance.uiColour;

                        kAnimBase.TintColour = color;
                    }
                }
            }
Exemple #8
0
 public static void Postfix(BuildingComplete __instance)
 {
     if (string.Compare(__instance.name, (WaterPurifierDynamicConfig.ID + "Complete")) == 0)
     {
         __instance.GetComponent <KAnimControllerBase>().TintColour = WaterPurifierDynamicConfig.Color();
     }
 }
 private static void Postfix(ref BuildingComplete __instance)
 {
     if (string.Compare(__instance.name, "ShinseiWaterCoolerComplete") == 0)
     {
         __instance.GetComponent <KAnimControllerBase>().TintColour = ShinseiWaterCoolerConfig.Color();
         //__instance.gameObject.AddOrGet<>
     }
 }
 public static void Postfix(BuildingComplete __instance)
 {
     if (__instance.name == "GasSinkComplete")
     {
         var kAnimBase = __instance.GetComponent <KAnimControllerBase>();
         kAnimBase.TintColour = new Color32(255, 0, 0, 255);
     }
 }
Exemple #11
0
 public static void Postfix(BuildingComplete __instance)
 {
     if (__instance.name.Equals((TileTemperatureSensorConfig.ID + "Complete")))
     {
         var KAnim = __instance.GetComponent <KAnimControllerBase>();
         if (KAnim != null)
         {
             KAnim.TintColour = TileTemperatureSensorConfig.BuildingColor();
         }
     }
 }
Exemple #12
0
        private static void SetColor(BuildingComplete building)
        {
            var primaryElement = building.GetComponent <PrimaryElement>();
            var kAnimBase      = building.GetComponent <KAnimControllerBase>();

            if (primaryElement == null || kAnimBase == null)
            {
                return;
            }

            var element = primaryElement.Element;
            var color   = element.substance.uiColour;

            if (element.id == SimHashes.Granite)
            {
                color.a = byte.MaxValue;
            }

            kAnimBase.TintColour = color;
        }
Exemple #13
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (__instance.name == "WallpaperComplete")
                {
                    var primaryElement = __instance.GetComponent <PrimaryElement>();
                    var kAnimBase      = __instance.GetComponent <KAnimControllerBase>();

                    if (primaryElement != null && kAnimBase != null)
                    {
                        var element = primaryElement.Element;
                        var color   = element.substance.uiColour;

                        if (element.id == SimHashes.Granite)
                        {
                            color.a = byte.MaxValue;
                        }

                        kAnimBase.TintColour = color;
                    }
                }
            }
Exemple #14
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (string.Compare(__instance.name, (BoostedGasPump.ID + "Complete")) == 0)
                {
                    var kanim = __instance.GetComponent <KAnimControllerBase>();
                    if (kanim == null)
                    {
                        return;
                    }

                    kanim.TintColour = BoostedGasPump.ChangeColor();
                }
            }
Exemple #15
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (string.Compare(__instance.name, (EfficientSmartStorageBin.ID + "Complete")) == 0)
                {
                    var kanim = __instance.GetComponent <KAnimControllerBase>();
                    if (kanim == null)
                    {
                        return;
                    }

                    kanim.TintColour = EfficientSmartStorageBin.ChangeColor();
                }
            }
Exemple #16
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (string.Compare(__instance.name, (HighInflowLiquidReservoir.ID + "Complete")) == 0)
                {
                    var kanim = __instance.GetComponent <KAnimControllerBase>();
                    if (kanim == null)
                    {
                        return;
                    }

                    kanim.TintColour = HighInflowLiquidReservoir.ChangeColor();
                }
            }
Exemple #17
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (string.Compare(__instance.name, (MediumPowerTransformer.ID + "Complete")) == 0)
                {
                    var kanim = __instance.GetComponent <KAnimControllerBase>();
                    if (kanim == null)
                    {
                        return;
                    }

                    kanim.TintColour = MediumPowerTransformer.ChangeColor();
                }
            }
Exemple #18
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (string.Compare(__instance.name, (SolidTemperatureFilter.ID + "Complete")) == 0)
                {
                    var kanim = __instance.GetComponent <KAnimControllerBase>();
                    if (kanim == null)
                    {
                        return;
                    }

                    kanim.TintColour = SolidTemperatureFilter.ChangeColor();
                }
            }
        public static void SetColor(BuildingComplete building)
        {
            var primaryElement = building.GetComponent <PrimaryElement>();
            var kAnimBase      = building.GetComponent <KAnimControllerBase>();

            if (primaryElement == null || kAnimBase == null)
            {
                return;
            }

            var element     = primaryElement.Element;
            var elementName = UI.StripLinkFormatting(element.name);

            var colorDictionary = WallpaperPatches.ConfigManager.Config.Colors;
            var color           = colorDictionary.ContainsKey(elementName) ? colorDictionary[elementName].ToColor() : element.substance.uiColour;

            if (element.id == SimHashes.Granite && !colorDictionary.ContainsKey(SimHashes.Granite.ToString()))
            {
                color.a = byte.MaxValue;
            }

            kAnimBase.TintColour = color;
        }
 public static void Postfix(BuildingComplete __instance)
 {
     KAnimControllerBase kAnimBase = __instance.GetComponent<KAnimControllerBase>();
     if (kAnimBase != null)
     {
         if (__instance.name == "PollutedElectrolyzerComplete") // I found it in the logs
         {
             float r = 255 - 70;// 100
             float g = 255; // more the int after - is big, less green and more pink
             float b = 255 - 150; //50
             kAnimBase.TintColour = new Color(r / 255f, g / 255f, b / 255f);
         }
     }
 }
 public static void Postfix(BuildingComplete __instance)
 {
     if (__instance.name != null)
     {
         if (__instance.name == "ChlorineDiffuserComplete" && __instance.GetComponent <KAnimControllerBase>() != null)
         {
             __instance.GetComponent <KAnimControllerBase>().TintColour = new Color(0.53f, 0.79f, 0.34f);
         }
     }
     //KAnimControllerBase component = __instance.GetComponent<KAnimControllerBase>();
     //bool flag = component != null;
     //if (flag)
     //{
     //    bool flag2 = __instance.name == "ChlorineDiffuserComplete";
     //    if (flag2)
     //    {
     //        float num = 135f;
     //        float num2 = 200f;
     //        float num3 = 85f;
     //        component.TintColour = new Color(num / 255f, num2 / 255f, num3 / 255f);
     //    }
     //}
 }
Exemple #22
0
        private static void ApplyColorToBuilding(BuildingComplete building, Color color)
        {
            TreeFilterable      treeFilterable;
            Ownable             ownable;
            KAnimControllerBase kAnimBase;

            if ((ownable = building.GetComponent <Ownable>()) != null)
            {
                TryApplyTintViaOwnable(ownable, color);
            }
            else if ((treeFilterable = building.GetComponent <TreeFilterable>()) != null)
            {
                TryApplyTintViaTreeFilterable(treeFilterable, color);
            }
            else if ((kAnimBase = building.GetComponent <KAnimControllerBase>()) != null)
            {
                kAnimBase.TintColour = color;
            }
            else
            {
                State.Common.Logger.LogOnce($"Invalid building <{building}> and its not a registered tile.");
            }
        }
Exemple #23
0
            public static void Postfix(BuildingComplete __instance)
            {
                if (string.Compare(__instance.name, (GasValveExactQtyByG.ID + "Complete")) == 0)
                {
                    var kanim = __instance.GetComponent <KAnimControllerBase>();
                    if (kanim == null)
                    {
                        return;
                    }

                    kanim.TintColour = GasValveExactQtyByG.ChangeColor();
                }

                if (string.Compare(__instance.name, (GasValveExactQtyByKG.ID + "Complete")) == 0)
                {
                    var kanim = __instance.GetComponent <KAnimControllerBase>();
                    if (kanim == null)
                    {
                        return;
                    }

                    kanim.TintColour = GasValveExactQtyByKG.ChangeColor();
                }
            }
Exemple #24
0
            public static void Postfix(BuildingComplete __instance)
            {
                var kAnimBase = __instance.GetComponent <KAnimControllerBase>();

                if (kAnimBase != null)
                {
                    if (__instance.name == "HeliumExtractorComplete")
                    {
                        float r = 255;
                        float g = 255 - 200;
                        float b = 255 - 100;
                        kAnimBase.TintColour = new Color(r / 255f, g / 255f, b / 255f);
                    }
                }
            }
Exemple #25
0
        public static void Postfix(ref BuildingComplete __instance)
        {
            // Trigger if the building is an InsulatedPressureDoor
            if (string.Compare(__instance.name, "InsulatedPressureDoorComplete") == 0)
            {
                // Apply the custom colour tint
                __instance.GetComponent <KAnimControllerBase>().TintColour = InsulatedPressureDoorConfig.Color();

                // Add the InsulatingDoor component
                __instance.gameObject.AddOrGet <InsulatingDoor>();
            }

            // If the building has the InsulatingDoor component, apply its insulation
            InsulatingDoor insulatingDoor = __instance.gameObject.GetComponent <InsulatingDoor>();

            if (insulatingDoor != null)
            {
                insulatingDoor.SetInsulation(__instance.gameObject, insulatingDoor.door.building.Def.ThermalConductivity);
            }
        }
Exemple #26
0
        public static void Postfix(BuildingComplete __instance)
        {
            var kAnimBase = __instance.GetComponent <KAnimControllerBase>();

            if (kAnimBase != null)
            {
                Debug.Log(__instance.name);
                if (__instance.name == "BleachStoneRefineryComplete")
                {
                    float r = 255 - 60;
                    float g = 255 - 50;
                    float b = 255 - 130;
                    kAnimBase.TintColour = new Color(r / 255f, g / 255f, b / 255f);
                }
                if (__instance.name == "SlimeRefineryComplete")
                {
                    float r = 255 - 127;
                    float g = 255 - 159;
                    float b = 255 - 159;
                    kAnimBase.TintColour = new Color(r / 255f, g / 255f, b / 255f);
                }
            }
        }
        public static void UpdateBuildingColor(BuildingComplete building)
        {
            string    buildingName = building.name.Replace("Complete", string.Empty);
            SimHashes material     = MaterialHelper.ExtractMaterial(building);

            Color32 color;

            if (State.ConfiguratorState.Enabled)
            {
                switch (State.ConfiguratorState.ColorMode)
                {
                case ColorMode.Json:
                    color = material.GetMaterialColorForType(buildingName);
                    break;

                case ColorMode.DebugColor:
                    color = material.ToDebugColor();
                    break;

                default:
                    color = ColorHelper.DefaultColor;
                    break;
                }
            }
            else
            {
                color = ColorHelper.DefaultColor;
            }

            if (State.TileNames.Contains(buildingName))
            {
                try
                {
                    if (ColorHelper.TileColors == null)
                    {
                        ColorHelper.TileColors = new Color?[Grid.CellCount];
                    }

                    ColorHelper.TileColors[Grid.PosToCell(building.gameObject)] = color;

                    return;
                }
                catch (Exception e)
                {
                    State.Logger.Log("Error while aquiring cell color");
                    State.Logger.Log(e);
                }
            }

            Color32 dimmedColor = color.SetBrightness(color.GetBrightness() / 2);

            // storagelocker
            StorageLocker storageLocker = building.GetComponent <StorageLocker>();

            if (storageLocker != null)
            {
                //SetFilteredStorageColors(storageLocker.filteredStorage, color, dimmedColor);
                SetFilteredStorageColors(storageLocker, (Color)color, (Color)dimmedColor);
            }
            else
            {
                // ownable
                Ownable ownable = building.GetComponent <Ownable>();

                if (ownable != null)
                {
                    //ownable.ownedTint   = color;
                    SetField(ownable, "ownedTint", (Color)color);
                    //ownable.unownedTint = dimmedColor;
                    SetField(ownable, "unownedTint", (Color)dimmedColor);
                    //ownable.UpdateTint();
                    Invoke(ownable, "UpdateTint");
                }
                else
                {
                    // rationbox
                    RationBox rationBox = building.GetComponent <RationBox>();

                    if (rationBox != null)
                    {
                        //SetFilteredStorageColors(rationBox.filteredStorage, color, dimmedColor);
                        SetFilteredStorageColors(rationBox, (Color)color, (Color)dimmedColor);
                    }
                    else
                    {
                        // refrigerator
                        Refrigerator fridge = building.GetComponent <Refrigerator>();

                        if (fridge != null)
                        {
                            //SetFilteredStorageColors(fridge.filteredStorage, color, dimmedColor);
                            SetFilteredStorageColors(fridge, (Color)color, (Color)dimmedColor);
                        }
                        else
                        {
                            // anything else
                            KAnimControllerBase kAnimControllerBase = building.GetComponent <KAnimControllerBase>();

                            if (kAnimControllerBase != null)
                            {
                                kAnimControllerBase.TintColour = color;
                            }
                            else
                            {
                                Debug.LogError(
                                    $"Can't find KAnimControllerBase component in <{buildingName}> and its not a registered tile.");
                            }
                        }
                    }
                }
            }
        }
    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);
    }