/// <summary> /// Opens a mod port. Doesn't add a port /// </summary> /// <param name="comp">The Computer.</param> /// <param name="port">The Port.Type to search for.</param> /// <param name="ipFrom">The ip responsible for the change.</param> public static void OpenModPort(this Hacknet.Computer comp, Port.Type port, string ipFrom = null) { var i = port.GetWithin(comp); if (i == null) { return; } i.Unlocked |= !comp.silent; if (!string.IsNullOrEmpty(ipFrom)) { comp.log(ipFrom + " Opened Port#" + port.PortName + "/" + port.PortDisplay); } comp.sendNetworkMessage("cPortOpen " + comp.ip + " " + ipFrom + " " + port); }
/// <summary> /// Determines whether Computer has a certain mod port. /// </summary> /// <returns><c>true</c>, if Computer has the port, <c>false</c> otherwise.</returns> /// <param name="port">The Port.Type to search by.</param> public static bool HasModPort(this Hacknet.Computer comp, Port.Type port) => port.GetWithin(comp) != null;
/// <summary> /// Determines whether the modded port is open. /// </summary> /// <returns><c>true</c>, if the port exists and is open, <c>false</c> otherwise.</returns> /// <param name="comp">The Computer</param> /// <param name="port">The Port.Type to find</param> public static bool IsModPortOpen(this Hacknet.Computer comp, Port.Type port) => port.GetWithin(comp)?.Unlocked == true;
public static void RemapModPort(this Hacknet.Computer comp, Port.Type selectedPort, int remap) => selectedPort.GetWithin(comp).MappedPort = remap;