minervamaga

Untitled

Mar 10th, 2020
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.23 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using Microsoft.Xna.Framework;
  4. using StardewModdingAPI;
  5. using StardewModdingAPI.Events;
  6. using StardewModdingAPI.Utilities;
  7. using StardewValley;
  8.  
  9. namespace LuckyShoes
  10. {
  11.     /// <summary>The mod entry point.</summary>
  12.     public class ModEntry : Mod
  13.     {
  14.         /// <summary>The mod entry point, called after the mod is first loaded.</summary>
  15.         /// <param name="helper">Provides simplified APIs for writing mods.</param>
  16.         ///
  17.         private int leprechaunShoes = 14;
  18.         private bool isWearingLeprechaunShoes = false;
  19.  
  20.         public override void Entry(IModHelper helper)
  21.         {
  22.             helper.Events.GameLoop.UpdateTicked += onUpdateTicked;
  23.             //helper.Events.Player.InventoryChanged += onInventoryChanged;
  24.  
  25.         }
  26.  
  27.         private void onUpdateTicked(object sender, UpdateTickedEventArgs e)
  28.         {
  29.             if (!Context.IsWorldReady)
  30.             {
  31.                 return;
  32.             }
  33.            
  34.             else if (e.IsOneSecond)
  35.             {
  36.                 this.equippedBoots();
  37.  
  38.                 if (isWearingLeprechaunShoes == true)
  39.                 {
  40.                     this.giveBuff();
  41.                     Monitor.Log($"Buff applied.", LogLevel.Debug);
  42.                 }
  43.                 else
  44.                 {
  45.                     this.buffOff();
  46.                     this.doNothing();
  47.                 }
  48.             }
  49.            
  50.         }
  51.  
  52.         private void giveBuff()
  53.         {
  54.  
  55.             Buff luckBuff = Game1.buffsDisplay.otherBuffs.Find(b => b.source == "Lucky");
  56.  
  57.             if (luckBuff == null)
  58.             {
  59.  
  60.                 luckBuff = new Buff(0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 100, "Lucky", "Lucky");
  61.                 Game1.buffsDisplay.addOtherBuff(luckBuff);
  62.                 Monitor.Log($"Adding luck buff.", LogLevel.Debug);
  63.             }
  64.  
  65.             else if (luckBuff != null)
  66.             {
  67.                 return;
  68.             }
  69.            
  70.         }
  71.         private void buffOff()
  72.         {
  73.  
  74.             Buff luckBuff = Game1.buffsDisplay.otherBuffs.Find(b => b.source == "Lucky");
  75.  
  76.             if (luckBuff != null)
  77.             {
  78.  
  79.                 luckBuff.removeBuff();
  80.                 Game1.buffsDisplay.otherBuffs.Remove(luckBuff);
  81.                 Monitor.Log($"Removing luck buff.", LogLevel.Debug);
  82.             }
  83.  
  84.             else if (luckBuff == null)
  85.             {
  86.                 return;
  87.             }
  88.  
  89.         }
  90.  
  91.         private void equippedBoots()
  92.         {
  93.             var currentBoots = Game1.player.shoes.Value;
  94.             Monitor.Log($"Current boots value is {currentBoots}.", LogLevel.Debug);
  95.  
  96.             if (currentBoots != leprechaunShoes)
  97.             {
  98.                 Monitor.Log($"Boots are not Lucky Shoes.", LogLevel.Debug);
  99.                 isWearingLeprechaunShoes = false;
  100.                 return;
  101.             }
  102.             else
  103.             {
  104.                 isWearingLeprechaunShoes = true;
  105.                 Monitor.Log($"Player is wearing correct boots? {isWearingLeprechaunShoes}.", LogLevel.Debug);
  106.             }
  107.         }
  108.  
  109.         private void doNothing()
  110.         {
  111.             Monitor.Log($"We're doing nothing", LogLevel.Debug);
  112.         }
  113.  
  114.     }
  115. }
Advertisement
Add Comment
Please, Sign In to add comment