Ejemplo n.º 1
0
 internal static void AddComputerReference(List <Computer> __instance, Computer item)
 {
     if (object.ReferenceEquals(__instance, OS.currentInstance?.netMap?.nodes))
     {
         ComputerLookup.PopulateLookups(item);
     }
 }
Ejemplo n.º 2
0
        private static void AddMissionGenComputer(object __result)
        {
            var comp = (Computer)__result;

            comp.idName = "Gen" + MissionGenerator.generationCount;
            ComputerLookup.Add(comp);
        }
Ejemplo n.º 3
0
        internal static void OnChangeIPTrigger2(SAChangeIP __instance, string __state)
        {
            var comp = ComputerLookup.Find(__instance.TargetComp);

            if (comp != null && comp.ip != __state)
            {
                ComputerLookup.RebuildLookups();
            }
        }
Ejemplo n.º 4
0
 internal static void AddComputerReferenceRange(List <Computer> __instance, IEnumerable <Computer> collection)
 {
     if (object.ReferenceEquals(__instance, OS.currentInstance?.netMap?.nodes))
     {
         foreach (var comp in collection)
         {
             ComputerLookup.PopulateLookups(comp);
         }
     }
 }
 internal static bool GenerateRandomIPReplacement(out string __result)
 {
     while (true)
     {
         var ip = Utils.random.Next(254) + 1 + "." + (Utils.random.Next(254) + 1) + "." + (Utils.random.Next(254) + 1) + "." + (Utils.random.Next(254) + 1);
         if (ComputerLookup.FindByIp(ip, false) == null)
         {
             __result = ip;
             return(false);
         }
     }
 }
Ejemplo n.º 6
0
        internal static void OnISPChangeIP(ILContext il)
        {
            ILCursor c = new ILCursor(il);

            c.GotoNext(MoveType.After, x => x.MatchCallOrCallvirt(AccessTools.Method(typeof(NetworkMap), nameof(NetworkMap.generateRandomIP))));

            c.Emit(OpCodes.Dup);
            c.Emit(OpCodes.Ldarg_0);
            c.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(ISPDaemon), nameof(ISPDaemon.scannedComputer)));
            c.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(Computer), nameof(Computer.ip)));
            c.EmitDelegate <Action <string, string> >((newIp, oldIp) =>
            {
                if (ComputerLookup.FindByIp(newIp) == null)
                {
                    ComputerLookup.NotifyIPChange(oldIp, newIp);
                }
            });
        }
Ejemplo n.º 7
0
 internal static bool ScanReplacement(string[] args, OS os)
 {
     if (args.Length > 1)
     {
         Computer computer = ComputerLookup.FindByIp(args[1]);
         if (computer == null)
         {
             computer = ComputerLookup.FindByName(args[1]);
         }
         if (computer != null)
         {
             os.netMap.discoverNode(computer);
             os.write("Found Terminal : " + computer.name + "@" + computer.ip);
         }
         return(false);
     }
     return(true);
 }
Ejemplo n.º 8
0
        private static void DScanReplacement(OS os, string[] args)
        {
            if (args.Length < 2)
            {
                os.write("No Node ID Given");
                return;
            }
            var comp = ComputerLookup.FindById(args[1]);

            if (comp != null)
            {
                os.netMap.discoverNode(comp);
                comp.highlightFlashTime = 1f;
            }
            else
            {
                os.write("Node ID Not found");
            }
        }
Ejemplo n.º 9
0
        internal static bool ScanReplacement(string[] args, OS os)
        {
            if (args.Length > 1)
            {
                Computer computer = ComputerLookup.FindByIp(args[1]);
                if (computer == null)
                {
                    computer = ComputerLookup.FindByName(args[1]);
                }
                if (computer != null)
                {
                    os.netMap.discoverNode(computer);
                    os.write("Found Terminal : " + computer.name + "@" + computer.ip);
                }
                return(false);
            }
            Computer computer2 = ((os.connectedComp != null) ? os.connectedComp : os.thisComputer);

            if (os.hasConnectionPermission(admin: true))
            {
                os.write("Scanning...");
                for (int i = 0; i < computer2.links.Count; i++)
                {
                    if (!os.netMap.visibleNodes.Contains(computer2.links[i]))
                    {
                        os.netMap.visibleNodes.Add(computer2.links[i]);
                    }
                    os.netMap.nodes[computer2.links[i]].highlightFlashTime = 1f;
                    os.write("Found Terminal : " + os.netMap.nodes[computer2.links[i]].name + "@" + os.netMap.nodes[computer2.links[i]].ip);
                    os.netMap.lastAddedNode = os.netMap.nodes[computer2.links[i]];
                    Thread.Sleep(400);
                }
                os.write("Scan Complete\n");
            }
            else
            {
                os.write("Scanning Requires Admin Access\n");
            }
            return(false);
        }
