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); }); } }
public static ConduitIO GetPortAt(GameObject obj, int cell) { if (portCache.ContainsKey(cell)) { ConduitIO port = portCache[cell]; if (port.transform.parent == obj.transform) { return(port); } } return(null); }
internal static void RegisterPort(int cell, ConduitIO port) { if (portCache.ContainsKey(cell)) { Debug.LogWarning($"[MultiIO] MultiIOExtensions.RegisterPort() -> Port registered with a cell that was already cached. Replacing entry."); portCache[cell] = port; } else { portCache.Add(cell, port); } }
public static void Postfix(BuildingCellVisualizer __instance, int cell) { ConduitIO port = MultiIOExtensions.GetPortAt(__instance.gameObject, cell); 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); }); } }
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; } ConduitIO port = MultiIOExtensions.GetPortAt(building.gameObject, 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; } }
public static bool Intersects(ConduitIO port, int origin, Orientation orientation) { return(false); }