The configuration class for this mod.
Beispiel #1
0
 public static void Initialize(IMonitor monitor, IModHelper helper, ModConfig config)
 {
     Monitor = monitor;
     Config  = config;
     Helper  = helper;
 }
Beispiel #2
0
    void Awake()
    {
        MainThreadQueue.Initialize();

        GameInfo       = GetComponent <KMGameInfo>();
        SettingWarning = transform.Find("UI").Find("SettingWarning").gameObject;
        BetterCasePicker.BombCaseGenerator = GetComponentInChildren <BombCaseGenerator>();

        modConfig          = new ModConfig <TweakSettings>("TweakSettings");
        settings           = modConfig.Settings;
        modConfig.Settings = settings;         // Write any settings that the user doesn't have in their settings file.

        bool changeFadeTime = settings.FadeTime >= 0;

        FreeplayDevice.MAX_SECONDS_TO_SOLVE = float.MaxValue;
        FreeplayDevice.MIN_MODULE_COUNT     = 1;

        if (settings.EnableModsOnlyKey)
        {
            var lastFreeplaySettings = FreeplaySettings.CreateDefaultFreeplaySettings();
            lastFreeplaySettings.OnlyMods = true;
            ProgressionManager.Instance.RecordLastFreeplaySettings(lastFreeplaySettings);
        }

        UpdateSettingWarning();

        // Setup API/properties other mods to interact with
        GameObject infoObject = new GameObject("Tweaks_Info", typeof(TweaksProperties));

        infoObject.transform.parent = gameObject.transform;

        // Watch the TweakSettings file for Time Mode state being changed in the office.
        FileSystemWatcher watcher = new FileSystemWatcher(Path.Combine(Application.persistentDataPath, "Modsettings"), "TweakSettings.json")
        {
            NotifyFilter = NotifyFilters.LastWrite
        };

        watcher.Changed += (object source, FileSystemEventArgs e) =>
        {
            if (settings.Equals(modConfig.Settings))
            {
                return;
            }

            UpdateSettings();
            UpdateSettingWarning();

            MainThreadQueue.Enqueue(() => StartCoroutine(ModifyFreeplayDevice(false)));
        };

        // Setup our "service" to block the leaderboard submission requests
        ReflectedTypes.InstanceField.SetValue(null, new SteamFilterService());

        // Create a fake case with a bunch of anchors to trick the game when using CaseGenerator.
        TweaksCaseGeneratorCase = new GameObject("TweaksCaseGenerator");
        TweaksCaseGeneratorCase.transform.SetParent(transform);
        var kmBomb = TweaksCaseGeneratorCase.AddComponent <KMBomb>();

        kmBomb.IsHoldable      = false;
        kmBomb.WidgetAreas     = new List <GameObject>();
        kmBomb.visualTransform = transform;
        kmBomb.Faces           = new List <KMBombFace>();

        TweaksCaseGeneratorCase.AddComponent <ModBomb>();

        var kmBombFace = TweaksCaseGeneratorCase.AddComponent <KMBombFace>();

        kmBombFace.Anchors = new List <Transform>();
        kmBomb.Faces.Add(kmBombFace);

        for (int i = 0; i <= 9001; i++)
        {
            kmBombFace.Anchors.Add(transform);
        }

        // Handle scene changes
        UnityEngine.SceneManagement.SceneManager.sceneLoaded += (Scene scene, LoadSceneMode _) =>
        {
            UpdateSettings();
            UpdateSettingWarning();

            Modes.settings           = Modes.modConfig.Settings;
            Modes.modConfig.Settings = Modes.settings;

            if ((scene.name == "mainScene" || scene.name == "gameplayScene") && changeFadeTime)
            {
                SceneManager.Instance.RapidFadeInTime = settings.FadeTime;
            }

            switch (scene.name)
            {
            case "mainScene":
                if (changeFadeTime)
                {
                    SceneManager.Instance.SetupState.FadeInTime          =
                        SceneManager.Instance.SetupState.FadeOutTime     =
                            SceneManager.Instance.UnlockState.FadeInTime = settings.FadeTime;
                }

                break;

            case "gameplayLoadingScene":
                var gameplayLoadingManager = FindObjectOfType <GameplayLoadingManager>();
                if (settings.InstantSkip)
                {
                    gameplayLoadingManager.MinTotalLoadTime = 0;
                }
                if (changeFadeTime)
                {
                    gameplayLoadingManager.FadeInTime      =
                        gameplayLoadingManager.FadeOutTime = settings.FadeTime;
                }

                ReflectedTypes.UpdateTypes();

                ReflectedTypes.CurrencyAPIEndpointField?.SetValue(null, settings.FixFER ? "http://api.exchangeratesapi.io" : "http://api.fixer.io");

                break;

            case "gameplayScene":
                if (changeFadeTime)
                {
                    SceneManager.Instance.GameplayState.FadeInTime      =
                        SceneManager.Instance.GameplayState.FadeOutTime = settings.FadeTime;
                }

                break;
            }
        };

        // Handle state changes
        GameInfo.OnStateChange += (KMGameInfo.State state) =>
        {
            CurrentState = state;
            watcher.EnableRaisingEvents = state == KMGameInfo.State.Setup;

            if (state == KMGameInfo.State.Gameplay)
            {
                bool disableRecords = settings.BombHUD || settings.ShowEdgework || CurrentMode != Mode.Normal || settings.MissionSeed != -1;

                Assets.Scripts.Stats.StatsManager.Instance.DisableStatChanges        =
                    Assets.Scripts.Records.RecordManager.Instance.DisableBestRecords = disableRecords;
                if (disableRecords)
                {
                    SteamFilterService.TargetMissionID = GameplayState.MissionToLoad;
                }

                BetterCasePicker.HandleCaseGeneration();

                BombStatus.Instance.widgetsActivated = false;
                BombStatus.Instance.HUD.SetActive(settings.BombHUD);
                BombStatus.Instance.Edgework.SetActive(settings.ShowEdgework);
                BombStatus.Instance.ConfidencePrefab.gameObject.SetActive(CurrentMode != Mode.Zen);
                BombStatus.Instance.StrikesPrefab.color = CurrentMode == Mode.Time ? Color.yellow : Color.red;

                Modes.Multiplier = Modes.settings.TimeModeStartingMultiplier;
                BombStatus.Instance.UpdateMultiplier();
                bombWrappers = new BombWrapper[] { };
                StartCoroutine(CheckForBombs());
                if (settings.SkipGameplayDelay)
                {
                    StartCoroutine(SkipGameplayDelay());
                }

                if (GameplayState.BombSeedToUse == -1)
                {
                    GameplayState.BombSeedToUse = settings.MissionSeed;
                }
            }
            else if (state == KMGameInfo.State.Setup)
            {
                if (ReflectedTypes.LoadedModsField.GetValue(ModManager.Instance) is Dictionary <string, Mod> loadedMods)
                {
                    Mod tweaksMod = loadedMods.Values.FirstOrDefault(mod => mod.ModID == "Tweaks");
                    if (tweaksMod != null)
                    {
                        if (CaseGeneratorSettingCache != settings.CaseGenerator)
                        {
                            if (settings.CaseGenerator)
                            {
                                tweaksMod.ModObjects.Add(TweaksCaseGeneratorCase);
                            }
                            else
                            {
                                tweaksMod.ModObjects.Remove(TweaksCaseGeneratorCase);
                            }

                            CaseGeneratorSettingCache = settings.CaseGenerator;
                            UpdateSettingWarning();
                        }
                    }
                }

                StartCoroutine(ModifyFreeplayDevice(true));
                GetComponentInChildren <ModSelectorExtension>().FindAPI();

                GameplayState.BombSeedToUse = -1;
            }
            else if (state == KMGameInfo.State.Transitioning)
            {
                // Because the settings are checked on a scene change and there is no scene change from exiting the gameplay room,
                // we need to update the settings here in case the user changed their HideTOC settings.
                UpdateSettings();

                bool modified       = false;
                var  ModMissionToCs = ModManager.Instance.ModMissionToCs;
                foreach (var metaData in ModMissionToCs)
                {
                    modified |= ModToCMetaData.Add(metaData);
                }

                var unloadedMods = (Dictionary <string, Mod>)ReflectedTypes.UnloadedModsField.GetValue(ModManager.Instance);
                if (unloadedMods != null)
                {
                    foreach (var unloadedMod in unloadedMods.Values)
                    {
                        var tocs = (List <ModTableOfContentsMetaData>)ReflectedTypes.TocsField.GetValue(unloadedMod);
                        if (tocs != null)
                        {
                            foreach (var metaData in tocs)
                            {
                                modified |= ModToCMetaData.Remove(metaData);
                            }
                        }
                    }
                }

                var newToCs = ModToCMetaData.Where(metaData => !settings.HideTOC.Any(pattern => Localization.GetLocalizedString(metaData.DisplayNameTerm).Like(pattern)));
                modified |= (newToCs.Count() != ModMissionToCs.Count || !newToCs.All(ModMissionToCs.Contains));
                ModMissionToCs.Clear();
                ModMissionToCs.AddRange(newToCs);

                if (modified)
                {
                    SetupState.LastBombBinderTOCIndex = 0;
                    SetupState.LastBombBinderTOCPage  = 0;
                }
            }
        };
    }
