Example #1
0
        public static Vector2 getNearbyNodeOffset(Vector2 basePos, int positionNumber, int total, NetworkMap map, float extraDistance = 0.0f, bool forceUseThisPosition = false)
        {
            int total1 = total;
            int num1   = positionNumber;

            if (total < 20)
            {
                int   num2 = 30;
                float num3 = (float)positionNumber / (float)total;
                total1 = num2;
                num1   = (int)((double)num3 * (double)num2);
            }
            int num4 = 300;

            for (int index = 0; index < num4; ++index)
            {
                Vector2 positionFromCycle = Corporation.GetOffsetPositionFromCycle(num1 + index, total1, extraDistance);
                if (Corporation.GeneratedPositionIsValid(positionFromCycle + basePos, map, forceUseThisPosition))
                {
                    return(positionFromCycle);
                }
                Corporation.TestedPositions.Add(positionFromCycle + basePos);
            }
            return(map.getRandomPosition() - basePos);
        }
Example #2
0
        public List <Computer> generateGameNodes()
        {
            var list      = new List <Computer>();
            var computer1 = (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/JMailServer.xml");

            computer1.location = new Vector2(0.7f, 0.2f);
            mailServer         = computer1;
            list.Add(computer1);
            var c1 = new Computer("boatmail.com", "65.55.72.183", new Vector2(0.6f, 0.9f), 4, 3, os);

            c1.idName = "boatmail";
            c1.daemons.Add(new BoatMail(c1, "Boatmail", os));
            c1.initDaemons();
            list.Add(c1);
            var c2 =
                (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/InternationalAcademicDatabase.xml");
            var academicDatabaseDaemon = new AcademicDatabaseDaemon(c2, "Academic Databse", os);

            c2.daemons.Add(academicDatabaseDaemon);
            c2.initDaemons();
            academicDatabaseDaemon.initFilesFromPeople(People.all);
            academicDatabase = c2;
            list.Add(c2);
            var computer2 =
                (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/ContractHubAssetsComp.xml");

            list.Add(computer2);
            var ch = (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/ContractHubComp.xml");

            os.delayer.Post(ActionDelayer.NextTick(), () =>
            {
                ch.daemons.Add(new MissionHubServer(ch, "CSEC Contract Database", "CSEC", os));
                ch.initDaemons();
            });
            list.Add(ch);
            computer2.location = ch.location + Corporation.getNearbyNodeOffset(ch.location, 1, 1, this);
            list.Add(new Computer("Cheater's Stash", "1337.1337.1337.1337", getRandomPosition(), 0, 2, os)
            {
                idName = "haxServer",
                files  =
                {
                    root      =
                    {
                        files =
                        {
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[0]],
                                          PortExploits.cracks[PortExploits.portNums[0]]),
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[1]],
                                          PortExploits.cracks[PortExploits.portNums[1]]),
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[2]],
                                          PortExploits.cracks[PortExploits.portNums[2]]),
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[3]],
                                          PortExploits.cracks[PortExploits.portNums[3]])
                        }
                    }
                }
            });
            return(list);
        }
