Exemple #1
0
        public static PrefabTweak FromHashtable(Hashtable ht)
        {
            PrefabTweak pt = new PrefabTweak();

            if (ht.Contains(nameof(Matcher)))
            {
                pt.Matcher = (MatchPatternKind)Enum.Parse(typeof(MatchPatternKind), ht[nameof(Matcher)] as string, true);
            }
            if (ht.Contains(nameof(Operator)))
            {
                pt.Operator = (ValueOperation)Enum.Parse(typeof(ValueOperation), ht[nameof(Operator)] as string, true);
            }
            if (ht.Contains(nameof(Pattern)))
            {
                pt.Pattern = ht[nameof(Pattern)] as string;
            }
            if (ht.Contains(nameof(Field)))
            {
                pt.Field = ht[nameof(Field)] as string;
            }
            if (ht.Contains(nameof(Value)))
            {
                pt.Value = ht[nameof(Value)] as string;
            }
            return(pt);
        }
Exemple #2
0
        public static Config FromHashtable(Hashtable ht)
        {
            Config cfg = new Config();

            if (ht.Contains(nameof(EnableAchievements)))
            {
                cfg.EnableAchievements = (bool)ht[nameof(EnableAchievements)];
            }
            if (ht.Contains(nameof(DumpPrefabsData)))
            {
                cfg.DumpPrefabsData = (bool)ht[nameof(EnableAchievements)];
            }
            if (ht.Contains(nameof(ConstructionCostMultiplier)))
            {
                cfg.ConstructionCostMultiplier = (float)ht[nameof(ConstructionCostMultiplier)];
            }
            if (ht.Contains(nameof(MaintenanceCostMultiplier)))
            {
                cfg.MaintenanceCostMultiplier = (float)ht[nameof(MaintenanceCostMultiplier)];
            }
            if (ht.Contains(nameof(RelocationCostMultiplier)))
            {
                cfg.RelocationCostMultiplier = (float)ht[nameof(RelocationCostMultiplier)];
            }
            if (ht.Contains(nameof(RefundMultiplier)))
            {
                cfg.RefundMultiplier = (float)ht[nameof(RefundMultiplier)];
            }

            if (ht.Contains(nameof(Tweaks)))
            {
                ArrayList tweaks = ht[nameof(Tweaks)] as ArrayList;
                foreach (object t in tweaks)
                {
                    PrefabTweak pt = PrefabTweak.FromHashtable(t as Hashtable);
                    cfg.Tweaks.Add(pt);
                }
            }

            return(cfg);
        }