Beispiel #3
0
 public override void UpdateProperty(ModConfig config)
 {
     LinkedProperty.SetValue(config, this.SaveData.Value, null);
 }
Beispiel #4
0
 internal MiscTask(ModConfig config)
 {
     _config = config;
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="menu">The underlying chest menu.</param>
 /// <param name="chest">The selected chest.</param>
 /// <param name="chests">The available chests.</param>
 /// <param name="config">The mod configuration.</param>
 /// <param name="keys">The configured key bindings.</param>
 /// <param name="events">The SMAPI events available for mods.</param>
 /// <param name="input">An API for checking and changing input state.</param>
 /// <param name="reflection">Simplifies access to private code.</param>
 /// <param name="showAutomateOptions">Whether to show Automate options.</param>
 public ShopMenuOverlay(ShopMenu menu, ManagedChest chest, ManagedChest[] chests, ModConfig config, ModConfigKeys keys, IModEvents events, IInputHelper input, IReflectionHelper reflection, bool showAutomateOptions)
     : base(menu, chest, chests, config, keys, events, input, reflection, showAutomateOptions, keepAlive: () => Game1.activeClickableMenu is ShopMenu, topOffset: Game1.pixelZoom * 6)
 {
     this.Menu = menu;
     this.DefaultPurchaseFilter       = menu.canPurchaseCheck;
     this.DefaultInventoryHighlighter = menu.inventory.highlightMethod;
 }
Beispiel #6
0
 public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message)
 {
     message = Language.GetTextValue("Mods.BossExpertise.Config.ServerBlocked");
     return(false);
 }
 public FarmAnimalTreat(FarmAnimal farmAnimal, ModConfig config) : base(config)
 {
     _farmAnimal = farmAnimal;
 }
 public override void Unload()
 {
     RightClickOverrides.Clear();
     RightClickOverrides = null;
     Config = null;
 }
 public VillagerBirthdayRelationship(ModConfig config)
 {
     Config = config;
 }