Example #3
0
        public List <Computer> generateGameNodes()
        {
            List <Computer> computerList = new List <Computer>();
            Computer        computer1    = (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/JMailServer.xml", false, false);

            computer1.location = new Vector2(0.7f, 0.2f);
            this.mailServer    = computer1;
            computerList.Add(computer1);
            Computer c1 = new Computer("boatmail.com", "65.55.72.183", new Vector2(0.6f, 0.9f), 4, (byte)3, this.os);

            c1.idName = "boatmail";
            c1.daemons.Add((Daemon) new BoatMail(c1, "Boatmail", this.os));
            c1.initDaemons();
            computerList.Add(c1);
            Computer c2 = (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/InternationalAcademicDatabase.xml", false, false);
            AcademicDatabaseDaemon academicDatabaseDaemon = new AcademicDatabaseDaemon(c2, "Academic Database", this.os);

            c2.daemons.Add((Daemon)academicDatabaseDaemon);
            c2.initDaemons();
            this.academicDatabase = c2;
            computerList.Add(c2);
            Computer computer2 = (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/ContractHubAssetsComp.xml", false, false);

            computerList.Add(computer2);
            Computer ch = (Computer)ComputerLoader.loadComputer("Content/Missions/CoreServers/ContractHubComp.xml", false, false);

            this.os.delayer.Post(ActionDelayer.NextTick(), (Action)(() =>
            {
                ch.daemons.Add((Daemon) new MissionHubServer(ch, "CSEC Contract Database", "CSEC", this.os));
                ch.initDaemons();
            }));
            computerList.Add(ch);
            computer2.location = ch.location + Corporation.getNearbyNodeOffset(ch.location, 1, 1, this, 0.0f, false);
            computerList.Add(new Computer("Cheater's Stash", "1337.1337.1337.1337", this.getRandomPosition(), 0, (byte)2, this.os)
            {
                idName = "haxServer",
                files  =
                {
                    root      =
                    {
                        files =
                        {
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[0]], PortExploits.cracks[PortExploits.portNums[0]]),
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[1]], PortExploits.cracks[PortExploits.portNums[1]]),
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[2]], PortExploits.cracks[PortExploits.portNums[2]]),
                            new FileEntry(PortExploits.crackExeData[PortExploits.portNums[3]], PortExploits.cracks[PortExploits.portNums[3]]),
                            this.GetProgramForNum(1433),
                            this.GetProgramForNum(104),
                            this.GetProgramForNum(9),
                            this.GetProgramForNum(13),
                            this.GetProgramForNum(10)
                        }
                    }
                }
            });
            return(computerList);
        }
Example #4
0
        public static Vector2 getNearbyNodeOffsetOld(Vector2 basePos, int positionNumber, int total, NetworkMap map, float ExtraSeperationDistance = 0.0f)
        {
            int     num1    = 60;
            int     num2    = 0;
            Vector2 vector2 = Vector2.Zero;
            Vector2 location;

            do
            {
                int num3 = positionNumber + num2;
                int num4 = total;
                while (num3 >= num4)
                {
                    num3 -= num4;
                    num4 += total;
                }
                if (num3 > 0)
                {
                    vector2 = Utils.PolarToCartesian((float)num3 / (float)num4 * 6.283185f, 1f);
                }
                else
                {
                    vector2.X = 1f;
                }
                vector2.Y *= Corporation.Y_ASPECT_RATIO_BIAS;
                float num5 = Corporation.COMPUTER_SEPERATION + ExtraSeperationDistance;
                vector2  = new Vector2(vector2.X * Corporation.COMPUTER_SEPERATION, vector2.Y * Corporation.COMPUTER_SEPERATION);
                location = basePos + vector2;
                ++num2;
                Corporation.TestedPositions.Add(vector2);
            }while (((double)location.X < 0.0 || (double)location.X > 1.0 || ((double)location.Y < 0.0 || (double)location.Y > 1.0) || map.collides(location, 0.075f)) && num2 < num1);
            if (num2 >= num1)
            {
                if ((double)ExtraSeperationDistance <= 0.0)
                {
                    return(Corporation.getNearbyNodeOffsetOld(basePos, positionNumber, total, map, Corporation.COMPUTER_SEPERATION));
                }
                if ((double)ExtraSeperationDistance <= (double)Corporation.COMPUTER_SEPERATION)
                {
                    return(Corporation.getNearbyNodeOffsetOld(basePos, positionNumber, total, map, Corporation.COMPUTER_SEPERATION + Corporation.COMPUTER_SEPERATION));
                }
                vector2 = map.getRandomPosition() - basePos;
            }
            return(vector2);
        }
