Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using Microsoft.Xna.Framework;
- using StardewModdingAPI;
- using StardewModdingAPI.Events;
- using StardewModdingAPI.Utilities;
- using StardewValley;
- namespace LuckyShoes
- {
- /// <summary>The mod entry point.</summary>
- public class ModEntry : Mod
- {
- /// <summary>The mod entry point, called after the mod is first loaded.</summary>
- /// <param name="helper">Provides simplified APIs for writing mods.</param>
- ///
- private int leprechaunShoes = 14;
- private bool isWearingLeprechaunShoes = false;
- public override void Entry(IModHelper helper)
- {
- helper.Events.GameLoop.UpdateTicked += onUpdateTicked;
- //helper.Events.Player.InventoryChanged += onInventoryChanged;
- }
- private void onUpdateTicked(object sender, UpdateTickedEventArgs e)
- {
- if (!Context.IsWorldReady)
- {
- return;
- }
- else if (e.IsOneSecond)
- {
- this.equippedBoots();
- if (isWearingLeprechaunShoes == true)
- {
- this.giveBuff();
- Monitor.Log($"Buff applied.", LogLevel.Debug);
- }
- else
- {
- this.buffOff();
- this.doNothing();
- }
- }
- }
- private void giveBuff()
- {
- Buff luckBuff = Game1.buffsDisplay.otherBuffs.Find(b => b.source == "Lucky");
- if (luckBuff == null)
- {
- luckBuff = new Buff(0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 100, "Lucky", "Lucky");
- Game1.buffsDisplay.addOtherBuff(luckBuff);
- Monitor.Log($"Adding luck buff.", LogLevel.Debug);
- }
- else if (luckBuff != null)
- {
- return;
- }
- }
- private void buffOff()
- {
- Buff luckBuff = Game1.buffsDisplay.otherBuffs.Find(b => b.source == "Lucky");
- if (luckBuff != null)
- {
- luckBuff.removeBuff();
- Game1.buffsDisplay.otherBuffs.Remove(luckBuff);
- Monitor.Log($"Removing luck buff.", LogLevel.Debug);
- }
- else if (luckBuff == null)
- {
- return;
- }
- }
- private void equippedBoots()
- {
- var currentBoots = Game1.player.shoes.Value;
- Monitor.Log($"Current boots value is {currentBoots}.", LogLevel.Debug);
- if (currentBoots != leprechaunShoes)
- {
- Monitor.Log($"Boots are not Lucky Shoes.", LogLevel.Debug);
- isWearingLeprechaunShoes = false;
- return;
- }
- else
- {
- isWearingLeprechaunShoes = true;
- Monitor.Log($"Player is wearing correct boots? {isWearingLeprechaunShoes}.", LogLevel.Debug);
- }
- }
- private void doNothing()
- {
- Monitor.Log($"We're doing nothing", LogLevel.Debug);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment