Exemple #1
0
        public static void ReloadExtensionNodes(object osobj)
        {
            OS            os = (OS)osobj;
            ExtensionInfo activeExtensionInfo = ExtensionLoader.ActiveExtensionInfo;

            if (!Directory.Exists(activeExtensionInfo.FolderPath + "/Nodes"))
            {
                return;
            }
            Utils.ActOnAllFilesRevursivley(activeExtensionInfo.FolderPath + "/Nodes", (Action <string>)(filename =>
            {
                if (!filename.EndsWith(".xml"))
                {
                    return;
                }
                if (OS.TestingPassOnly)
                {
                    try
                    {
                        Computer c = Computer.loadFromFile(filename);
                        if (c != null)
                        {
                            ExtensionLoader.CheckAndAssignCoreServer(c, os);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw new FormatException(string.Format("COMPUTER LOAD ERROR:\nError loading computer \"{0}\"\nError: {1} - {2}", (object)filename, (object)ex.GetType().Name, (object)ex.Message), ex);
                    }
                }
                else
                {
                    Computer c = (Computer)ComputerLoader.loadComputer(filename, true, false);
                    for (int index = 0; index < os.netMap.nodes.Count; ++index)
                    {
                        Computer node = os.netMap.nodes[index];
                        if (node.idName == c.idName)
                        {
                            c.location             = node.location;
                            c.adminIP              = node.adminIP;
                            c.ip                   = node.ip;
                            c.highlightFlashTime   = 1f;
                            os.netMap.nodes[index] = c;
                            break;
                        }
                    }
                    if (c != null)
                    {
                        ExtensionLoader.CheckAndAssignCoreServer(c, os);
                    }
                }
            }));
        }
Exemple #2
0
        public static void LoadNewExtensionSession(ExtensionInfo info, object os_obj)
        {
            LocaleActivator.ActivateLocale(info.Language, Game1.getSingleton().Content);
            OS os = (OS)os_obj;

            People.ReInitPeopleForExtension();
            if (Directory.Exists(info.FolderPath + "/Nodes"))
            {
                Utils.ActOnAllFilesRevursivley(info.FolderPath + "/Nodes", (Action <string>)(filename =>
                {
                    if (!filename.EndsWith(".xml"))
                    {
                        return;
                    }
                    if (OS.TestingPassOnly)
                    {
                        try
                        {
                            Computer c = Computer.loadFromFile(filename);
                            if (c != null)
                            {
                                ExtensionLoader.CheckAndAssignCoreServer(c, os);
                            }
                        }
                        catch (Exception ex)
                        {
                            string format       = "COMPUTER LOAD ERROR:\nError loading computer \"{0}\"";
                            Exception exception = ex;
                            string message      = string.Format(format, (object)filename);
                            for (; exception != null; exception = exception.InnerException)
                            {
                                string str = string.Format("\r\nError: {0} - {1}", (object)exception.GetType().Name, (object)exception.Message);
                                message   += str;
                            }
                            throw new FormatException(message, ex);
                        }
                    }
                    else
                    {
                        Computer c = Computer.loadFromFile(filename);
                        if (c != null)
                        {
                            ExtensionLoader.CheckAndAssignCoreServer(c, os);
                        }
                    }
                }));
            }
            if (ComputerLoader.postAllLoadedActions != null)
            {
                ComputerLoader.postAllLoadedActions();
            }
            if (Programs.getComputer(os, "jmail") == null)
            {
                Computer c = new Computer("JMail Email Server", NetworkMap.generateRandomIP(), new Vector2(0.8f, 0.2f), 6, (byte)1, os);
                c.idName = "jmail";
                c.daemons.Add((Daemon) new MailServer(c, "JMail", os));
                MailServer.shouldGenerateJunk = false;
                c.users.Add(new UserDetail(os.defaultUser.name, "mailpassword", (byte)2));
                c.initDaemons();
                os.netMap.mailServer = c;
                os.netMap.nodes.Add(c);
            }
            for (int index = 0; index < info.StartingVisibleNodes.Length; ++index)
            {
                Computer computer = Programs.getComputer(os, info.StartingVisibleNodes[index]);
                if (computer != null)
                {
                    os.netMap.discoverNode(computer);
                }
            }
            for (int index = 0; index < info.FactionDescriptorPaths.Count; ++index)
            {
                string path = info.FolderPath + "/" + info.FactionDescriptorPaths[index];
                using (FileStream fileStream = File.OpenRead(path))
                {
                    try
                    {
                        Faction faction = Faction.loadFromSave(XmlReader.Create((Stream)fileStream));
                        os.allFactions.factions.Add(faction.idName, faction);
                    }
                    catch (Exception ex)
                    {
                        throw new FormatException("Error loading Faction: " + path, ex);
                    }
                }
            }
            OSTheme theme = OSTheme.Custom;
            bool    flag  = false;

            foreach (object obj in Enum.GetValues(typeof(OSTheme)))
            {
                if (obj.ToString().ToLower() == info.Theme)
                {
                    theme = (OSTheme)obj;
                    flag  = true;
                }
            }
            if (!flag)
            {
                if (File.Exists(info.FolderPath + "/" + info.Theme))
                {
                    ThemeManager.setThemeOnComputer((object)os.thisComputer, info.Theme);
                    ThemeManager.switchTheme((object)os, info.Theme);
                }
            }
            else
            {
                ThemeManager.setThemeOnComputer((object)os.thisComputer, theme);
                ThemeManager.switchTheme((object)os, theme);
            }
            ExtensionLoader.LoadExtensionStartTrackAsCurrentSong(info);
            if (info.StartingActionsPath != null)
            {
                RunnableConditionalActions.LoadIntoOS(info.StartingActionsPath, (object)os);
            }
            if (info.StartingMissionPath == null || info.StartsWithTutorial || info.HasIntroStartup)
            {
                return;
            }
            ExtensionLoader.SendStartingEmailForActiveExtensionNextFrame((object)os);
        }