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 void Postfix(int cell, Orientation orientation, GameObject go, BuildingDef __instance) { MultiOutput multiOut = __instance.BuildingComplete.GetComponent <MultiOutput>(); MultiInput multiIn = __instance.BuildingComplete.GetComponent <MultiInput>(); multiOut?.UnmarkAreas(cell, orientation, go, __instance.MarkOverlappingPorts); multiIn?.UnmarkAreas(cell, orientation, go, __instance.MarkOverlappingPorts); }
public static void Postfix(Building __instance, BuildingDef def, List <Descriptor> __result) { MultiOutput multiOut = __instance.GetComponent <MultiOutput>(); if (multiOut != null) { int gasOut = 0; int liquidOut = 0; int solidOut = 0; foreach (OutputPort port in multiOut.PortList) { if (!port.RequiresConnection) { continue; } if (port.ConduitType == ConduitType.Gas) { gasOut++; } else if (port.ConduitType == ConduitType.Liquid) { liquidOut++; } else if (port.ConduitType == ConduitType.Solid) { solidOut++; } } if (gasOut > 0) { Descriptor gasOutDesc = default(Descriptor); string prefix = gasOut > 1 ? $"({gasOut}) " : ""; gasOutDesc.SetupDescriptor(prefix + UI.BUILDINGEFFECTS.REQUIRESGASOUTPUT, UI.BUILDINGEFFECTS.TOOLTIPS.REQUIRESGASOUTPUT, Descriptor.DescriptorType.Requirement); __result.Add(gasOutDesc); } if (liquidOut > 0) { Descriptor liquitOutDesc = default(Descriptor); string prefix = liquidOut > 1 ? $"({liquidOut}) " : ""; liquitOutDesc.SetupDescriptor(prefix + UI.BUILDINGEFFECTS.REQUIRESLIQUIDOUTPUT, UI.BUILDINGEFFECTS.TOOLTIPS.REQUIRESLIQUIDOUTPUT, Descriptor.DescriptorType.Requirement); __result.Add(liquitOutDesc); } if (solidOut > 0) { Descriptor solidOutDesc = default(Descriptor); string prefix = solidOut > 1 ? $"({solidOut}) " : ""; solidOutDesc.SetupDescriptor(prefix + UI.FormatAsLink("Solid Output Pipe", "SOLIDPIPING"), $"Must expel <style=\"KKeywork\">Solid</style> through a {BUILDINGS.PREFABS.SOLIDCONDUIT.NAME} system", Descriptor.DescriptorType.Requirement); __result.Add(solidOutDesc); } } MultiInput multiIn = __instance.GetComponent <MultiInput>(); if (multiIn != null) { int gasIn = 0; int liquidIn = 0; int solidIn = 0; foreach (InputPort port in multiIn.PortList) { if (!port.RequiresConnection) { continue; } if (port.ConduitType == ConduitType.Gas) { gasIn++; } else if (port.ConduitType == ConduitType.Liquid) { liquidIn++; } else if (port.ConduitType == ConduitType.Solid) { solidIn++; } } if (gasIn > 0) { Descriptor gasOutDesc = default(Descriptor); string prefix = gasIn > 1 ? $"({gasIn}) " : ""; gasOutDesc.SetupDescriptor(prefix + UI.BUILDINGEFFECTS.REQUIRESGASINPUT, UI.BUILDINGEFFECTS.TOOLTIPS.REQUIRESGASINPUT, Descriptor.DescriptorType.Requirement); __result.Add(gasOutDesc); } if (liquidIn > 0) { Descriptor liquitOutDesc = default(Descriptor); string prefix = liquidIn > 1 ? $"({liquidIn}) " : ""; liquitOutDesc.SetupDescriptor(prefix + UI.BUILDINGEFFECTS.REQUIRESLIQUIDINPUT, UI.BUILDINGEFFECTS.TOOLTIPS.REQUIRESLIQUIDINPUT, Descriptor.DescriptorType.Requirement); __result.Add(liquitOutDesc); } if (solidIn > 0) { Descriptor solidOutDesc = default(Descriptor); string prefix = solidIn > 1 ? $"({solidIn}) " : ""; solidOutDesc.SetupDescriptor(prefix + UI.FormatAsLink("Solid Input Pipe", "SOLIDPIPING"), $"Must receive <style=\"KKeywork\">Solids</style> from a {BUILDINGS.PREFABS.SOLIDCONDUIT.NAME} system", Descriptor.DescriptorType.Requirement); __result.Add(solidOutDesc); } } }
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; } }