Beispiel #10
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            I18n.Init(helper.Translation);

            // read data file
            const string dataPath = "assets/data.json";

            try
            {
                DataModel?data = this.Helper.Data.ReadJsonFile <DataModel>(dataPath);
                if (data == null)
                {
                    data = new(null);
                    this.Monitor.Log($"The {dataPath} file seems to be missing or invalid. Floor connectors will be disabled.", LogLevel.Error);
                }
                this.Data = data;
            }
            catch (Exception ex)
            {
                this.Data = new(null);
                this.Monitor.Log($"The {dataPath} file seems to be invalid. Floor connectors will be disabled.\n{ex}", LogLevel.Error);
            }

            // read config
            this.Config = this.Helper.ReadConfig <ModConfig>();

            // init
            this.MachineManager = new MachineManager(
                config: () => this.Config,
                data: this.Data,
                defaultFactory: new AutomationFactory(
                    config: () => this.Config,
                    monitor: this.Monitor,
                    reflection: helper.Reflection,
                    data: this.Data,
                    isBetterJunimosLoaded: helper.ModRegistry.IsLoaded("hawkfalcon.BetterJunimos")
                    ),
                monitor: this.Monitor
                );

            this.CommandHandler = new CommandHandler(this.Monitor, () => this.Config, this.MachineManager);

            // hook events
            helper.Events.GameLoop.GameLaunched          += this.OnGameLaunched;
            helper.Events.GameLoop.SaveLoaded            += this.OnSaveLoaded;
            helper.Events.GameLoop.DayStarted            += this.OnDayStarted;
            helper.Events.GameLoop.UpdateTicked          += this.OnUpdateTicked;
            helper.Events.Input.ButtonsChanged           += this.OnButtonsChanged;
            helper.Events.Multiplayer.ModMessageReceived += this.OnModMessageReceived;
            helper.Events.Player.Warped                   += this.OnWarped;
            helper.Events.World.BuildingListChanged       += this.OnBuildingListChanged;
            helper.Events.World.LocationListChanged       += this.OnLocationListChanged;
            helper.Events.World.ObjectListChanged         += this.OnObjectListChanged;
            helper.Events.World.TerrainFeatureListChanged += this.OnTerrainFeatureListChanged;

            // hook commands
            this.CommandHandler.RegisterWith(helper.ConsoleCommands);

            // log info
            this.Monitor.VerboseLog($"Initialized with automation every {this.Config.AutomationInterval} ticks.");
            if (this.Config.ModCompatibility.WarnForMissingBridgeMod)
            {
                this.ReportMissingBridgeMods(this.Data.SuggestedIntegrations);
            }
        }
Beispiel #11
0
 private void CopyTheaters(ModConfig modConfig)
 {
     (propertyGrid1.SelectedObject as ModConfig).Theaters = modConfig.Theaters;
     TypeDescriptor.Refresh(propertyGrid1.SelectedObject);
 }
Beispiel #12
0
 public NameScreenRelationship(ModConfig config)
 {
     Display = false;
     Config  = config;
 }
