Example #1
0
        /// <summary>
        /// Creates the EOS Device connected to Computer.
        /// </summary>
        /// <returns>The created EOS Device.</returns>
        /// <param name="comp">The Computer.</param>
        /// <param name="name">The device's name.</param>
        /// <param name="ip">The device's ip.</param>
        /// <param name="icon">The device's icon.</param>
        /// <param name="location">The device's NetworkMap position.</param>
        /// <param name="password">The device's password, by game default should be alpine.</param>
        /// <param name="vanillaPorts">The device's closed vanilla port numbers.</param>
        /// <param name="portCracksRequired">The device's cracked ports required to unlock.</param>
        /// <param name="eosFolder">The device's eos folder.</param>
        /// <param name="modPorts">The device's closed modded Port.Type List.</param>
        public static Hacknet.Computer CreateEOSDeviceOn(this Hacknet.Computer comp,
                                                         string name               = "Unregistered eOS Device",
                                                         string ip                 = null,
                                                         string icon               = "ePhone",
                                                         Vector2?location          = null,
                                                         string password           = "******",
                                                         List <int> vanillaPorts   = null,
                                                         int portCracksRequired    = 2,
                                                         Hacknet.Folder eosFolder  = null,
                                                         List <Port.Type> modPorts = null)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (icon == null)
            {
                throw new ArgumentNullException(nameof(icon));
            }
            if (password == null)
            {
                throw new ArgumentNullException(nameof(password));
            }

            var c = new Hacknet.Computer(name, comp.idName + "_eos", location ??
                                         comp.location + Corporation.getNearbyNodeOffset(comp.location,
                                                                                         Utils.random.Next(12),
                                                                                         12,
                                                                                         comp.GetNetworkMap(),
                                                                                         0f), 0, 5, comp.os)
            {
                icon = icon
            };

            c.setAdminPassword(password);
            vanillaPorts = vanillaPorts ?? new List <int>(new int[] { 22, 3659 });
            foreach (var p in vanillaPorts)
            {
                c.AddVanillaPort(p);
            }
            if (modPorts != null)
            {
                foreach (var p in modPorts)
                {
                    c.AddModPort(p);
                }
            }
            c.portsNeededForCrack = portCracksRequired;
            if (eosFolder != null)
            {
                c.files.root.folders.Add(eosFolder);
            }
            else
            {
                EOSComp.GenerateEOSFilesystem(c);
            }
            comp.AddEOSDevice(c);
            return(c);
        }
Example #2
0
 /// <summary>
 /// Adds a vanilla port by port number.
 /// </summary>
 /// <returns><c>true</c>, if vanilla port was added, <c>false</c> otherwise.</returns>
 /// <param name="comp">The Computer</param>
 /// <param name="portNum">The number for the port</param>
 /// <param name="unlocked">If set to <c>true</c> then sets the port to be unlocked.</param>
 public static bool AddVanillaPort(this Hacknet.Computer comp, int portNum, bool unlocked = false) =>
 comp.AddVanillaPort(ExeInfoManager.GetExecutableInfo(portNum), unlocked);