Exemple #1
0
 internal static void Reset()
 {
     // Prepare lists for new randomization.
     MaxRando.Clear();
     TypeLists.Clear();
     LookupTable.Clear();
     NameLookup.Clear();
 }
Exemple #2
0
        private static void HandleCategory(ERF e, Regex r, RandomizationLevel randomizationlevel)
        {
            switch (randomizationlevel)
            {
            default:
            case RandomizationLevel.None:
                break;     // Do nothing.

            case RandomizationLevel.Type:
                List <int> type = new List <int>(e.Key_List.Where(x => r.IsMatch(x.ResRef) && !Is_Forbidden(x.ResRef)).Select(x => x.ResID));
                TypeLists.Add(type);
                break;

            case RandomizationLevel.Max:
                MaxRando.AddRange(e.Key_List.Where(x => r.IsMatch(x.ResRef) && !Is_Forbidden(x.ResRef)).Select(x => x.ResID));
                break;
            }
        }
Exemple #3
0
        public static void texture_rando(KPaths paths)
        {
            // Prepare lists for new randomization.
            MaxRando.Clear();
            TypeLists.Clear();

            // Load in texture pack.
            string pack_name;

            switch (Properties.Settings.Default.TexturePack)
            {
            default:
            case TexturePack.HighQuality:
                pack_name = "\\swpc_tex_tpa.erf";
                break;

            case TexturePack.MedQuality:
                pack_name = "\\swpc_tex_tpb.erf";
                break;

            case TexturePack.LowQuality:
                pack_name = "\\swpc_tex_tpc.erf";
                break;
            }

            ERF e = new ERF(paths.TexturePacks + pack_name);

            foreach (var key in e.Key_List)
            {
                if (!NameLookup.ContainsKey(key.ResID))
                {
                    NameLookup.Add(key.ResID, key.ResRef);
                }
            }

            // Handle categories.
            HandleCategory(e, RegexCubeMaps, Properties.Settings.Default.TextureRandomizeCubeMaps);
            HandleCategory(e, RegexCreatures, Properties.Settings.Default.TextureRandomizeCreatures);
            HandleCategory(e, RegexEffects, Properties.Settings.Default.TextureRandomizeEffects);
            HandleCategory(e, RegexItems, Properties.Settings.Default.TextureRandomizeItems);
            HandleCategory(e, RegexPlanetary, Properties.Settings.Default.TextureRandomizePlanetary);
            HandleCategory(e, RegexNPC, Properties.Settings.Default.TextureRandomizeNPC);
            HandleCategory(e, RegexPlayHeads, Properties.Settings.Default.TextureRandomizePlayHeads);
            HandleCategory(e, RegexPlayBodies, Properties.Settings.Default.TextureRandomizePlayBodies);
            HandleCategory(e, RegexPlaceables, Properties.Settings.Default.TextureRandomizePlaceables);
            HandleCategory(e, RegexParty, Properties.Settings.Default.TextureRandomizeParty);
            HandleCategory(e, RegexStunt, Properties.Settings.Default.TextureRandomizeStunt);
            HandleCategory(e, RegexVehicles, Properties.Settings.Default.TextureRandomizeVehicles);
            HandleCategory(e, RegexWeapons, Properties.Settings.Default.TextureRandomizeWeapons);

            // Handle other.
            switch (Properties.Settings.Default.TextureRandomizeOther)
            {
            default:
            case RandomizationLevel.None:
                break;     // Do nothing.

            case RandomizationLevel.Type:
                List <int> type = new List <int>(e.Key_List.Where(x => Matches_None(x.ResRef) && !Is_Forbidden(x.ResRef)).Select(x => x.ResID));
                TypeLists.Add(type);
                break;

            case RandomizationLevel.Max:
                MaxRando.AddRange(e.Key_List.Where(x => Matches_None(x.ResRef) && !Is_Forbidden(x.ResRef)).Select(x => x.ResID));
                break;
            }

            // Max Rando.
            List <int> Max_Rando_Iterator = new List <int>(MaxRando);

            Randomize.FisherYatesShuffle(MaxRando);
            int j = 0;

            foreach (ERF.Key k in e.Key_List.Where(x => Max_Rando_Iterator.Contains(x.ResID)))
            {
                LookupTable.Add(k.ResID, MaxRando[j]);
                k.ResID = MaxRando[j];
                j++;
            }

            // Type Rando.
            foreach (List <int> li in TypeLists)
            {
                List <int> type_copy = new List <int>(li);
                Randomize.FisherYatesShuffle(type_copy);
                j = 0;
                foreach (ERF.Key k in e.Key_List.Where(x => li.Contains(x.ResID)))
                {
                    LookupTable.Add(k.ResID, type_copy[j]);
                    k.ResID = type_copy[j];
                    j++;
                }
            }

            e.WriteToFile(paths.TexturePacks + pack_name);
        }