示例#1
0
 internal static void InitInLobbyConfig()
 {
     inLobbyConfigEntry = new ModConfigEntry
     {
         DisplayName = "Artifacts Randomizer",
         EnableField = ConfigFieldUtilities.CreateFromBepInExConfigEntry(Enabled) as BooleanConfigField
     };
     inLobbyConfigEntry.SectionFields["Main"] = new List <IConfigField>
     {
         new EnumConfigField <Randomization>(RandomizationMode.Definition.Key, RandomizationMode.Description.Description, () => RandomizationMode.Value, (newValue) => RandomizationMode.Value = newValue),
         new ArtifactBlacklistField(Blacklist.Definition.Key, Blacklist.Description.Description, GetBlacklistIndices, AddBlacklistIndex, RemoveBlacklistIndex)
     };
     inLobbyConfigEntry.SectionFields["Chance"] = new List <IConfigField>
     {
         new FloatConfigField(DefaultChance.Definition.Key, DefaultChance.Description.Description, () => DefaultChance.Value, null, (newValue) => DefaultChance.Value = newValue, 0, 1),
         new ArtifactChanceField(ArtifactWeights.Definition.Key, ArtifactWeights.Description.Description, GetArtifactChances, AddArtifactChance, RemoveArtifactChance, EndEditArtifactChance)
     };
     inLobbyConfigEntry.SectionFields["Weight"] = new List <IConfigField>
     {
         new IntConfigField(DefaultWeight.Definition.Key, DefaultWeight.Description.Description, () => DefaultWeight.Value, null, (newValue) => DefaultWeight.Value = newValue, 0),
         new IntConfigField(MaxCount.Definition.Key, MaxCount.Description.Description, () => MaxCount.Value, null, (newValue) => MaxCount.Value = newValue, -1),
         new IntConfigField(MinCount.Definition.Key, MinCount.Description.Description, () => MinCount.Value, null, (newValue) => MinCount.Value = newValue, 0),
         new ArtifactWeightField(ArtifactWeights.Definition.Key, ArtifactWeights.Description.Description, GetArtifactWeights, AddArtifactWeight, RemoveArtifactWeight, EndEditArtifactWeight)
     };
     ModConfigCatalog.Add(inLobbyConfigEntry);
 }
示例#2
0
        public static ModConfigEntry CreateFromBepInExConfigFile(ConfigFile file, string displayName, bool tryToFindEnabledField, bool tryToFindSectionEnabledField)
        {
            var entry = new ModConfigEntry
            {
                DisplayName = displayName
            };

            foreach (var row in file)
            {
                if (tryToFindEnabledField && entry.EnableField == null && row.Key.Key.Equals("enabled", StringComparison.InvariantCultureIgnoreCase) && row.Value.BoxedValue is bool)
                {
                    entry.EnableField = CreateBooleanConfigField(row.Value as ConfigEntry <bool>);
                    continue;
                }
                if (tryToFindSectionEnabledField && !entry.SectionEnableFields.ContainsKey(row.Key.Section) && row.Key.Key.Equals("sectionEnabled", StringComparison.InvariantCultureIgnoreCase) && row.Value.BoxedValue is bool)
                {
                    entry.SectionEnableFields[row.Key.Section] = CreateBooleanConfigField(row.Value as ConfigEntry <bool>);
                }
                var field = ProcessConfigRow(row.Value);
                if (field == null)
                {
                    InLobbyConfigPlugin.InstanceLogger.LogWarning($"Config [{displayName}]. Not found prefab that can be associated with `{row.Key.Key}` field.");
                    continue;
                }
                if (!entry.SectionFields.TryGetValue(row.Key.Section, out var fields))
                {
                    fields = entry.SectionFields[row.Key.Section] = new List <IConfigField>();
                }
                (fields as List <IConfigField>).Add(field);
            }

            return(entry);
        }
示例#3
0
        public void Awake()
        {
            Instance = this;

            IsEnabled = Config.Bind("Main", "enabled", true, "Should accumulate artifacts or not?");
            ModConfig = new ModConfigEntry
            {
                DisplayName = "Accumulative Artifacts",
                EnableField = new InLobbyConfig.Fields.BooleanConfigField("", () => IsEnabled.Value, (newValue) => IsEnabled.Value = newValue)
            };

            ModConfigCatalog.Add(ModConfig);
            HookEndpointManager.Add(onCurrentArtifactDiscovered, (Action <Action <ArtifactTrialMissionController, ArtifactDef>, ArtifactTrialMissionController, ArtifactDef>)OnCurrentArtifactDiscovered);
        }
        private static void OnStartInternal()
        {
            var modConfig = new ModConfigEntry
            {
                DisplayName = "Partial Item Display",
                EnableField = ConfigFieldUtilities.CreateFromBepInExConfigEntry(PartialItemDisplayPlugin.Enabled) as BooleanConfigField,
            };

            PartialItemDisplayPlugin.DefaultSection.ApplyToInLobbyConfig(modConfig);
            foreach (var characterSection in PartialItemDisplayPlugin.CharacterSections.Values)
            {
                characterSection.ApplyToInLobbyConfig(modConfig);
            }

            ModConfigCatalog.Add(modConfig);
            ModConfig = modConfig;
        }