Beispiel #13
0
        public override void Entry(IModHelper helper)
        {
            config = helper.ReadConfig <ModConfig>();
            if (!config.ModEnabled)
            {
                return;
            }

            this.contentPath = Path.Combine(this.Helper.DirectoryPath, "Content");
            if (!Directory.Exists(this.contentPath))
            {
                try {
                    this.Monitor.Log($"Creating directory {this.contentPath}");
                    Directory.CreateDirectory(this.contentPath);
                } catch (Exception ex) {
                    this.Monitor.Log($"Could not create directory {this.contentPath}! Please create it yourself.", LogLevel.Error);
                    this.Monitor.Log(ex.Message, LogLevel.Error);
                    return;
                }
            }

            this.itemLoader = new ItemLoader();
            this.merger     = new ContentMerger();

            GameEvents.UpdateTick += UpdateTick;
            LocationEvents.CurrentLocationChanged += CurrentLocationChanged;
            GraphicsEvents.OnPreRenderEvent       += OnPreRenderEvent;
            GameEvents.LoadContent += LoadFromFolder;

            ItemCustom custom = new ItemCustom("SCCL.custom");

            ControlEvents.KeyPressed += (sender, e) => {
                switch (e.KeyPressed)
                {
                case Microsoft.Xna.Framework.Input.Keys.R:
                    Game1.player.addItemToInventory(new ModObject(custom));
                    break;

                case Microsoft.Xna.Framework.Input.Keys.T:
                    itemLoader.Save();
                    break;

                case Microsoft.Xna.Framework.Input.Keys.Y:
                    itemLoader.Load();
                    break;
                }
            };

            #region Console Commands
            Helper.ConsoleCommands.Add("SCCLEnable", "Enables a content injector | SCCLEnable <injector>", (cmd, args) => {
                if (args.Length >= 1)
                {
                    string name = args[0];
                    if (ContentAPI.InjectorExists(name))
                    {
                        ContentAPI.GetInjector(this, name).Enabled = true;
                        Monitor.Log(name + " is enabled", LogLevel.Info);
                    }
                    else
                    {
                        Monitor.Log("No injector with name '" + name + "' exists!", LogLevel.Warn);
                    }
                }
                else
                {
                    Monitor.Log("Injector name was not specified", LogLevel.Warn);
                }
            });
            Helper.ConsoleCommands.Add("SCCLDisable", "Disables a content injector | SCCLEnable <injector>", (cmd, args) => {
                if (args.Length >= 1)
                {
                    string name = args[0];
                    if (ContentAPI.InjectorExists(name))
                    {
                        ContentAPI.GetInjector(this, name).Enabled = false;
                        Monitor.Log(name + " is disabled", LogLevel.Info);
                    }
                    else
                    {
                        Monitor.Log("No injector with name '" + name + "' exists!", LogLevel.Warn);
                    }
                }
                else
                {
                    Monitor.Log("Injector name was not specified", LogLevel.Warn);
                }
            });
            Helper.ConsoleCommands.Add("SCCLList", "Lists all content injectors | SCCLList", (cmd, args) => {
                this.Monitor.Log("Registered injectors: " + string.Join(", ", ContentAPI.GetAllInjectors()), LogLevel.Info);
            });
            Helper.ConsoleCommands.Add("SCCLReload", "Reloads the config (ModEnabled is ignored) | SCCLReload", (cmd, args) => {
                this.config = this.Helper.ReadConfig <ModConfig>();
                // TODO: remove all previously loaded assets
                this.LoadFromFolder(this, new EventArgs());
            });
            #endregion
        }
Beispiel #14
0
 public TileLayer(int w, int h, ModConfig config)
     : this(new Size(w, h), config)
 {
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="reflection">Simplifies access to private game code.</param>
 /// <param name="gameHelper">Provides utility methods for interacting with the game code.</param>
 /// <param name="config">The mod configuration.</param>
 /// <param name="codex">Provides subject entries.</param>
 public CharacterLookupProvider(IReflectionHelper reflection, GameHelper gameHelper, ModConfig config, ISubjectRegistry codex)
     : base(reflection, gameHelper)
 {
     this.Config = config;
     this.Codex  = codex;
 }
Beispiel #16
0
 public GrampasGhostHandler(ModConfig config, IModHelper helper, IMonitor monitor)
     : base(config, helper, monitor)
 {
 }
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="config">The mod configuration.</param>
 public SeedBagAttachment(ModConfig config)
 {
     this.Enable = config.StandardAttachments.SeedBag.Enable;
 }
        // monster switch statement ahead...
        private void SetCustomStat(CharacterStats stats, string stackSource, Tag statTag, float value, bool mult, ModConfig config)
        {
            ClearCustomStat(stats, statTag, stackSource, mult);
            stats.RefreshVitalMaxStat();
            Stat[] _dmg = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageTypesModifier");
            Stat[] _pro = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageProtection");
            Stat[] _res = (Stat[])AT.GetValue(typeof(CharacterStats), stats, "m_damageResistance");

            switch (statTag.TagName)
            {
            case "MaxHealth":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxHealthStat"), value, CharacterStats.MIN_MAXHEALTH_LIMIT, config)), mult);
                break;

            case "HealthRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_healthRegen"), value, Settings.Minimum, config)), mult);
                break;

            case "MaxStamina":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxStamina"), value, CharacterStats.MIN_MAXSTAMINA_LIMIT, config)), mult);
                break;

            case "StaminaRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_staminaRegen"), value, Settings.MinimumMod, config)), mult);
                break;

            case "StaminaUse":
            case "StaminaCostReduction":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_staminaUseModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "MaxMana":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_maxManaStat"), value, Settings.Minimum, config)), mult);
                break;

            case "ManaRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_manaRegen"), value, Settings.Minimum, config)), mult);
                break;

            case "ManaUse":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_manaUseModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "Impact":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_impactModifier"), value, Settings.Minimum, config)), mult);
                break;

            case "AllDamages":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_damageModifiers"), value, Settings.Minimum, config)), mult);
                break;

            case "ImpactResistance":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_impactResistance"), value, Settings.Minimum, config)), mult);
                break;

            case "StabilityRegen":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_stabilityRegen"), value, Settings.MinimumMod, config)), mult);
                break;

            case "MovementSpeed":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_movementSpeed"), value, Settings.MinimumMod, config)), mult);
                break;

            case "AttackSpeed":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_attackSpeedModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "DodgeInvulnerabilityModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_dodgeInvulneratiblityModifier"), value, Settings.MinimumMod, config)), mult);
                break;

            case "Detectability":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_detectability"), value, Settings.Minimum, config)), mult);
                break;

            case "VisualDetectability":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_visualDetectability"), value, Settings.Minimum, config)), mult);
                break;

            case "SkillCooldownModifier":
                stats.AddStatStack(statTag, new StatStack(stackSource, Modify(mult, AT.GetCharacterStat(stats, "m_skillCooldownModifier"), value, Settings.MinimumMod, config)), mult);
                break;
            }
        }
