private static void RemoveArtifactChance(ArtifactIndex key) { ArtifactChancesDict.Remove(key); UpdateArtifactChances(); }
internal static void InitConfig(ConfigFile Config) { Enabled = Config.Bind("Main", nameof(Enabled), true, "Is mod should randomize artifacts or not"); RandomizationMode = Config.Bind("Main", nameof(RandomizationMode), Randomization.Weight, "Randomization mode which will be used"); Blacklist = Config.Bind("Main", nameof(Blacklist), "", "Artifact indices (comma-separated) that should be ingored when randomizing"); DefaultChance = Config.Bind("Chance", nameof(DefaultChance), 0F, "Chance that will be applied to artifacts without custom chance"); ArtifactChances = Config.Bind("Chance", nameof(ArtifactChances), "", "Artifact chance with indices (comma-separated).\nExample: `1: 0.1, 3: 0.2`"); DefaultWeight = Config.Bind("Weight", nameof(DefaultWeight), 50, "Weight that will be applied to artifacts without custom weight"); MaxCount = Config.Bind("Weight", nameof(MaxCount), -1, "Maximum count of artifacts to be enabled via randomization"); MinCount = Config.Bind("Weight", nameof(MinCount), 0, "Minimum count of artifacts to be enabled via randomization"); ArtifactWeights = Config.Bind("Weight", nameof(ArtifactWeights), "", "Artifact weight with indices (comma-separated).\nExample: `1: 20, 3: 50`"); try { BlacklistIndices.Clear(); BlacklistIndices.AddRange(Blacklist.Value .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(el => (ArtifactIndex)int.Parse(el.Trim())) .Distinct()); } catch (Exception e) { InstanceLogger.LogWarning("Failed to parse `Blacklist` config"); InstanceLogger.LogError(e); } try { ArtifactWeightsDict.Clear(); ArtifactWeights.Value .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(el => el.Trim().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)) .Select(el => { var index = (ArtifactIndex)int.Parse(el[0].Trim()); ArtifactWeightsDict[index] = int.Parse(el[1].Trim()); return(index); }) .ToArray(); } catch (Exception e) { InstanceLogger.LogWarning("Failed to parse `ArtifactWeights` config"); InstanceLogger.LogError(e); } try { ArtifactChancesDict.Clear(); ArtifactChances.Value .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries) .Select(el => el.Trim().Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries)) .Select(el => { var index = (ArtifactIndex)int.Parse(el[0].Trim()); ArtifactChancesDict[index] = float.Parse(el[1].Trim(), CultureInfo.InvariantCulture); return(index); }) .ToArray(); } catch (Exception e) { InstanceLogger.LogWarning("Failed to parse `ArtifactChances` config"); InstanceLogger.LogError(e); } }
private static void AddArtifactChance(ArtifactIndex key, float value) { ArtifactChancesDict.Add(key, value); UpdateArtifactChances(); }