Example #1
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);
                        }
                    }
                }
Example #2
0
        private static bool TryApplyTintViaTreeFilterable(TreeFilterable treeFilterable, Color32 targetColor)
        {
            try
            {
                var traversedTreeFilterable = Traverse.Create(treeFilterable);

                traversedTreeFilterable.Field("filterTint").SetValue(targetColor);

                var tags = traversedTreeFilterable.Field <List <Tag> >("acceptedTags").Value.ToArray();

                treeFilterable.OnFilterChanged(tags);

                return(true);
            }
            catch (Exception e)
            {
                State.Common.Logger.LogOnce("Failed to apply tint using TreeFiltertable traverse", e);
            }

            return(false);
        }