Beispiel #19
0
 /// <summary> Five player some starting stuff. Only used for a freshly started games. </summary>
 private void AwardNewGame()
 {
     //Monitor.Log("Awarding new game stuff...", LogLevel.Trace);
     if (ModConfig.GetConfig("newgame_tools"))
     {
         if (ModConfig.GetFlagBoolean("ccJunimo"))
         {
             UpgradeTool("Watering Can");
             UpgradeTool("Hoe");
             Monitor.Log("Local Legend: Awarding a farming tools upgrade for a new game.", LogLevel.Info);
         }
         if (ModConfig.GetFlagBoolean("ccJoja"))
         {
             UpgradeTool("Axe");
             UpgradeTool("Pickaxe");
             Monitor.Log("Joja Co. Member Of The Year: Awarding a gathering tools upgrade for a new game.", LogLevel.Info);
         }
         if (ModConfig.GetFlagBoolean("fullShipment"))
         {
             Game1.player.increaseBackpackSize(12);
             Monitor.Log("Full Shipment: Awarding backpack upgrade for a new game.", LogLevel.Info);
         }
     }
     if (ModConfig.GetConfig("newgame_assets"))
     {
         int moneyBonus = Decimal.ToInt32(ModConfig.GetFlagDecimal("money", 0) / 1000);
         if (moneyBonus > 0)
         {
             Game1.player.money += moneyBonus;
             Monitor.Log($"Hoarder: Awarding {moneyBonus} money for a new game.", LogLevel.Info);
         }
         if (Decimal.ToInt32(ModConfig.GetFlagDecimal("grandpaScore", 0)) == 4)
         {
             Game1.player.addItemToInventory((Item) new StardewValley.Object(628, 1));
             Game1.player.addItemToInventory((Item) new StardewValley.Object(629, 1));
             Game1.player.addItemToInventory((Item) new StardewValley.Object(630, 1));
             Game1.player.addItemToInventory((Item) new StardewValley.Object(631, 1));
             Game1.player.addItemToInventory((Item) new StardewValley.Object(632, 1));
             Game1.player.addItemToInventory((Item) new StardewValley.Object(633, 1));
             Monitor.Log("Perfection: Awarding a set of the tree saplings for a new game.", LogLevel.Info);
         }
         // Burglar's Ring for "Qi's Challenge"
         if (ModConfig.GetFlagBoolean("QiChallengeComplete"))
         {
             Game1.player.leftRing.Value = new Ring(526);
             Game1.player.leftRing.Value.onEquip(Game1.player, Game1.player.currentLocation);
             Monitor.Log("Qi's Challenge: Awarding the Burglar's Ring for a new game.", LogLevel.Info);
         }
         // Iridium Band for "Protector Of The Valley"
         if (ModConfig.GetFlagBoolean("areAllMonsterSlayerQuestsComplete"))
         {
             Game1.player.leftRing.Value = new Ring(527);
             Game1.player.leftRing.Value.onEquip(Game1.player, Game1.player.currentLocation);
             Monitor.Log("Protector Of The Valley: Awarding the Iridium Band for a new game.", LogLevel.Info);
         }
         // TODO:
         // Bonus 2 starting hearts with everyone for "Popular"?
         // Statue of Perfection for "Fector's Challenge"?
     }
     //Monitor.Log("Awarding new game stuff - completed.", LogLevel.Trace);
 }
Beispiel #20
0
 /// <summary>Creats an instance of the clean task.</summary>
 /// <param name="config">The config object for this mod.</param>
 public LargeTerrainFeatureCleanTask(ModConfig config)
     : base(config)
 {
 }
Beispiel #21
0
        public override void OnActivate()
        {
            SetMessage("", Color.White);
            string configDisplayName = ((LabelAttribute)Attribute.GetCustomAttribute(modConfig.GetType(), typeof(LabelAttribute)))?.Label ?? modConfig.Name;

            headerTextPanel.SetText(modConfig.mod.DisplayName + ": " + configDisplayName);
            pendingConfig  = modConfig.Clone();
            pendingChanges = pendingRevertDefaults;
            if (pendingRevertDefaults)
            {
                pendingRevertDefaults = false;
                ConfigManager.Reset(pendingConfig);
                pendingChangesUIUpdate = true;
            }

            int index = modConfigs.IndexOf(modConfig);
            int count = modConfigs.Count;

            //pendingChanges = false;
            backButton.BackgroundColor = UICommon.DefaultUIBlueMouseOver;
            uIElement.RemoveChild(saveConfigButton);
            uIElement.RemoveChild(revertConfigButton);
            uIElement.RemoveChild(previousConfigButton);
            uIElement.RemoveChild(nextConfigButton);
            if (index + 1 < count)
            {
                uIElement.Append(nextConfigButton);
            }
            if (index - 1 >= 0)
            {
                uIElement.Append(previousConfigButton);
            }

            uIElement.RemoveChild(configPanelStack.Peek());
            uIElement.Append(uIPanel);
            mainConfigList.Clear();
            configPanelStack.Clear();
            configPanelStack.Push(uIPanel);
            subPageStack.Clear();
            //currentConfigList = mainConfigList;
            int i   = 0;
            int top = 0;

            // load all mod config options into UIList
            // TODO: Inheritance with ModConfig? DeclaredOnly?

            uIPanel.BackgroundColor = UICommon.MainPanelBackground;
            var backgroundColorAttribute = (BackgroundColorAttribute)Attribute.GetCustomAttribute(pendingConfig.GetType(), typeof(BackgroundColorAttribute));

            if (backgroundColorAttribute != null)
            {
                uIPanel.BackgroundColor = backgroundColorAttribute.color;
            }

            int order = 0;

            foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(pendingConfig))
            {
                if (variable.isProperty && variable.Name == "Mode")
                {
                    continue;
                }
                if (Attribute.IsDefined(variable.MemberInfo, typeof(JsonIgnoreAttribute)) && !Attribute.IsDefined(variable.MemberInfo, typeof(LabelAttribute)))                 // TODO, appropriately named attribute
                {
                    continue;
                }
                HeaderAttribute header = ConfigManager.GetCustomAttribute <HeaderAttribute>(variable, null, null);
                if (header != null)
                {
                    var wrapper = new PropertyFieldWrapper(typeof(HeaderAttribute).GetProperty(nameof(HeaderAttribute.Header)));
                    WrapIt(mainConfigList, ref top, wrapper, header, order++);
                }
                WrapIt(mainConfigList, ref top, variable, pendingConfig, order++);
            }
        }
