예제 #1
0
        /// <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);
        }
예제 #2
0
        /// <summary>
        /// Gets a port
        /// </summary>
        /// <param name="t">The type of port</param>
        /// <returns>Port object</returns>
        /// <exception cref="InvalidIOException">Thrown when internal IO error happens</exception>
        /// <since_tizen> 5 </since_tizen>
        protected Port GetPort(Port.Type t)
        {
            var err = Interop.LibRPCPort.Proxy.GetPort(_proxy,
                                                       (Interop.LibRPCPort.PortType)t, out IntPtr port);

            switch (err)
            {
            case Interop.LibRPCPort.ErrorCode.InvalidParameter:
            case Interop.LibRPCPort.ErrorCode.IoError:
                throw new InvalidIOException();
            }

            return(new Port()
            {
                Handle = port
            });
        }
예제 #3
0
        /// <summary>
        /// Gets s port.
        /// </summary>
        /// <param name="t">The type of port.</param>
        /// <param name="instance">The ID of the instance, which is connected.</param>
        /// <returns>Port object.</returns>
        /// <exception cref="InvalidIDException">Thrown when invalid instance is used.</exception>
        /// <exception cref="InvalidIOException">Thrown when an internal IO error occurs.</exception>
        /// <since_tizen> 5 </since_tizen>
        protected Port GetPort(Port.Type t, string instance)
        {
            var err = Interop.LibRPCPort.Stub.GetPort(_stub,
                                                      (Interop.LibRPCPort.PortType)t, instance, out IntPtr port);

            switch (err)
            {
            case Interop.LibRPCPort.ErrorCode.InvalidParameter:
                throw new InvalidIDException();

            case Interop.LibRPCPort.ErrorCode.IoError:
                throw new InvalidIOException();
            }

            return(new Port()
            {
                Handle = port
            });
        }
예제 #4
0
 /// <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;
예제 #5
0
 /// <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;
예제 #6
0
 public static bool RemoveModPort(this Hacknet.Computer comp, Port.Type port) =>
 port?.RemoveFrom(comp) == true;
예제 #7
0
 /// <summary>
 /// Adds the mod port by port type.
 /// </summary>
 /// <returns><c>true</c>, if mod port was added, <c>false</c> otherwise.</returns>
 /// <param name="comp">The Computer</param>
 /// <param name="port">The Port.Type to add to Computer</param>
 /// <param name="unlocked">If set to <c>true</c> then sets the port to be unlocked.</param>
 public static bool AddModPort(this Hacknet.Computer comp, Port.Type port, bool unlocked = false) =>
 port?.AssignTo(comp, unlocked) == true;
예제 #8
0
 public static void RemapModPort(this Hacknet.Computer comp, Port.Type selectedPort, int remap) =>
 selectedPort.GetWithin(comp).MappedPort = remap;
예제 #9
0
파일: Bombe.cs 프로젝트: yberry/Keep
 public bool HasPort(Port.Type t)
 {
     return(ports.Any(p => p.Nom == t));
 }