Exemple #1
0
        public static void UpdateBuildingColor(BuildingComplete building)
        {
            string buildingName = building.name.Replace("Complete", string.Empty);
            Color  color        = ColorHelper.GetComponentMaterialColor(building);

            if (State.TileNames.Contains(buildingName))
            {
                ApplyColorToTile(building, color);
                return;
            }

            try
            {
                if (!State.TypeFilter.Check(buildingName))
                {
                    color = ColorHelper.DefaultColor;
                }
            }
            catch (Exception e)
            {
                State.Common.Logger.LogOnce("Error while filtering buildings", e);
            }

            ApplyColorToBuilding(building, color);
        }
Exemple #2
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 #3
0
 public static void Postfix(BuildingComplete __instance)
 {
     if (string.Compare(__instance.name, (WaterPurifierDynamicConfig.ID + "Complete")) == 0)
     {
         __instance.GetComponent <KAnimControllerBase>().TintColour = WaterPurifierDynamicConfig.Color();
     }
 }
Exemple #4
0
 public static void Postfix(BuildingComplete __instance)
 {
     if (__instance.name == "ExteriorWallComplete" || __instance.name == "ThermalBlockComplete")
     {
         SetColor(__instance);
     }
 }
        /// <summary>
        /// Transfers heat from this object to and from the specified building.
        /// </summary>
        /// <param name="thisElement">The element of this thermal interface plate.</param>
        /// <param name="newBuilding">The target building to transfer heat.</param>
        /// <param name="temp1">The temperature of this building.</param>
        /// <param name="dt">The time delta from the last transfer.</param>
        /// <returns>The new temperature of this building.</returns>
        private float TransferHeatTo(PrimaryElement thisElement, BuildingComplete newBuilding,
                                     float temp1, float dt)
        {
            var thatElement = newBuilding.primaryElement;
            int area2       = newBuilding.Def.WidthInCells * newBuilding.Def.HeightInCells,
                area1       = building.Def.WidthInCells * building.Def.HeightInCells;
            // Capacity per cell for target building
            Element element1 = thisElement.Element, element2 = thatElement?.Element;
            float   mass1 = thisElement.Mass, tnew1 = temp1;

            if (element1 != null && element2 != null && area1 > 0 && area2 > 0)
            {
                // No /5 factor since we are transferring building to building, it cancels out
                float k2 = element2.specificHeatCapacity, k1 = element1.specificHeatCapacity,
                      temp2 = thatElement.Temperature, c2 = k2 * thatElement.Mass / area2,
                      chot = c2, c1 = mass1 * k1 / area1;
                if (temp1 > temp2)
                {
                    chot = c1;
                }
                float tmin = Math.Min(temp1, temp2), tmax = Math.Max(temp1, temp2), dq = dt *
                                                                                         k1 * k2 * chot * (temp1 - temp2) * 0.5f, tnew2 = (temp2 + dq / c2).
                                                                                                                                          InRange(tmin, tmax);
                tnew1 = (temp1 - dq / c1).InRange(tmin, tmax);
                // No order swaps, reach equilibrium
                if ((temp1 - temp2) * (tnew1 - tnew2) < 0.0f)
                {
                    tnew1 = tnew2 = (c1 * temp1 + c2 * temp2) / (c1 + c2);
                }
                // Temperature is modified in sim via a callback
                thatElement.Temperature = tnew2;
            }
            return(tnew1);
        }
        public static void Postfix(ref BuildingComplete __instance)
        {
            if (string.Compare(__instance.name, "InsulatedManualPressureDoorComplete") == 0)
            {
                __instance.gameObject.AddOrGet <InsulatingDoor>();
            }
            if (string.Compare(__instance.name, "InsulatedPressureDoorComplete") == 0)
            {
                __instance.gameObject.AddOrGet <InsulatingDoor>();
            }
            if (string.Compare(__instance.name, "TinyInsulatedManualPressureDoorComplete") == 0)
            {
                __instance.gameObject.AddOrGet <InsulatingDoor>();
            }
            if (string.Compare(__instance.name, "TinyInsulatedPressureDoorComplete") == 0)
            {
                __instance.gameObject.AddOrGet <InsulatingDoor>();
            }

            InsulatingDoor insulatingDoor = __instance.gameObject.GetComponent <InsulatingDoor>();

            if (insulatingDoor != null)
            {
                insulatingDoor.SetInsulation(__instance.gameObject, insulatingDoor.door.building.Def.ThermalConductivity);
            }
        }
