Beispiel #1
0
 public MaterialPicker(NollaPrng prng, uint worldSeed)
 {
     PRNG = prng;
     PickMaterials(LIQUIDS, 3);
     PickMaterials(ALCHEMY, 1);
     ShuffleList(worldSeed);
     PRNG.Next();
     PRNG.Next();
 }
Beispiel #2
0
 public static void DoMain(string[] args)
 {
     foreach (var arg in args)
     {
         if (uint.TryParse(arg, out var value))
         {
             var prng = new NollaPrng(value);
             Console.WriteLine($"Next state for seed {value}: {prng.Seed}, error on float cast {prng.Seed - ((double) (float) (prng.Seed * ((double)1/int.MaxValue))) * (0x8000_0000)}");
             Console.WriteLine($"IV bytes for given seed are: {BitConverter.ToString(Get16Seeded((int) value))}");
         }
     }
 }
Beispiel #3
0
        void ShuffleList(uint worldSeed)
        {
            var prng = new NollaPrng((worldSeed >> 1) + 12534);

            // Toxic sludge, blood, and soil for first
            for (int i = Materials.Count - 1; i >= 0; i--)
            {
                int rand = (int)(prng.Next() * (i + 1));
                var tmp  = Materials[i];
                Materials[i]    = Materials[rand];
                Materials[rand] = tmp;
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                PrintHelp();
                return;
            }

            var fileInfo = new FileInfo(args[0]);

            // Suport drag-and-drop onto exe
            if (fileInfo.Exists)
            {
                WakMain(args);
                return;
            }

            if (args.Length > 1 && args[0] == "beta")
            {
                NollaPrng.BETA_SEED = true;
                args = args.Skip(1).ToArray();
            }
            var command = args[0];

            args = args.Skip(1).ToArray();
            switch (command)
            {
            case "help":
                PrintHelp();
                break;

            case "wak":
                WakMain(args);
                break;

            case "recipe":
                MaterialPicker.DoMain(args);
                break;

            case "rng":
                NollaPrng.DoMain(args);
                break;

            default:
                Console.Error.WriteLine($"Unknown command {args[0]}");
                PrintHelp();
                break;
            }
        }
Beispiel #5
0
        public static void PickForSeed(uint worldSeed)
        {
            var prng = new NollaPrng(worldSeed * 0.17127000 + 1323.59030000);

            // Preheat random!
            for (int i = 0; i < 5; i++)
            {
                prng.Next();
            }

            Console.WriteLine($"Seed: {worldSeed}");
            Console.WriteLine($"Lively Concotion: {new MaterialPicker(prng, worldSeed).ToString()}");
            Console.WriteLine($"Alchemical Precursor: {new MaterialPicker(prng, worldSeed).ToString()}");
            Console.WriteLine("");
        }
Beispiel #6
0
        static byte[] DecryptStream(Stream stream, int length, int iv)
        {
            var plaintext = new byte[length];

            using (var aesAlg = new Aes128CounterMode(NollaPrng.Get16Seeded(iv)))
            {
                // Create a decryptor to perform the stream transform.
                var decryptor = aesAlg.CreateDecryptor(AESKey, null);
                var buffer    = new byte[length];
                stream.Read(buffer, 0, length);
                using (MemoryStream limitedStream = new MemoryStream(buffer)) {
                    using (CryptoStream csDecrypt = new CryptoStream(limitedStream, decryptor, CryptoStreamMode.Read, true))
                    {
                        csDecrypt.Read(plaintext, 0, length);
                    }
                }
            }
            return(plaintext);
        }
Beispiel #7
0
        public static byte[] Get16Seeded(int seed, int seedBase = SEED_BASE)
        {
            var prng = new NollaPrng(seed, seedBase);

            return(prng.Next16());
        }