Beispiel #22
0
        // called from RPC manager
        public void SetSyncInfo(bool modsEnabled, bool enemiesAllied, bool customStats, float healthModifier, float damageModifier, float impactRes, float damageRes, float impactDmg)
        {
            m_currentHostUID = CharacterManager.Instance.GetWorldHostCharacter()?.UID;
            //Debug.Log("Received sync from host uid: " + m_currentHostUID);

            this.m_currentSyncInfos = new ModConfig
            {
                ModName         = "CombatOverhaul_Sync",
                SettingsVersion = 1.0,
                Settings        = new List <BBSetting>
                {
                    new BoolSetting
                    {
                        Name         = Settings.All_Enemies_Allied,
                        m_value      = enemiesAllied,
                        DefaultValue = false,
                    },
                    new BoolSetting
                    {
                        Name    = Settings.Enemy_Balancing,
                        m_value = customStats
                    },
                    new FloatSetting
                    {
                        Name    = Settings.Enemy_Health,
                        m_value = healthModifier
                    },
                    new FloatSetting
                    {
                        Name    = Settings.Enemy_Damages,
                        m_value = damageModifier
                    },
                    new FloatSetting
                    {
                        Name    = Settings.Enemy_Resistances,
                        m_value = damageRes
                    },
                    new FloatSetting
                    {
                        Name    = Settings.Enemy_ImpactRes,
                        m_value = impactRes
                    },
                    new FloatSetting
                    {
                        Name    = Settings.Enemy_ImpactDmg,
                        m_value = impactDmg
                    },
                }
            };

            // manually fix the settings dictionary since we are not using ModConfig.Register()
            var dict = new Dictionary <string, BBSetting>();

            foreach (var setting in m_currentSyncInfos.Settings)
            {
                dict.Add(setting.Name, setting);
            }
            At.SetField(m_currentSyncInfos, "m_Settings", dict);

            if (modsEnabled)
            {
                //Debug.Log("Updating all current characters");
                foreach (Character c in CharacterManager.Instance.Characters.Values.Where(x => x.IsAI))
                {
                    SetEnemyMods(m_currentSyncInfos, c.Stats, c);
                }
            }
        }
Beispiel #23
0
 private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
 {
     // Read persisted config.
     config_ = this.Helper.ReadConfig <ModConfig>();
 }
