private static void add_friendship(object sender, EventArgsNewDay e) { if (!ModConfig.enabled || !e.IsNewDay) { return; } List <SpecificConfig> SpecificConfigs = ModConfig.individualConfigs; SortedDictionary <string, SpecificConfig> npcConfigsMap = new SortedDictionary <string, SpecificConfig>(); /*Log.Debug("Loading configurations..."); * foreach (SpecificConfig SpecificConfig in SpecificConfigs) * { * npcConfigsMap.Add(SpecificConfig.name, SpecificConfig); * }*/ if (!npcConfigsMap.ContainsKey("Default")) { npcConfigsMap.Add("Default", new SpecificConfig("Default", 5, 8, 2500)); } string[] npcNames = Player.friendships.Keys.ToArray(); if (!ModConfig.noPassiveIncrease) { Log.Info($"=== Adding Friendship ==="); foreach (string npcName in npcNames) { SpecificConfig config = npcConfigsMap.ContainsKey(npcName) ? npcConfigsMap[npcName] : npcConfigsMap["Default"]; int[] friendshipParams = Player.friendships[npcName]; int friendshipValue = friendshipParams[0]; int friendship_increase = friendshipValue > config.max ? 0 : ModConfig.randomizeIncrease ? Player.hasPlayerTalkedToNPC(npcName) ? (rnd.Next(1, config.baseIncrease * 2) * Player.LuckLevel) + rnd.Next(1, config.talkIncrease * 2) : (rnd.Next(1, config.baseIncrease) * Player.LuckLevel) + rnd.Next(1, config.talkIncrease) : Player.hasPlayerTalkedToNPC(npcName) ? config.talkIncrease * 2 : config.baseIncrease * 2; friendshipValue += friendship_increase; Log.Info($"{npcName} friendship level has increased by {friendship_increase} points. (Current = {friendshipValue}.)"); Player.friendships[npcName][0] = friendshipValue; } Log.Info($"=== Finished Adding Friendship ==="); } }
public static bool MeetCondition(string softwareName, string applicationName, SpecificConfig entity) { bool Apply(Condition condition, Func <bool> isMeet) => condition.Excluding ? !isMeet() : isMeet(); bool CheckConditions(IEnumerable <Condition> conditions, bool isOr) { bool Predicate(Condition c) => c switch { AppCondition app => Apply(c, () => softwareName == app.AppName), InstalledAppCondition installedApp => Apply(c, () => applicationName == installedApp.AppName), AndCondition andCondition => Apply(c, () => CheckConditions(andCondition.Conditions, false)), OrCondition orCondition => Apply(c, () => CheckConditions(orCondition.Conditions, true)), _ => false }; return(isOr ? conditions.OrderBy(c => c.Order).Any(Predicate) : conditions.OrderBy(c => c.Order).All(Predicate)); } return(entity.Conditions.IsEmpty || CheckConditions(entity.Conditions, false)); } }
public View() { SpecificConfigFunc = (d) => { // no op }; }
public AppConfigModel(SpecificConfig config) => Config = config;