Ejemplo n.º 1
0
 public static Faction loadFromSave(XmlReader xmlRdr)
 {
     var _name = "UNKNOWN";
     var str = "";
     var flag = false;
     var _neededValue = 100;
     var num = 0;
     while (xmlRdr.Name != "Faction" && xmlRdr.Name != "EntropyFaction" && xmlRdr.Name != "HubFaction")
         xmlRdr.Read();
     var name = xmlRdr.Name;
     if (xmlRdr.MoveToAttribute("name"))
         _name = xmlRdr.ReadContentAsString();
     if (xmlRdr.MoveToAttribute("id"))
         str = xmlRdr.ReadContentAsString();
     if (xmlRdr.MoveToAttribute("neededVal"))
         _neededValue = xmlRdr.ReadContentAsInt();
     if (xmlRdr.MoveToAttribute("playerVal"))
         num = xmlRdr.ReadContentAsInt();
     if (xmlRdr.MoveToAttribute("playerHasPassed"))
         flag = xmlRdr.ReadContentAsString().ToLower() == "true";
     Faction faction;
     switch (name)
     {
         case "HubFaction":
             faction = new HubFaction(_name, _neededValue);
             break;
         case "EntropyFaction":
             faction = new EntropyFaction(_name, _neededValue);
             break;
         default:
             faction = new Faction(_name, _neededValue);
             break;
     }
     faction.playerValue = num;
     faction.idName = str;
     faction.playerHasPassedValue = flag;
     return faction;
 }