Example #5
0
        public static void AddEOSComp(XmlReader rdr, Computer compAttatchedTo, object osObj)
        {
            OS     os       = (OS)osObj;
            string compName = "Unregistered eOS Device";
            string str1     = compAttatchedTo.idName + "_eos";
            bool   flag     = false;

            if (rdr.MoveToAttribute("name"))
            {
                compName = ComputerLoader.filter(rdr.ReadContentAsString());
            }
            if (rdr.MoveToAttribute("id"))
            {
                str1 = rdr.ReadContentAsString();
            }
            if (rdr.MoveToAttribute("empty"))
            {
                flag = rdr.ReadContentAsString().ToLower() == "true";
            }
            string newPass = "******";

            if (rdr.MoveToAttribute("passOverride"))
            {
                newPass = rdr.ReadContentAsString();
            }
            Computer device = new Computer(compName, NetworkMap.generateRandomIP(), os.netMap.getRandomPosition(), 0, (byte)5, os);

            device.idName = str1;
            string str2 = "ePhone";

            if (rdr.MoveToAttribute("icon"))
            {
                str2 = rdr.ReadContentAsString();
            }
            device.icon     = str2;
            device.location = compAttatchedTo.location + Corporation.getNearbyNodeOffset(compAttatchedTo.location, Utils.random.Next(12), 12, os.netMap, 0.0f, false);
            device.setAdminPassword(newPass);
            ComputerLoader.loadPortsIntoComputer("22,3659", (object)device);
            device.portsNeededForCrack = 2;
            EOSComp.GenerateEOSFilesystem(device);
            rdr.Read();
            Folder folder1 = device.files.root.searchForFolder("eos");
            Folder folder2 = folder1.searchForFolder("notes");
            Folder folder3 = folder1.searchForFolder("mail");

            while (!(rdr.Name == "eosDevice") || rdr.IsStartElement())
            {
                if (rdr.Name.ToLower() == "note" && rdr.IsStartElement())
                {
                    string nameEntry = (string)null;
                    if (rdr.MoveToAttribute("filename"))
                    {
                        nameEntry = ComputerLoader.filter(rdr.ReadContentAsString());
                    }
                    int    content   = (int)rdr.MoveToContent();
                    string dataEntry = ComputerLoader.filter(rdr.ReadElementContentAsString().TrimStart());
                    if (nameEntry == null)
                    {
                        int length = dataEntry.IndexOf("\n");
                        if (length == -1)
                        {
                            length = dataEntry.IndexOf("\n");
                        }
                        if (length == -1)
                        {
                            length = dataEntry.Length;
                        }
                        string str3 = dataEntry.Substring(0, length);
                        if (str3.Length > 50)
                        {
                            str3 = str3.Substring(0, 47) + "...";
                        }
                        nameEntry = str3.Replace(" ", "_").Replace(":", "").ToLower().Trim() + ".txt";
                    }
                    FileEntry fileEntry = new FileEntry(dataEntry, nameEntry);
                    folder2.files.Add(fileEntry);
                }
                if (rdr.Name.ToLower() == "mail" && rdr.IsStartElement())
                {
                    string str3 = (string)null;
                    string str4 = (string)null;
                    if (rdr.MoveToAttribute("username"))
                    {
                        str3 = ComputerLoader.filter(rdr.ReadContentAsString());
                    }
                    if (rdr.MoveToAttribute("pass"))
                    {
                        str4 = ComputerLoader.filter(rdr.ReadContentAsString());
                    }
                    string dataEntry = "MAIL ACCOUNT : " + str3 + "\nAccount   :" + str3 + "\nPassword :"******"\nLast Sync :" + DateTime.Now.ToString() + "\n\n" + Computer.generateBinaryString(512);
                    string nameEntry = str3 + ".act";
                    folder3.files.Add(new FileEntry(dataEntry, nameEntry));
                }
                if (rdr.Name.ToLower() == "file" && rdr.IsStartElement())
                {
                    string nameEntry = (string)null;
                    if (rdr.MoveToAttribute("name"))
                    {
                        nameEntry = rdr.ReadContentAsString();
                    }
                    string path = "home";
                    if (rdr.MoveToAttribute("path"))
                    {
                        path = rdr.ReadContentAsString();
                    }
                    int    content   = (int)rdr.MoveToContent();
                    string dataEntry = ComputerLoader.filter(rdr.ReadElementContentAsString()).TrimStart();
                    device.getFolderFromPath(path, true).files.Add(new FileEntry(dataEntry, nameEntry));
                }
                rdr.Read();
                if (rdr.EOF)
                {
                    break;
                }
            }
            if (flag)
            {
                Folder folder4 = folder1.searchForFolder("apps");
                if (folder4 != null)
                {
                    folder4.files.Clear();
                    folder4.folders.Clear();
                }
            }
            os.netMap.nodes.Add(device);
            ComputerLoader.postAllLoadedActions += (Action)(() => device.links.Add(os.netMap.nodes.IndexOf(compAttatchedTo)));
            if (compAttatchedTo.attatchedDeviceIDs != null)
            {
                compAttatchedTo.attatchedDeviceIDs += ",";
            }
            compAttatchedTo.attatchedDeviceIDs += device.idName;
        }
