예제 #1
0
            public static void Postfix(ref bool __result, BuildingDef __instance, GameObject source_go, int cell, Orientation orientation, ref string fail_reason)
            {
                if (!__result || source_go == null)
                {
                    return;
                }
                List <ConduitIO> portList = MultiIOExtensions.GetAllPortsFromObject(source_go);

                if (portList.Count == 0)
                {
                    return;
                }

                foreach (ConduitIO port in portList)
                {
                    CellOffset rotatedCellOffset = Rotatable.GetRotatedCellOffset(port.CellOffset, orientation);
                    int        portCell          = Grid.OffsetCell(cell, rotatedCellOffset);
                    //fail_reason is ref, Invoke will modify this array if fail_reason is used
                    object[] parameters = new object[] { source_go, port.ConduitType, portCell, fail_reason };
                    //Debug.Log($"[MultiIO] Are Conduit Ports in Valid Positions?");
                    __result    = (bool)areConduitPortsInValidPositionsMethod.Invoke(__instance, parameters);
                    fail_reason = (string)parameters[3];
                    if (!__result)
                    {
                        return;
                    }
                }
            }
예제 #2
0
            public static void Postfix(BuildingCellVisualizer __instance)
            {
                List <ConduitIO> ports = MultiIOExtensions.GetAllPortsFromObject(__instance.gameObject);

                foreach (ConduitIO outPort in ports)
                {
                    GameObject visualizer = outPort.CellVisualizer;
                    if (visualizer != null)
                    {
                        UnityEngine.Object.Destroy(visualizer);
                    }
                }
            }
예제 #3
0
            public static void Postfix(BuildingCellVisualizer __instance)
            {
                List <ConduitIO> ports = MultiIOExtensions.GetAllPortsFromObject(__instance.gameObject);

                foreach (ConduitIO port in ports)
                {
                    GameObject visualizer = port.CellVisualizer;
                    if (visualizer != null)
                    {
                        visualizer.SetActive(false);
                    }
                }
            }
예제 #4
0
            public static void Postfix(ref bool __result, BuildingDef __instance, GameObject source_go, int cell, Orientation orientation)
            {
                if (!__result || source_go == null)
                {
                    return;
                }
                List <ConduitIO> portList = MultiIOExtensions.GetAllPortsFromObject(source_go);

                if (portList.Count == 0)
                {
                    return;
                }

                foreach (ConduitIO port in portList)
                {
                }
            }
예제 #5
0
            public static void Postfix(HashedString mode, BuildingCellVisualizer __instance, Building ___building, BuildingCellVisualizerResources ___resources)
            {
                List <ConduitIO> ports      = MultiIOExtensions.GetAllPortsFromObject(___building.gameObject);
                Sprite           outputIcon = ___resources.gasOutputIcon;
                Sprite           inputIcon  = ___resources.gasInputIcon;

                if (OverlayModes.GasConduits.ID == mode)
                {
                    foreach (ConduitIO port in ports)
                    {
                        if (port.ConduitType == ConduitType.Gas)
                        {
                            CellOffset offset = port.CellOffset;
                            int        cell   = Grid.OffsetCell(___building.GetCell(), ___building.GetRotatedOffset(offset));
                            CallDrawUtilityIcon(__instance, cell, port is InputPort ? inputIcon : outputIcon, ref port.CellVisualizer, port.IconColor, Color.white);
                        }
                    }
                }
                else if (OverlayModes.LiquidConduits.ID == mode)
                {
                    foreach (ConduitIO port in ports)
                    {
                        if (port.ConduitType == ConduitType.Liquid)
                        {
                            CellOffset offset = port.CellOffset;
                            int        cell   = Grid.OffsetCell(___building.GetCell(), ___building.GetRotatedOffset(offset));
                            CallDrawUtilityIcon(__instance, cell, port is InputPort ? inputIcon : outputIcon, ref port.CellVisualizer, port.IconColor, Color.white);
                        }
                    }
                }
                else if (OverlayModes.SolidConveyor.ID == mode)
                {
                    foreach (ConduitIO port in ports)
                    {
                        if (port.ConduitType == ConduitType.Solid)
                        {
                            CellOffset offset = port.CellOffset;
                            int        cell   = Grid.OffsetCell(___building.GetCell(), ___building.GetRotatedOffset(offset));
                            CallDrawUtilityIcon(__instance, cell, port is InputPort ? inputIcon : outputIcon, ref port.CellVisualizer, port.IconColor, Color.white);
                        }
                    }
                }
            }