Ejemplo n.º 2
0
 public override void LoadContent()
 {
     if (canRunContent)
     {
         delayer = new ActionDelayer();
         ComputerLoader.init(this);
         content = ScreenManager.Game.Content;
         username = SaveUserAccountName == null
             ? (Settings.isConventionDemo ? Settings.ConventionLoginName : Environment.UserName)
             : SaveUserAccountName;
         username = FileSanitiser.purifyStringForDisplay(username);
         var compLocation = new Vector2(0.1f, 0.5f);
         if (multiplayer && !isServer)
             compLocation = new Vector2(0.8f, 0.8f);
         ramAvaliable = totalRam;
         var str = !multiplayer || !isServer ? NetworkMap.generateRandomIP() : NetworkMap.generateRandomIP();
         thisComputer = new Computer(username + " PC", NetworkMap.generateRandomIP(), compLocation, 5, 4, this);
         thisComputer.adminIP = thisComputer.ip;
         thisComputer.idName = "playerComp";
         var folder = thisComputer.files.root.searchForFolder("home");
         folder.folders.Add(new Folder("stash"));
         folder.folders.Add(new Folder("misc"));
         var userDetail = thisComputer.users[0];
         userDetail.known = true;
         thisComputer.users[0] = userDetail;
         defaultUser = new UserDetail(username, "password", 1);
         defaultUser.known = true;
         var theme = OSTheme.HacknetBlue;
         if (Settings.isConventionDemo)
         {
             var num = Utils.random.NextDouble();
             if (num < 0.33)
                 theme = OSTheme.HacknetMint;
             else if (num < 0.66)
                 theme = OSTheme.HackerGreen;
         }
         ThemeManager.setThemeOnComputer(thisComputer, theme);
         if (multiplayer)
         {
             thisComputer.addMultiplayerTargetFile();
             sendMessage("newComp #" + thisComputer.ip + "#" + compLocation.X + "#" + compLocation.Y +
                         "#" + 5 + "#" + thisComputer.name);
             multiplayerMissionLoaded = false;
         }
         if (!WillLoadSave)
             People.init();
         modules = new List<Module>();
         exes = new List<ExeModule>();
         shells = new List<ShellExe>();
         shellIPs = new List<string>();
         var viewport = ScreenManager.GraphicsDevice.Viewport;
         var width1 = RamModule.MODULE_WIDTH;
         var height1 = 205;
         var width2 = (int) ((viewport.Width - width1 - 6)*0.4442);
         var num1 = (int) ((viewport.Width - width1 - 6)*0.5558);
         var height2 = viewport.Height - height1 - TOP_BAR_HEIGHT - 6;
         terminal =
             new Terminal(
                 new Rectangle(viewport.Width - 2 - width2, TOP_BAR_HEIGHT, width2,
                     viewport.Height - TOP_BAR_HEIGHT - 2), this);
         terminal.name = "TERMINAL";
         modules.Add(terminal);
         netMap = new NetworkMap(new Rectangle(width1 + 4, viewport.Height - height1 - 2, num1 - 1, height1),
             this);
         netMap.name = "netMap v1.7";
         modules.Add(netMap);
         display = new DisplayModule(new Rectangle(width1 + 4, TOP_BAR_HEIGHT, num1 - 2, height2), this);
         display.name = "DISPLAY";
         modules.Add(display);
         ram =
             new RamModule(
                 new Rectangle(2, TOP_BAR_HEIGHT, width1, ramAvaliable + RamModule.contentStartOffset), this);
         ram.name = "RAM";
         modules.Add(ram);
         for (var index = 0; index < modules.Count; ++index)
             modules[index].LoadContent();
         for (var index = 0; index < 2; ++index)
         {
             if (isServer || !multiplayer)
                 thisComputer.links.Add(index);
             else
                 thisComputer.links.Add(netMap.nodes.Count - 1 - index);
         }
         var flag1 = false;
         if (!WillLoadSave)
         {
             netMap.nodes.Insert(0, thisComputer);
             netMap.visibleNodes.Add(0);
             MusicManager.loadAsCurrentSong("Music\\Revolve");
         }
         else
         {
             loadSaveFile();
             flag1 = true;
             Settings.initShowsTutorial = false;
         }
         if (!multiplayer && !flag1)
         {
             MailServer.shouldGenerateJunk = false;
             netMap.mailServer.addNewUser(thisComputer.ip, defaultUser);
         }
         mailicon = new MailIcon(this, new Vector2(0.0f, 0.0f));
         mailicon.pos.X = viewport.Width - mailicon.getWidth() - 2;
         topBar = new Rectangle(0, 0, viewport.Width, TOP_BAR_HEIGHT - 1);
         crashModule =
             new CrashModule(
                 new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width,
                     ScreenManager.GraphicsDevice.Viewport.Height), this);
         crashModule.LoadContent();
         introTextModule =
             new IntroTextModule(
                 new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width,
                     ScreenManager.GraphicsDevice.Viewport.Height), this);
         introTextModule.LoadContent();
         traceTracker = new TraceTracker(this);
         IncConnectionOverlay = new IncomingConnectionOverlay(this);
         if (allFactions == null)
         {
             allFactions = new AllFactions();
             allFactions.init();
         }
         currentFaction = allFactions.factions[allFactions.currentFaction];
         scanLines = content.Load<Texture2D>("ScanLines");
         cross = content.Load<Texture2D>("Cross");
         cog = content.Load<Texture2D>("Cog");
         saveIcon = content.Load<Texture2D>("SaveIcon");
         beepSound = content.Load<SoundEffect>("SFX/beep");
         if (!multiplayer & !flag1)
             loadMissionNodes();
         if (!flag1)
             MusicManager.playSong();
         if (flag1 || !Settings.slowOSStartup)
         {
             initShowsTutorial = false;
             introTextModule.complete = true;
         }
         inputEnabled = true;
         isLoaded = true;
         fullscreen = new Rectangle(0, 0, ScreenManager.GraphicsDevice.Viewport.Width,
             ScreenManager.GraphicsDevice.Viewport.Height);
         TraceDangerSequence = new TraceDangerSequence(content, ScreenManager.SpriteBatch, fullscreen, this);
         endingSequence = new EndingSequenceModule(fullscreen, this);
         var flag2 = Settings.slowOSStartup && !flag1;
         var flag3 = Settings.osStartsWithTutorial && (!flag1 || !Flags.HasFlag("TutorialComplete"));
         if (flag2)
         {
             rebootThisComputer();
             if (!Settings.initShowsTutorial)
                 return;
             display.visible = false;
             ram.visible = false;
             netMap.visible = false;
             terminal.visible = true;
         }
         else if (flag3)
         {
             display.visible = false;
             ram.visible = false;
             netMap.visible = false;
             terminal.visible = true;
             terminal.reset();
             Settings.initShowsTutorial = true;
             initShowsTutorial = true;
             if (TestingPassOnly)
                 return;
             execute("FirstTimeInitdswhupwnemfdsiuoewnmdsmffdjsklanfeebfjkalnbmsdakj Init");
         }
         else
         {
             if (!TestingPassOnly)
                 runCommand("connect " + thisComputer.ip);
             if (thisComputer.files.root.searchForFolder("sys").searchForFile("Notes_Reopener.bat") == null)
                 return;
             runCommand("notes");
         }
     }
     else
     {
         if (!multiplayer)
             return;
         initializeNetwork();
     }
 }