Ejemplo n.º 1
0
                public static void Postfix(BuildingCellVisualizer __instance, HashedString mode)
                {
                    Traverse         traverse1 = Traverse.Create((object)__instance);
                    Building         building  = traverse1.Field("building").GetValue <Building>();
                    ISecondaryOutput component = building.Def.BuildingComplete.GetComponent <ISecondaryOutput>();

                    if (component == null || component.GetSecondaryConduitType() != ConduitType.Solid)
                    {
                        return;
                    }
                    BuildingCellVisualizerResources visualizerResources = traverse1.Field("resources").GetValue <BuildingCellVisualizerResources>();
                    Traverse traverse2 = traverse1.Field("icons");
                    Dictionary <GameObject, Image> icons = traverse2.GetValue <Dictionary <GameObject, Image> >();
                    Traverse traverse3 = traverse1.Field("secondaryOutputVisualizer");

                    if (icons == null)
                    {
                        return;
                    }
                    GameObject visualizerObj = traverse3.GetValue <GameObject>();

                    if ((UnityEngine.Object)visualizerObj == (UnityEngine.Object)null)
                    {
                        GameObject key = Util.KInstantiate(Assets.UIPrefabs.ResourceVisualizer, GameScreenManager.Instance.worldSpaceCanvas, (string)null);
                        key.transform.SetAsFirstSibling();
                        icons.Add(key, key.transform.GetChild(0).GetComponent <Image>());
                        traverse3.SetValue((object)key);
                    }
                    else
                    {
                        if (mode != OverlayModes.SolidConveyor.ID || !(bool)((UnityEngine.Object)building) || !(bool)((UnityEngine.Object)visualizerResources))
                        {
                            return;
                        }
                        CellOffset secondaryConduitOffset = component.GetSecondaryConduitOffset();
                        InfiniteSourceSinkPatches.Db_Initialize_Patch.DrawUtilityIcon(ref icons, InfiniteSourceSinkPatches.Db_Initialize_Patch.GetVisualizerCell(building, secondaryConduitOffset), visualizerResources.liquidOutputIcon, ref visualizerObj, (Color)BuildingCellVisualizer.secondOutputColour);
                        traverse3.SetValue((object)visualizerObj);
                        traverse2.SetValue((object)icons);
                    }
                }
Ejemplo n.º 2
0
    private void MapBuilding()
    {
        BuildingDef def = building.Def;

        if (def.CheckRequiresPowerInput())
        {
            ports |= Ports.PowerIn;
        }
        if (def.CheckRequiresPowerOutput())
        {
            ports |= Ports.PowerOut;
        }
        if (def.CheckRequiresGasInput())
        {
            ports |= Ports.GasIn;
        }
        if (def.CheckRequiresGasOutput())
        {
            ports |= Ports.GasOut;
        }
        if (def.CheckRequiresLiquidInput())
        {
            ports |= Ports.LiquidIn;
        }
        if (def.CheckRequiresLiquidOutput())
        {
            ports |= Ports.LiquidOut;
        }
        if (def.CheckRequiresSolidInput())
        {
            ports |= Ports.SolidIn;
        }
        if (def.CheckRequiresSolidOutput())
        {
            ports |= Ports.SolidOut;
        }
        DiseaseVisualization.Info info = Assets.instance.DiseaseVisualization.GetInfo(def.DiseaseCellVisName);
        if (info.name != null)
        {
            diseaseSourceSprite = Assets.instance.DiseaseVisualization.overlaySprite;
            diseaseSourceColour = info.overlayColour;
        }
        ISecondaryInput component = def.BuildingComplete.GetComponent <ISecondaryInput>();

        if (component != null)
        {
            switch (component.GetSecondaryConduitType())
            {
            case ConduitType.Gas:
                secondary_ports |= Ports.GasIn;
                break;

            case ConduitType.Liquid:
                secondary_ports |= Ports.LiquidIn;
                break;
            }
        }
        ISecondaryOutput component2 = def.BuildingComplete.GetComponent <ISecondaryOutput>();

        if (component2 != null)
        {
            switch (component2.GetSecondaryConduitType())
            {
            case ConduitType.Gas:
                secondary_ports |= Ports.GasOut;
                break;

            case ConduitType.Liquid:
                secondary_ports |= Ports.LiquidOut;
                break;
            }
        }
    }