Exemplo n.º 1
0
        public static bool Prefix(InventoryPage __instance, int x, int y)
        {
            var necklaceSlot = __instance.equipmentIcons.First(cc => cc.myID == 123450101);

            if (necklaceSlot.containsPoint(x, y))
            {
                var necklaceItem = Game1.player.get_necklaceItem();
                if (Game1.player.CursorSlotItem == null || Game1.player.CursorSlotItem is Necklace)
                {
                    Item tmp  = Mod.instance.Helper.Reflection.GetMethod(__instance, "takeHeldItem").Invoke <Item>();
                    Item held = necklaceItem.Value;
                    if (held != null)
                    {
                        (held as Necklace).OnUnequip(Game1.player);
                    }
                    held = Utility.PerformSpecialItemGrabReplacement(held);
                    Mod.instance.Helper.Reflection.GetMethod(__instance, "setHeldItem").Invoke(held);
                    necklaceItem.Value = tmp;

                    LevelUpMenu.RevalidateHealth(Game1.player);

                    if (necklaceItem.Value != null)
                    {
                        (necklaceItem.Value as Necklace).OnEquip(Game1.player);
                        Game1.playSound("crit");
                    }
                    else if (Game1.player.CursorSlotItem != null)
                    {
                        Game1.playSound("dwop");
                    }
                }
                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>Toggle a player profession.</summary>
        /// <param name="id">The profession ID.</param>
        /// <param name="enable">Whether to enable the profession (else disable).</param>
        /// <remarks>Derived from <see cref="LevelUpMenu.getImmediateProfessionPerk"/>.</remarks>
        private void SetProfession(int id, bool enable)
        {
            // skip if done
            if (enable == this.GetProfession(id))
            {
                return;
            }

            // get health bonus for profession
            int healthBonus = id switch
            {
                Farmer.fighter => 15,
                Farmer.defender => 25,
                _ => 0
            };

            // apply
            Farmer player = Game1.player;

            if (enable)
            {
                player.maxHealth += healthBonus;
                player.health    += healthBonus;
                player.professions.Add(id);
            }
            else
            {
                player.health    -= healthBonus;
                player.maxHealth -= healthBonus;
                player.professions.Remove(id);
            }
            LevelUpMenu.RevalidateHealth(player);
        }
    }
Exemplo n.º 3
0
 /// <summary>Reset all skills and professions for the local player.</summary>
 /// <param name="command">The console command.</param>
 /// <param name="args">The supplied arguments.</param>
 private void _ResetLocalPlayerProfessions(string command, string[] args)
 {
     Game1.player.FarmingLevel  = 0;
     Game1.player.FishingLevel  = 0;
     Game1.player.ForagingLevel = 0;
     Game1.player.MiningLevel   = 0;
     Game1.player.CombatLevel   = 0;
     Game1.player.newLevels.Clear();
     Game1.player.professions.Clear();
     LevelUpMenu.RevalidateHealth(Game1.player);
 }
 /// <inheritdoc/>
 public override void OnDayStarted(object sender, DayStartedEventArgs e)
 {
     AwesomeProfessions.EventManager.SubscribeMissingEvents();
     AwesomeProfessions.EventManager.CleanUpRogueEvents();
     LevelUpMenu.RevalidateHealth(Game1.player);
 }