Ejemplo n.º 10
0
 internal static void RebuildAfterNodeGen()
 {
     ComputerLookup.RebuildLookups();
 }
Ejemplo n.º 11
0
 internal static void OnChangeIPTrigger(SAChangeIP __instance, out string __state)
 {
     __state = ComputerLookup.Find(__instance.TargetComp)?.ip;
 }
Ejemplo n.º 12
0
 internal static bool ModifyProgramsLookup(out Computer __result, string ip_Or_ID_or_Name)
 {
     __result = ComputerLookup.Find(ip_Or_ID_or_Name);
     return(false);
 }
Ejemplo n.º 13
0
 internal static bool ModifyComputerLoaderLookup(out Computer __result, string target)
 {
     __result = ComputerLookup.FindById(target);
     return(false);
 }
Ejemplo n.º 14
0
 internal static void ClearOnQuitGame()
 {
     ComputerLookup.ClearLookups();
 }
Ejemplo n.º 15
0
        static MissionLoader()
        {
            EventManager.onPluginUnload += OnPluginUnload;

            executor.RegisterExecutor("mission", (exec, info) =>
            {
                hasMissionTag       = true;
                mission.activeCheck = info.Attributes.GetBool("activeCheck");
                mission.ShouldIgnoreSenderVerification = info.Attributes.GetBool("shouldIgnoreSenderVerification");
            });
            executor.RegisterExecutor("mission.goals.goal", (exec, info) => mission.goals.Add(LoadGoal(info)), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.missionStart", (exec, info) =>
            {
                var function = info.Content ?? throw new FormatException("missionStart with no mission function!");
                var val      = info.Attributes.GetInt("val", 1);
                if (info.Attributes.GetBool("suppress", Settings.IsInExtensionMode))
                {
                    mission.addStartFunction(val, function);
                }
                else
                {
                    MissionFunctions.runCommand(val, function);
                }
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.missionEnd", (exec, info) =>
            {
                mission.addEndFunction(info.Attributes.GetInt("val", 1), info.Content ?? throw new FormatException("missionEnd with no mission function!"));
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.nextMission", (exec, info) =>
            {
                mission.willSendEmail = !info.Attributes.GetBool("IsSilent", false);
                mission.nextMission   = info.Content ?? "NONE";
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.branchMissions.branch", (exec, info) =>
            {
                var filePrefix      = Settings.IsInExtensionMode ? ExtensionLoader.ActiveExtensionInfo.FolderPath + "/" : "Content/Missions/";
                var currentMission  = mission;
                var currentBranches = branches;
                mission             = null;
                branches            = null;
                exec.SaveState();
                currentBranches.Add(LoadContentMission(filePrefix + info.Content));
                exec.PopState();
                mission  = currentMission;
                branches = currentBranches;
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.branchMissions", (exec, info) => OS.currentInstance.branchMissions = branches, ParseOption.FireOnEnd);
            executor.RegisterExecutor("mission.posting", (exec, info) =>
            {
                mission.postingTitle = info.Attributes.GetString("title", "UNKNOWN").Filter();
                mission.postingBody  = info.Content ?? "UNKNOWN";
                mission.postingAcceptFlagRequirements = info.Attributes.GetString("reqs").Split(Utils.commaDelim, StringSplitOptions.RemoveEmptyEntries);
                mission.requiredRank = info.Attributes.GetInt("requiredRank");
                mission.difficulty   = info.Attributes.GetInt("difficulty");
                mission.client       = info.Attributes.GetString("client").Filter();
                mission.target       = info.Attributes.GetString("target").Filter();
            }, ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.sender", (exec, info) => mission.email.sender   = info.Content.Filter(), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.subject", (exec, info) => mission.email.subject = info.Content.Filter(), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.body", (exec, info) => mission.email.body       = info.Content.Filter(), ParseOption.ParseInterior);
            executor.RegisterExecutor("mission.email.attachments.link", (exec, info) =>
            {
                var comp = ComputerLookup.FindById(info.Attributes.GetString("comp"));
                if (comp != null)
                {
                    mission.email.attachments.Add($"link#%#{comp.name}#%#{comp.ip}");
                }
            });
            executor.RegisterExecutor("mission.email.attachments.account", (exec, info) =>
            {
                var comp = info.Attributes.GetComp("comp");
                mission.email.attachments.Add(
                    $"account#%#{comp.name}#%#{comp.ip}#%#{info.Attributes.GetString("user", "UNKNOWN").Filter()}#%#{info.Attributes.GetString("pass", "UNKNOWN").Filter()}"
                    );
            });
            executor.RegisterExecutor("mission.email.attachments.note", (exec, info) =>
            {
                mission.email.attachments.Add($"note#%#{info.Attributes.GetString("title", "Data").Filter()}#%#{info.Content.Filter()}");
            }, ParseOption.ParseInterior);
        }
Ejemplo n.º 16
0
 internal static void OnAircraftDaemonChangeIP()
 {
     ComputerLookup.RebuildLookups();
 }
Ejemplo n.º 17
0
        public static Computer LoadComputer(string filename, bool preventAddingToNetmap = false, bool preventInitDaemons = false)
        {
            filename = LocalizedFileLoader.GetLocalizedFilepath(filename);

            os = OS.currentInstance;

            executor.SetText(filename, true);

            holder = new ComputerHolder();

            foreach (var custom in CustomExecutors)
            {
                var customInstance = (ComputerExecutor)Activator.CreateInstance(custom.ExecutorType);
                customInstance.Init(os, ref holder);
                executor.RegisterTempExecutor(custom.Element, customInstance.Execute, custom.Options);
            }

            foreach (var customDaemon in DaemonManager.CustomDaemons)
            {
                executor.RegisterTempExecutor("Computer." + customDaemon.Name, (exec, info) =>
                {
                    DaemonManager.TryLoadCustomDaemon(info, comp, os);
                });
            }

            ReplacementsCommon.isPathfinderComputer = true;
            if (!executor.TryParse(out var ex))
            {
                ReplacementsCommon.isPathfinderComputer = false;
                throw new FormatException($"{filename}: {ex.Message}", ex);
            }
            ReplacementsCommon.isPathfinderComputer = false;

            var ret = comp;

            comp = null;

            if (ret == null)
            {
                return(null);
            }

            if (!ComputerExtensions.HasInitializedPorts(ret))
            {
                PortManager.LoadPortsFromChildren(ret, ReplacementsCommon.defaultPorts, false);
            }

            if (!preventInitDaemons)
            {
                ret.initDaemons();
            }
            if (!preventAddingToNetmap)
            {
                os.netMap.nodes.Add(ret);
                if (eos != null)
                {
                    eos.links.Add(os.netMap.nodes.Count - 1);
                    ComputerLookup.Add(eos);
                }
                ComputerLookup.Add(ret);
            }

            os     = null;
            eos    = null;
            holder = null;

            return(ret);
        }
Ejemplo n.º 18
0
        public static Computer LoadComputer(ElementInfo info, OS os)
        {
            var name = info.Attributes.GetString("name");
            var ip   = info.Attributes.GetString("ip");
            var type = info.Attributes.GetByte("type");
            var spec = info.Attributes.GetString("spec");

            var location = info.Children.GetElement("location");

            var security = info.Children.GetElement("security");
            var level    = security.Attributes.GetInt("level");

            Firewall firewall = null;

            if (info.Children.TryGetElement("firewall", out var firewallInfo))
            {
                firewall = new Firewall(
                    firewallInfo.Attributes.GetInt("complexity"),
                    firewallInfo.Attributes.GetString("solution", null),
                    firewallInfo.Attributes.GetFloat("additionalDelay")
                    );
            }

            ReplacementsCommon.isPathfinderComputer = true;
            var comp = new Computer(name, ip, location.Attributes.GetVector("x", "y", Vector2.Zero).Value, level, type, os)
            {
                idName             = info.Attributes.GetString("id"),
                attatchedDeviceIDs = info.Attributes.GetString("devices", null),
                icon                = info.Attributes.GetString("icon", null),
                HasTracker          = info.Attributes.GetBool("tracker"),
                firewall            = firewall,
                traceTime           = security.Attributes.GetFloat("traceTime"),
                portsNeededForCrack = security.Attributes.GetInt("portsToCrack"),
                adminIP             = security.Attributes.GetString("adminIP")
            };

            ReplacementsCommon.isPathfinderComputer = false;

            var proxyTime = security.Attributes.GetFloat("proxyTime");

            if (proxyTime > 0)
            {
                comp.addProxy(proxyTime);
            }
            else
            {
                comp.hasProxy    = false;
                comp.proxyActive = false;
            }

            if (info.Children.TryGetElement("admin", out var adminInfo))
            {
                Administrator.AdministratorManager.LoadAdministrator(adminInfo, comp, os);
            }

            foreach (var link in info.Children.GetElement("links").Content?
                     .Split((char[])null, StringSplitOptions.RemoveEmptyEntries) ?? new string[0])
            {
                comp.links.Add(int.Parse(link));
            }

            if (info.Children.TryGetElement("portsOpen", out var portsOpen))
            {
                PortManager.LoadPortsFromStringVanilla(comp, portsOpen.Content);
            }

            if (info.Children.TryGetElement("portRemap", out var remap))
            {
                PortManager.LoadPortRemapsFromStringVanilla(comp, remap.Content);
            }

            if (info.Children.TryGetElement("ports", out var ports))
            {
                if (ports.Content != null)
                {
                    foreach (var port in ports.Content.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        var parts       = port.Split(':');
                        var record      = PortManager.GetPortRecordFromProtocol(parts[0]);
                        var displayName = parts[3].Replace('_', ' ');
                        var portNum     = int.Parse(parts[2]);
                        if (record == null)
                        {
                            PortManager.RegisterPort(record = new PortRecord(
                                                         parts[0],
                                                         displayName,
                                                         portNum,
                                                         int.Parse(parts[1])
                                                         ));
                        }

                        comp.AddPort(record.CreateState(
                                         comp,
                                         displayName,
                                         portNum
                                         ));
                    }
                }

                foreach (var port in ports.Children)
                {
                    var record      = PortManager.GetPortRecordFromProtocol(port.Name);
                    var displayName = port.Children.GetElement("Display").Content;
                    var portNum     = int.Parse(port.Children.GetElement("Number").Content);
                    if (record == null)
                    {
                        PortManager.RegisterPort(record = new PortRecord(
                                                     port.Name,
                                                     displayName,
                                                     portNum,
                                                     int.Parse(port.Children.GetElement("Original").Content)
                                                     ));
                    }
                    comp.AddPort(record.CreateState(
                                     comp,
                                     displayName,
                                     portNum
                                     ));
                }
            }

            comp.users.Clear();
            if (info.Children.TryGetElement("users", out var users))
            {
                foreach (var user in users.Children.Where(x => x.Name == "user"))
                {
                    var username = user.Attributes.GetString("name");
                    var pass     = user.Attributes.GetString("pass");

                    var userDetail = new UserDetail(
                        username,
                        pass,
                        user.Attributes.GetByte("type")
                        )
                    {
                        known = user.Attributes.GetBool("known")
                    };

                    if (username.ToLower() == "admin")
                    {
                        comp.adminPass = pass;
                    }

                    comp.users.Add(userDetail);
                }
            }

            if (info.Children.TryGetElement("Memory", out var memory))
            {
                comp.Memory = ReplacementsCommon.LoadMemoryContents(memory);
            }

            #region Daemons

            if (info.Children.TryGetElement("daemons", out var daemons))
            {
                foreach (var daemon in daemons.Children)
                {
                    if (Daemon.DaemonManager.TryLoadCustomDaemon(daemon, comp, os))
                    {
                        continue;
                    }

                    switch (daemon.Name)
                    {
                    case "MailServer":
                        var mailserver = new MailServer(comp, daemon.Attributes.GetString("name"), os);
                        if (daemon.Attributes.TryGetValue("color", out var mail_color))
                        {
                            mailserver.setThemeColor(Utils.convertStringToColor(mail_color));
                        }

                        comp.daemons.Add(mailserver);
                        break;

                    case "MissionListingServer":
                        var listing_name       = daemon.Attributes.GetString("name");
                        var listing_group      = daemon.Attributes.GetString("group");
                        var listing_isPublic   = daemon.Attributes.GetBool("public");
                        var listing_isAssigner = daemon.Attributes.GetBool("assign");
                        var listing_articles   = daemon.Attributes.GetString("articles");

                        MissionListingServer listingserver;
                        if (daemon.Attributes.TryGetValue("icon", out var listing_icon) &&
                            daemon.Attributes.TryGetValue("color", out var listing_color))
                        {
                            listingserver = new MissionListingServer(comp, listing_name, listing_icon,
                                                                     listing_articles,
                                                                     Utils.convertStringToColor(listing_color), os, listing_isPublic,
                                                                     listing_isAssigner);
                        }
                        else
                        {
                            listingserver = new MissionListingServer(comp, name, listing_group, os,
                                                                     listing_isPublic, listing_isAssigner);
                        }

                        comp.daemons.Add(listingserver);
                        break;

                    case "AddEmailServer":
                        comp.daemons.Add(new AddEmailDaemon(comp, daemon.Attributes.GetString("name"), os));
                        break;

                    case "MessageBoard":
                        var messageboard = new MessageBoardDaemon(comp, os);
                        messageboard.name      = daemon.Attributes.GetString("name");
                        messageboard.BoardName =
                            daemon.Attributes.GetString("boardName", messageboard.BoardName);
                        comp.daemons.Add(messageboard);
                        break;

                    case "WebServer":
                        comp.daemons.Add(new WebServerDaemon(
                                             comp,
                                             daemon.Attributes.GetString("name"),
                                             os,
                                             daemon.Attributes.GetString("url")
                                             ));
                        break;

                    case "OnlineWebServer":
                        var onlinewebserver =
                            new OnlineWebServerDaemon(comp, daemon.Attributes.GetString("name"), os);
                        onlinewebserver.setURL(daemon.Attributes.GetString("url"));
                        comp.daemons.Add(onlinewebserver);
                        break;

                    case "AcademicDatabse":
                        comp.daemons.Add(new AcademicDatabaseDaemon(
                                             comp,
                                             daemon.Attributes.GetString("name"),
                                             os
                                             ));
                        break;

                    case "MissionHubServer":
                        comp.daemons.Add(new MissionHubServer(comp, "unknown", "unknown", os));
                        break;

                    case "DeathRowDatabase":
                        comp.daemons.Add(new DeathRowDatabaseDaemon(comp, "Death Row Database", os));
                        break;

                    case "MedicalDatabase":
                        comp.daemons.Add(new MedicalDatabaseDaemon(comp, os));
                        break;

                    case "HeartMonitor":
                        var heartmon = new HeartMonitorDaemon(comp, os);
                        heartmon.PatientID = daemon.Attributes.GetString("patient", "UNKNOWN");
                        comp.daemons.Add(heartmon);
                        break;

                    case "PointClicker":
                        comp.daemons.Add(new PointClickerDaemon(comp, "Point Clicker!", os));
                        break;

                    case "ispSystem":
                        comp.daemons.Add(new ISPDaemon(comp, os));
                        break;

                    case "porthackheart":
                        comp.daemons.Add(new PorthackHeartDaemon(comp, os));
                        break;

                    case "SongChangerDaemon":
                        comp.daemons.Add(new SongChangerDaemon(comp, os));
                        break;

                    case "UploadServerDaemon":
                        var uploadserver = new UploadServerDaemon(
                            comp,
                            daemon.Attributes.GetString("name"),
                            daemon.Attributes.GetColor("color", Color.White).Value,
                            os,
                            daemon.Attributes.GetString("foldername"),
                            daemon.Attributes.GetBool("needsAuh")
                            );
                        uploadserver.hasReturnViewButton = daemon.Attributes.GetBool("hasReturnViewButton");
                        comp.daemons.Add(uploadserver);
                        break;

                    case "DHSDaemon":
                        comp.daemons.Add(new DLCHubServer(comp, "unknown", "unknown", os));
                        break;

                    case "CustomConnectDisplayDaemon":
                        comp.daemons.Add(new CustomConnectDisplayDaemon(comp, os));
                        break;

                    case "DatabaseDaemon":
                        var databaseserver = new DatabaseDaemon(
                            comp,
                            os,
                            daemon.Attributes.GetString("Name", null),
                            daemon.Attributes.GetString("Permissions"),
                            daemon.Attributes.GetString("DataType"),
                            daemon.Attributes.GetString("Foldername"),
                            daemon.Attributes.GetColor("Color")
                            );
                        databaseserver.adminResetEmailHostID      = daemon.Attributes.GetString("AdminEmailHostID", null);
                        databaseserver.adminResetPassEmailAccount = daemon.Attributes.GetString("AdminEmailAccount", null);
                        comp.daemons.Add(databaseserver);
                        break;

                    case "WhitelistAuthenticatorDaemon":
                        var whitelistserver = new WhitelistConnectionDaemon(comp, os);
                        whitelistserver.AuthenticatesItself = daemon.Attributes.GetBool("SelfAuthenticating", true);
                        comp.daemons.Add(whitelistserver);
                        break;

                    case "IRCDaemon":
                        comp.daemons.Add(new IRCDaemon(comp, os, "LOAD ERROR"));
                        break;

                    case "MarkovTextDaemon":
                        comp.daemons.Add(new MarkovTextDaemon(
                                             comp,
                                             os,
                                             daemon.Attributes.GetString("Name", null),
                                             daemon.Attributes.GetString("SourceFilesContentFolder", null)
                                             ));
                        break;

                    case "AircraftDaemon":
                        comp.daemons.Add(new AircraftDaemon(
                                             comp,
                                             os,
                                             daemon.Attributes.GetString("Name", "Pacific Charter Flight"),
                                             daemon.Attributes.GetVector("OriginX", "OriginY", Vector2.Zero).Value,
                                             daemon.Attributes.GetVector("DestX", "DestY", Vector2.One * 0.5f).Value,
                                             daemon.Attributes.GetFloat("Progress")
                                             ));
                        break;

                    case "LogoCustomConnectDisplayDaemon":
                        comp.daemons.Add(new LogoCustomConnectDisplayDaemon(
                                             comp,
                                             os,
                                             daemon.Attributes.GetString("logo", null),
                                             daemon.Attributes.GetString("title", null),
                                             daemon.Attributes.GetBool("overdrawLogo"),
                                             daemon.Attributes.GetString("buttonAlignment", null)
                                             ));
                        break;

                    case "LogoDaemon":
                        comp.daemons.Add(new LogoDaemon(
                                             comp,
                                             os,
                                             name,
                                             daemon.Attributes.GetBool("ShowsTitle", true),
                                             daemon.Attributes.GetString("LogoImagePath")
                                             )
                        {
                            TextColor = daemon.Attributes.GetColor("TextColor", Color.White).Value
                        });
                        break;

                    case "DLCCredits":
                        DLCCreditsDaemon dlcdaemon = null;
                        string           credits_title, credits_button = null;
                        if (daemon.Attributes.TryGetValue("Title", out credits_title) ||
                            daemon.Attributes.TryGetValue("Button", out credits_button))
                        {
                            dlcdaemon = new DLCCreditsDaemon(comp, os, credits_title, credits_button);
                        }
                        else
                        {
                            dlcdaemon = new DLCCreditsDaemon(comp, os);
                        }
                        dlcdaemon.ConditionalActionsToLoadOnButtonPress = daemon.Attributes.GetString("Action", null);
                        comp.daemons.Add(dlcdaemon);
                        break;

                    case "FastActionHost":
                        comp.daemons.Add(new FastActionHost(comp, os, name));
                        break;
                    }
                }
            }

            #endregion

            comp.files = new FileSystem(true)
            {
                root = LoadFolder(info.Children.GetElement("filesystem").Children.GetElement("folder"))
            };

            switch (spec)
            {
            case "player":
                os.thisComputer = comp;
                break;

            case "mail":
                os.netMap.mailServer = comp;
                break;
            }

            if (EventManager <SaveComputerLoadedEvent> .InvokeAll(new SaveComputerLoadedEvent(os, comp, info)).Cancelled)
            {
                return(null);
            }

            ComputerLookup.Add(comp);
            return(comp);
        }
Ejemplo n.º 19
0
 internal static void RebuildOnEndLoad(OS __instance)
 {
     ComputerLookup.RebuildLookups();
 }
Ejemplo n.º 20
0
        private static MisisonGoal LoadGoal(ElementInfo info)
        {
            var type = info.Attributes.GetString("type").ToLower();

            var os = OS.currentInstance;

            if (GoalManager.TryLoadCustomGoal(type, out var customGoal))
            {
                if (customGoal is PathfinderGoal pfGoal)
                {
                    pfGoal.LoadFromXML(info);
                }
                return(customGoal);
            }

            switch (type)
            {
            case "filedeletion":
                var compName = info.Attributes.GetString("target").Filter();
                return(new FileDeletionMission(
                           info.Attributes.GetString("path").Filter(),
                           info.Attributes.GetString("file").Filter(),
                           ComputerLookup.FindById(compName)?.ip ?? compName,
                           os
                           ));

            case "clearfolder":
                return(new FileDeleteAllMission(
                           info.Attributes.GetString("path").Filter(),
                           info.Attributes.GetComp("target").ip,
                           os
                           ));

            case "filedownload":
                return(new FileDownloadMission(
                           info.Attributes.GetString("path").Filter(),
                           info.Attributes.GetString("file").Filter(),
                           info.Attributes.GetComp("target").ip,
                           os
                           ));

            case "filechange":
                return(new FileChangeMission(
                           info.Attributes.GetString("path").Filter(),
                           info.Attributes.GetString("file").Filter(),
                           info.Attributes.GetComp("target").ip,
                           info.Attributes.GetString("keyword").Filter(),
                           os,
                           info.Attributes.GetBool("removal")
                           )
                {
                    caseSensitive = info.Attributes.GetBool("filechange")
                });

            case "getadmin":
                return(new GetAdminMission(info.Attributes.GetComp("target").ip, os));

            case "getstring":
                return(new GetStringMission(info.Attributes.GetString("target").Filter()));

            case "delay":
                return(new DelayMission(info.Attributes.GetFloat("time", 1f)));

            case "hasflag":
                return(new CheckFlagSetMission(info.Attributes.GetString("target").Filter(), os));

            case "fileupload":
                return(new FileUploadMission(
                           info.Attributes.GetString("path").Filter(),
                           info.Attributes.GetString("file").Filter(),
                           info.Attributes.GetComp("target").ip,
                           info.Attributes.GetComp("destTarget").ip,
                           info.Attributes.GetString("destPath").Filter(),
                           os,
                           info.Attributes.GetBool("decrypt"),
                           info.Attributes.GetString("decryptPass").Filter()
                           ));

            case "adddegree":
                return(new AddDegreeMission(
                           info.Attributes.GetString("owner").Filter(),
                           info.Attributes.GetString("degree").Filter(),
                           info.Attributes.GetString("uni").Filter(),
                           info.Attributes.GetFloat("gpa", -1f),
                           os
                           ));

            case "wipedegrees":
                return(new WipeDegreesMission(info.Attributes.GetString("owner").Filter(), os));

            case "removedeathrowrecord":
                return(new DeathRowRecordRemovalMission(
                           info.Attributes.GetString("fname", info.Attributes.GetString("name").Split(' ')[0]),
                           info.Attributes.GetString("lname", info.Attributes.GetString("name").Split(' ')[1]),
                           os
                           ));

            case "modifydeathrowrecord":
                return(new DeathRowRecordModifyMission(
                           info.Attributes.GetString("fname", info.Attributes.GetString("name").Split(' ')[0]),
                           info.Attributes.GetString("lname", info.Attributes.GetString("name").Split(' ')[1]),
                           info.Content,
                           os
                           ));

            case "sendemail":
                return(new SendEmailMission(
                           info.Attributes.GetString("mailServer", "jmail").Filter(),
                           info.Attributes.GetString("recipient").Filter(),
                           info.Attributes.GetString("subject").Filter(),
                           os
                           ));

            case "databaseentrychange":
                return(new DatabaseEntryChangeMission(
                           info.Attributes.GetComp("comp").ip,
                           os,
                           info.Attributes.GetString("operation").Filter(),
                           info.Attributes.GetString("fieldName").Filter(),
                           info.Attributes.GetString("targetValue").Filter(),
                           info.Attributes.GetString("recordName").Filter()
                           ));

            case "getadminpasswordstring":
                return(new GetAdminPasswordStringMission(info.Attributes.GetComp("target").ip, os));

            default:
                throw new KeyNotFoundException("Unknown goal type");
            }
        }