Beispiel #24
0
        // actual function to set an enemy's stats
        private void SetEnemyMods(ModConfig _config, CharacterStats _stats, Character m_character)
        {
            if (m_character == null || !m_character.IsAI || m_character.Faction == Character.Factions.Player)
            {
                //Debug.Log("trying to set stats for a null character, or a non-AI character");
                return;
            }

            if (FixedEnemies.Contains(m_character.UID))
            {
                // Debug.Log("Fixed enemies already contains " + m_character.Name);
                return;
            }

            var m_staminaUseModiifers = new Stat(1f);

            m_staminaUseModiifers.AddMultiplierStack(new StatStack("MyStat", -0.9f));

            if ((bool)_config.GetValue(Settings.Enemy_Balancing))
            {
                string stackSource = "CombatOverhaul";

                if (!PhotonNetwork.isNonMasterClientInRoom)
                {
                    // set health modifier
                    var healthTag   = TagSourceManager.Instance.GetTag("77"); // 77 = max health
                    var healthStack = new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_Health) - 1);
                    _stats.RemoveStatStack(healthTag, stackSource, true);
                    _stats.AddStatStack(healthTag, healthStack, true);
                    At.SetField(_stats, "m_health", _stats.CurrentHealth * (float)_config.GetValue(Settings.Enemy_Health));
                }

                // set impact resistance
                var impactTag = TagSourceManager.Instance.GetTag("84"); // 84 = impact res
                _stats.RemoveStatStack(impactTag, stackSource, false);
                var impactStack = new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_ImpactRes));
                _stats.AddStatStack(impactTag, impactStack, false);

                // damage bonus
                var damageTag = TagSourceManager.Instance.GetTag("96"); // 96 = all damage bonus
                _stats.RemoveStatStack(damageTag, stackSource, true);
                var damageStack = new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_Damages) * 0.01f);
                _stats.AddStatStack(damageTag, damageStack, true);

                // impact modifier
                var impactModifier = At.GetField(_stats, "m_impactModifier") as Stat;
                impactModifier.RemoveStack(stackSource, true);
                impactModifier.AddStack(new StatStack(stackSource, (float)_config.GetValue(Settings.Enemy_ImpactDmg) * 0.01f), true);

                for (int i = 0; i < 6; i++)
                {
                    // damage resistance (Capped at 99, unless already 100)
                    float currentRes = m_character.Stats.GetDamageResistance((DamageType.Types)i);
                    if (currentRes < 100)
                    {
                        var valueToSet = (float)_config.GetValue(Settings.Enemy_Resistances);

                        if (currentRes + valueToSet >= 99)
                        {
                            valueToSet = 99 - currentRes;
                        }

                        int tag          = 113 + i; // 113 to 118 = damage resistance stats
                        var damageResTag = TagSourceManager.Instance.GetTag(tag.ToString());
                        _stats.RemoveStatStack(damageResTag, stackSource, true);
                        var resStack = new StatStack(stackSource, valueToSet);
                        _stats.AddStatStack(damageResTag, resStack, false);
                    }
                }
            }

            if ((bool)_config.GetValue(Settings.All_Enemies_Allied))
            {
                m_character.ChangeFaction(Character.Factions.Bandits);
                m_character.TargetingSystem.AlliedToSameFaction = true;

                Character.Factions[] targets = new Character.Factions[] { Character.Factions.Player };
                At.SetField(m_character.TargetingSystem, "TargetableFactions", targets);

                // fix skills
                foreach (var uid in m_character.Inventory.SkillKnowledge.GetLearnedActiveSkillUIDs())
                {
                    if (ItemManager.Instance.GetItem(uid) is Skill skill)
                    {
                        foreach (Shooter shooter in skill.GetComponentsInChildren <Shooter>())
                        {
                            shooter.Setup(targets, shooter.transform.parent);
                        }
                    }
                }
            }

            FixedEnemies.Add(m_character.UID);
        }
Beispiel #25
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="config">The mod configuration.</param>
 public PickaxeAttachment(ModConfig config)
 {
     this.BreakFlooring = config.PickaxeBreaksFlooring;
     this.ClearDirt     = config.PickaxeClearsDirt;
 }
