Ejemplo n.º 1
0
            public static void Postfix(BuildingCellVisualizer __instance, int cell)
            {
                //ConduitIO port = MultiIOExtensions.GetPortAt(__instance.gameObject, cell);
                GameObject obj = Grid.Objects[cell, 1];

                if (obj == null)
                {
                    return;
                }
                MultiInput  multiInput = obj.GetComponent <MultiInput>();
                MultiOutput multiOut   = obj.GetComponent <MultiOutput>();
                ConduitIO   port       = null;

                port = multiInput?.GetPortAt(cell);
                if (port == null)
                {
                    port = multiOut?.GetPortAt(cell);
                    if (port == null)
                    {
                        return;
                    }
                }
                if (port != null)
                {
                    GameObject visualizer = port.CellVisualizer;
                    SizePulse  pulse      = visualizer.AddComponent <SizePulse>();
                    pulse.speed            = 20f;
                    pulse.multiplier       = 0.75f;
                    pulse.updateWhenPaused = true;
                    pulse.onComplete       = (System.Action)Delegate.Combine(pulse.onComplete, (System.Action) delegate { UnityEngine.Object.Destroy(pulse); });
                }
            }
Ejemplo n.º 2
0
            public static void Postfix(int cell, string defName, string soundName, bool fireEvents, ref bool __result)
            {
                //Only need to patch if the result was false and a pipe is being checked (liquid/gas)
                if (__result)
                {
                    return;
                }
                if (!defName.Contains("Conduit"))
                {
                    return;
                }
                Building building = Grid.Objects[cell, 1]?.GetComponent <Building>();

                if (building == null)
                {
                    return;
                }
                MultiInput  multiInput = building.GetComponent <MultiInput>();
                MultiOutput multiOut   = building.GetComponent <MultiOutput>();
                ConduitIO   port       = null;

                port = multiInput?.GetPortAt(cell);
                if (port == null)
                {
                    port = multiOut?.GetPortAt(cell);
                    if (port == null)
                    {
                        return;
                    }
                }

                ConduitType type      = port.ConduitType;
                string      nameCheck = "";

                if (type == ConduitType.Gas)
                {
                    nameCheck = "Gas";
                }
                else if (type == ConduitType.Liquid)
                {
                    nameCheck = "Liquid";
                }
                else if (type == ConduitType.Solid)
                {
                    nameCheck = "Solid";
                }
                if (nameCheck == "" || !defName.Contains(nameCheck))
                {
                    return;
                }

                BuildingCellVisualizer bcv = building.GetComponent <BuildingCellVisualizer>();

                if (bcv != null)
                {
                    if (fireEvents)
                    {
                        bcv.ConnectedEvent(cell);
                        string sound = GlobalAssets.GetSound(soundName);
                        if (sound != null)
                        {
                            KMonoBehaviour.PlaySound(sound);
                        }
                    }
                    __result = true;
                }
            }