public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings)
 {
     if (Settings != null)
     {
         foreach (var hero in Settings)
         {
             if (hero.Key != "General")
             {
                 builder.AppendLine($"{hero.Key}");
                 builder.AppendLine("{");
                 builder.Indent();
                 WorkshopValuePair.ToWorkshop(((JObject)hero.Value).ToObject <Dictionary <string, object> >(), builder, allSettings);
                 builder.Outdent();
                 builder.AppendLine("}");
             }
             else
             {
                 WorkshopValuePair.ToWorkshop(((JObject)hero.Value).ToObject <Dictionary <string, object> >(), builder, allSettings);
             }
         }
     }
     if (EnabledHeroes != null)
     {
         builder.AppendLine();
         builder.AppendKeywordLine("enabled heroes");
         Ruleset.WriteList(builder, EnabledHeroes);
     }
     if (DisabledHeroes != null)
     {
         builder.AppendLine();
         builder.AppendKeywordLine("disabled heroes");
         Ruleset.WriteList(builder, DisabledHeroes);
     }
 }
        public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings, string modeName)
        {
            builder.AppendKeywordLine(modeName);

            Settings?.Remove("Enabled");

            if (EnabledMaps != null || DisabledMaps != null || (Settings != null && Settings.Count > 0))
            {
                builder.AppendLine("{");
                builder.Indent();

                if (Settings != null)
                {
                    WorkshopValuePair.ToWorkshop(Settings, builder, allSettings);
                }

                if (EnabledMaps != null)
                {
                    builder.AppendKeywordLine("enabled maps");
                    Ruleset.WriteList(builder, EnabledMaps);
                }
                if (DisabledMaps != null)
                {
                    builder.AppendKeywordLine("disabled maps");
                    Ruleset.WriteList(builder, DisabledMaps);
                }

                builder.Unindent();
                builder.AppendLine("}");
            }
        }
Exemple #3
0
        public void ToWorkshop(WorkshopBuilder builder, List <LobbySetting> allSettings, string modeName)
        {
            bool enabled = Settings == null || !Settings.TryGetValue("Enabled", out object value) || (value is bool b && b);

            Settings?.Remove("Enabled");

            if (!enabled)
            {
                builder.AppendKeyword("disabled").Append(" ");
            }
            builder.AppendKeywordLine(modeName);

            if (EnabledMaps != null || DisabledMaps != null || (Settings != null && Settings.Count > 0))
            {
                builder.AppendLine("{");
                builder.Indent();

                if (Settings != null)
                {
                    WorkshopValuePair.ToWorkshop(Settings, builder, allSettings);
                }

                if (EnabledMaps != null)
                {
                    builder.AppendKeywordLine("enabled maps");
                    Ruleset.WriteList(builder, EnabledMaps);
                }
                if (DisabledMaps != null)
                {
                    builder.AppendKeywordLine("disabled maps");
                    Ruleset.WriteList(builder, DisabledMaps);
                }

                builder.Unindent();
                builder.AppendLine("}");
            }
        }