Beispiel #26
0
        public void ConstructUI(GameObject parent)
        {
            var mainObj = UIFactory.CreateVerticalGroup(parent, new Color(0.1f, 0.1f, 0.1f, 1.0f));

            var mainGroup = mainObj.GetComponent <VerticalLayoutGroup>();

            mainGroup.childControlHeight     = true;
            mainGroup.childControlWidth      = true;
            mainGroup.childForceExpandHeight = true;
            mainGroup.childForceExpandWidth  = true;

            var mainImage = mainObj.GetComponent <Image>();

            mainImage.maskable = true;

            var mask = mainObj.AddComponent <Mask>();

            mask.showMaskGraphic = true;

            var mainLayout = mainObj.AddComponent <LayoutElement>();

            mainLayout.minHeight      = 190;
            mainLayout.flexibleHeight = 0;

            #region LOG AREA
            var logAreaObj   = UIFactory.CreateHorizontalGroup(mainObj);
            var logAreaGroup = logAreaObj.GetComponent <HorizontalLayoutGroup>();
            logAreaGroup.childControlHeight     = true;
            logAreaGroup.childControlWidth      = true;
            logAreaGroup.childForceExpandHeight = true;
            logAreaGroup.childForceExpandWidth  = true;

            var logAreaLayout = logAreaObj.AddComponent <LayoutElement>();
            logAreaLayout.preferredHeight = 190;
            logAreaLayout.flexibleHeight  = 0;

            var inputScrollerObj = UIFactory.CreateSrollInputField(logAreaObj, out InputFieldScroller inputScroll, 14, new Color(0.05f, 0.05f, 0.05f));

            inputScroll.inputField.textComponent.font = UIManager.ConsoleFont;
            inputScroll.inputField.readOnly           = true;

            m_textInput = inputScroll.inputField;
            #endregion

            #region BOTTOM BAR

            var           bottomBarObj = UIFactory.CreateHorizontalGroup(mainObj);
            LayoutElement topBarLayout = bottomBarObj.AddComponent <LayoutElement>();
            topBarLayout.minHeight      = 30;
            topBarLayout.flexibleHeight = 0;

            var bottomGroup = bottomBarObj.GetComponent <HorizontalLayoutGroup>();
            bottomGroup.padding.left           = 10;
            bottomGroup.padding.right          = 10;
            bottomGroup.padding.top            = 2;
            bottomGroup.padding.bottom         = 2;
            bottomGroup.spacing                = 10;
            bottomGroup.childForceExpandHeight = true;
            bottomGroup.childForceExpandWidth  = false;
            bottomGroup.childControlWidth      = true;
            bottomGroup.childControlHeight     = true;
            bottomGroup.childAlignment         = TextAnchor.MiddleLeft;

            // Debug Console label

            var bottomLabel       = UIFactory.CreateLabel(bottomBarObj, TextAnchor.MiddleLeft);
            var topBarLabelLayout = bottomLabel.AddComponent <LayoutElement>();
            topBarLabelLayout.minWidth      = 100;
            topBarLabelLayout.flexibleWidth = 0;
            var topBarText = bottomLabel.GetComponent <Text>();
            topBarText.fontStyle = FontStyle.Bold;
            topBarText.text      = "Debug Console";
            topBarText.fontSize  = 14;

            // Hide button

            var hideButtonObj = UIFactory.CreateButton(bottomBarObj);

            var hideBtnText = hideButtonObj.GetComponentInChildren <Text>();
            hideBtnText.text = "Hide";

            var hideButton = hideButtonObj.GetComponent <Button>();

            hideButton.onClick.AddListener(HideCallback);
            void HideCallback()
            {
                if (logAreaObj.activeSelf)
                {
                    logAreaObj.SetActive(false);
                    hideBtnText.text     = "Show";
                    mainLayout.minHeight = 30;
                }
                else
                {
                    logAreaObj.SetActive(true);
                    hideBtnText.text     = "Hide";
                    mainLayout.minHeight = 190;
                }
            }

            var hideBtnColors = hideButton.colors;
            //hideBtnColors.normalColor = new Color(160f / 255f, 140f / 255f, 40f / 255f);
            hideButton.colors = hideBtnColors;

            var hideBtnLayout = hideButtonObj.AddComponent <LayoutElement>();
            hideBtnLayout.minWidth      = 80;
            hideBtnLayout.flexibleWidth = 0;

            // Clear button

            var clearButtonObj = UIFactory.CreateButton(bottomBarObj);

            var clearBtnText = clearButtonObj.GetComponentInChildren <Text>();
            clearBtnText.text = "Clear";

            var clearButton = clearButtonObj.GetComponent <Button>();

            clearButton.onClick.AddListener(ClearCallback);
            void ClearCallback()
            {
                m_textInput.text = "";
                AllMessages.Clear();
            }

            var clearBtnColors = clearButton.colors;
            //clearBtnColors.normalColor = new Color(160f/255f, 140f/255f, 40f/255f);
            clearButton.colors = clearBtnColors;

            var clearBtnLayout = clearButtonObj.AddComponent <LayoutElement>();
            clearBtnLayout.minWidth      = 80;
            clearBtnLayout.flexibleWidth = 0;

            // Unity log toggle

            var unityToggleObj = UIFactory.CreateToggle(bottomBarObj, out Toggle unityToggle, out Text unityToggleText);

            unityToggle.onValueChanged.AddListener(ToggleLogUnity);

            unityToggle.isOn          = LogUnity;
            unityToggleText.text      = "Print Unity Debug?";
            unityToggleText.alignment = TextAnchor.MiddleLeft;

            void ToggleLogUnity(bool val)
            {
                LogUnity = val;
                ModConfig.Instance.Log_Unity_Debug = val;
                ModConfig.SaveSettings();
            }

            var unityToggleLayout = unityToggleObj.AddComponent <LayoutElement>();
            unityToggleLayout.minWidth      = 170;
            unityToggleLayout.flexibleWidth = 0;

            var unityToggleRect = unityToggleObj.transform.Find("Background").GetComponent <RectTransform>();
            var pos             = unityToggleRect.localPosition;
            pos.y = -4;
            unityToggleRect.localPosition = pos;

            //            // Save to disk button

            //            var saveToDiskObj = UIFactory.CreateToggle(bottomBarObj, out Toggle diskToggle, out Text diskToggleText);

            //            diskToggle.onValueChanged.AddListener(ToggleDisk);

            //            diskToggle.isOn = SaveToDisk;
            //            diskToggleText.text = "Save logs to 'Mods\\UnityExplorer\\Logs'?";
            //            diskToggleText.alignment = TextAnchor.MiddleLeft;

            //            void ToggleDisk(bool val)
            //            {
            //                SaveToDisk = val;
            //                ModConfig.Instance.Save_Logs_To_Disk = val;
            //                ModConfig.SaveSettings();
            //            }

            //            var diskToggleLayout = saveToDiskObj.AddComponent<LayoutElement>();
            //            diskToggleLayout.minWidth = 340;
            //            diskToggleLayout.flexibleWidth = 0;

            //            var saveToDiskRect = saveToDiskObj.transform.Find("Background").GetComponent<RectTransform>();
            //            pos = unityToggleRect.localPosition;
            //            pos.y = -8;
            //            saveToDiskRect.localPosition = pos;

            #endregion
        }
Beispiel #27
0
        internal PetTask(ModConfig config)
        {
            _config = config;

            SettingsMenu.ReportConfigChanged += SettingsMenu_ReportConfigChanged;
        }
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            this.Config = helper.ReadConfig <ModConfig>();

            ControlEvents.KeyPressed += this.ControlEvents_KeyPressed;
        }
Beispiel #29
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
        public override void Entry(IModHelper helper)
        {
            this.Config = helper.ReadConfig <ModConfig>();

            InputEvents.ButtonPressed += this.InputEvents_ButtonPressed;
        }
Beispiel #30
0
 public override bool AcceptClientChanges(ModConfig pendingConfig, int whoAmI, ref string message)
 {
     message = "Only the host of this world can change the config! Do so in singleplayer.";
     //Because of NoSync
     return(false);
 }