Example #6
0
        public static void AddEOSComp(XmlReader rdr, Computer compAttatchedTo, object osObj)
        {
            var os       = (OS)osObj;
            var compName = "Unregistered eOS Device";
            var str1     = compAttatchedTo.idName + "_eos";

            if (rdr.MoveToAttribute("name"))
            {
                compName = rdr.ReadContentAsString();
            }
            if (rdr.MoveToAttribute("id"))
            {
                str1 = rdr.ReadContentAsString();
            }
            var device = new Computer(compName, NetworkMap.generateRandomIP(), os.netMap.getRandomPosition(), 0, 5, os);

            device.idName = str1;
            var str2 = "ePhone";

            if (rdr.MoveToAttribute("icon"))
            {
                str2 = rdr.ReadContentAsString();
            }
            device.icon     = str2;
            device.location = compAttatchedTo.location +
                              Corporation.getNearbyNodeOffset(compAttatchedTo.location, Utils.random.Next(12), 12,
                                                              os.netMap);
            device.setAdminPassword("alpine");
            ComputerLoader.loadPortsIntoComputer("22,3659", device);
            device.portsNeededForCrack = 2;
            GenerateEOSFilesystem(device);
            rdr.Read();
            var folder1 = device.files.root.searchForFolder("eos");
            var folder2 = folder1.searchForFolder("notes");
            var folder3 = folder1.searchForFolder("mail");

            while (!(rdr.Name == "eosDevice") || rdr.IsStartElement())
            {
                if (rdr.Name.ToLower() == "note" && rdr.IsStartElement())
                {
                    string nameEntry = null;
                    if (rdr.MoveToAttribute("filename"))
                    {
                        nameEntry = rdr.ReadContentAsString();
                    }
                    var num       = (int)rdr.MoveToContent();
                    var dataEntry = rdr.ReadElementContentAsString().TrimStart();
                    if (nameEntry == null)
                    {
                        var length = dataEntry.IndexOf("\n");
                        if (length == -1)
                        {
                            length = dataEntry.IndexOf("\n");
                        }
                        if (length == -1)
                        {
                            length = dataEntry.Length;
                        }
                        nameEntry = dataEntry.Substring(0, length).Replace(" ", "_").ToLower().Trim() + ".txt";
                    }
                    var fileEntry = new FileEntry(dataEntry, nameEntry);
                    folder2.files.Add(fileEntry);
                }
                if (rdr.Name.ToLower() == "mail" && rdr.IsStartElement())
                {
                    string str3 = null;
                    string str4 = null;
                    if (rdr.MoveToAttribute("username"))
                    {
                        str3 = rdr.ReadContentAsString();
                    }
                    if (rdr.MoveToAttribute("pass"))
                    {
                        str4 = rdr.ReadContentAsString();
                    }
                    var dataEntry = "MAIL ACCOUNT : " + str3 + "\nAccount   :" + str3 + "\nPassword :"******"\nLast Sync :" + DateTime.Now + "\n\n" + Computer.generateBinaryString(512);
                    var nameEntry = str3 + ".act";
                    folder3.files.Add(new FileEntry(dataEntry, nameEntry));
                }
                rdr.Read();
                if (rdr.EOF)
                {
                    break;
                }
            }
            os.netMap.nodes.Add(device);
            ComputerLoader.postAllLoadedActions += () => device.links.Add(os.netMap.nodes.IndexOf(compAttatchedTo));
            if (compAttatchedTo.attatchedDeviceIDs != null)
            {
                compAttatchedTo.attatchedDeviceIDs += ",";
            }
            compAttatchedTo.attatchedDeviceIDs += device.idName;
        }
Example #7
0
 private Vector2 getLocation()
 {
     return(this.basePosition + Corporation.getNearbyNodeOffset(this.basePosition, this.servers.Count, this.serverCount, this.os.netMap, 0.0f, false));
 }