Exemple #7
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 #8
0
        public static void UpdateBuildingColor(BuildingComplete building)
        {
            try
            {
                if (building.name == "PixelPackComplete" || building.name == "WallpaperComplete" || building.name.Contains(ExcludeKeyword) || building.HasTag(ExcludedTag))
                {
                    return;
                }

                Color color = ColorHelper.GetComponentMaterialColor(building);

                Filter(building.name, ref color);

                if (State.TileNames.Contains(building.name))
                {
                    ApplyColorToTile(building, color);
                }
                else
                {
                    ApplyColorToBuilding(building, color);
                }
            }
            catch (Exception e)
            {
                State.Common.Logger.LogOnce("Failed to update material building color", e);
            }
        }
 public static void Postfix(BuildingComplete __instance)
 {
     if (__instance.name == "GasSinkComplete")
     {
         var kAnimBase = __instance.GetComponent <KAnimControllerBase>();
         kAnimBase.TintColour = new Color32(255, 0, 0, 255);
     }
 }
 private static void Postfix(ref BuildingComplete __instance)
 {
     if (string.Compare(__instance.name, "ShinseiWaterCoolerComplete") == 0)
     {
         __instance.GetComponent <KAnimControllerBase>().TintColour = ShinseiWaterCoolerConfig.Color();
         //__instance.gameObject.AddOrGet<>
     }
 }
Exemple #11
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 #12
0
    public static void Postfix(ref BuildingComplete __instance)
    {
        InsulatingDoor insulatingDoor = __instance.gameObject.GetComponent <InsulatingDoor>();

        if (insulatingDoor != null)
        {
            insulatingDoor.SetInsulation(__instance.gameObject, 0.01f);
        }
    }
            public static void Postfix(BuildingComplete __instance)
            {
                if (__instance.name != "WallpaperComplete")
                {
                    return;
                }

                ColorTools.SetColor(__instance);
            }
Exemple #14
0
    public static void Postfix(ref BuildingComplete __instance)
    {
        InsulatingDoor insulatingDoor = __instance.gameObject.GetComponent <InsulatingDoor>();

        if (insulatingDoor != null)
        {
            insulatingDoor.SetInsulation(__instance.gameObject, insulatingDoor.door.building.Def.ThermalConductivity);
        }
    }
Exemple #15
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 #16
0
        public static void Postfix(ref BuildingComplete __instance)
        {
            // If the building has the InsulatingDoor component, remove its insulation
            InsulatingDoor insulatingDoor = __instance.gameObject.GetComponent <InsulatingDoor>();

            if (insulatingDoor != null)
            {
                insulatingDoor.SetInsulation(__instance.gameObject, 1f);
            }
        }
Exemple #17
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 #19
0
 private static void ApplyColorToTile(BuildingComplete building, Color color)
 {
     try
     {
         State.TileColors[Grid.PosToCell(building.gameObject)] = color.ToTileColor();
     }
     catch (Exception e)
     {
         State.Common.Logger.LogOnce("Error while getting cell color", e);
     }
 }
Exemple #20
0
    public BuildingDef GetBuildingDef()
    {
        GameObject       prefab    = Assets.GetPrefab(Result);
        BuildingComplete component = prefab.GetComponent <BuildingComplete>();

        if ((UnityEngine.Object)component != (UnityEngine.Object)null)
        {
            return(component.Def);
        }
        return(null);
    }
Exemple #21
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();
         }
     }
 }
    public void OnNewBuilding(object data)
    {
        BuildingComplete component = GetComponent <BuildingComplete>();

        if (component.creationTime > 0f)
        {
            inactiveStartTime = component.creationTime;
            activeStartTime   = component.creationTime;
            activeTimes.Clear();
            inactiveTimes.Clear();
        }
    }
Exemple #23
0
    protected override void OnCleanUp()
    {
        int cell = Grid.PosToCell(this);
        BuildingComplete component = GetComponent <BuildingComplete>();

        if (component.Def.ReplacementLayer == ObjectLayer.NumLayers || (UnityEngine.Object)Grid.Objects[cell, (int)component.Def.ReplacementLayer] == (UnityEngine.Object)null)
        {
            GetNetworkManager().RemoveFromNetworks(cell, this, false);
            GetFlowManager().EmptyConduit(cell);
        }
        base.OnCleanUp();
    }
Exemple #24
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 #25
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 #26
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();
                }
            }
Exemple #27
0
    protected override void OnCleanUp()
    {
        int cell = Grid.PosToCell(base.transform.GetPosition());
        BuildingComplete component = GetComponent <BuildingComplete>();

        if (component.Def.ReplacementLayer == ObjectLayer.NumLayers || (UnityEngine.Object)Grid.Objects[cell, (int)component.Def.ReplacementLayer] == (UnityEngine.Object)null)
        {
            Game.Instance.logicCircuitSystem.RemoveFromNetworks(cell, this, false);
        }
        Unsubscribe(774203113, OnBuildingBrokenDelegate, false);
        Unsubscribe(-1735440190, OnBuildingFullyRepairedDelegate, false);
        base.OnCleanUp();
    }
Exemple #28
0
    private void SetStamps(GameObject target)
    {
        for (int i = 0; i < stampContainer.transform.childCount; i++)
        {
            UnityEngine.Object.Destroy(stampContainer.transform.GetChild(i).gameObject);
        }
        BuildingComplete component = target.GetComponent <BuildingComplete>();

        if (!((UnityEngine.Object)component != (UnityEngine.Object)null))
        {
            return;
        }
    }
Exemple #29
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 #30
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();
                }
            }