Beispiel #1
0
 private static void Prefix(ref Player __instance, ref float v)
 {
     if (Configuration.Current.StaminaUsage.IsEnabled)
     {
         string methodName = new StackTrace().GetFrame(2).GetMethod().Name;
         if (methodName.Contains(nameof(Player.UpdatePlacement)) || methodName.Contains(nameof(Player.Repair)) || methodName.Contains(nameof(Player.RemovePiece)))
         {
             string itemName = __instance.GetRightItem()?.m_shared.m_name;
             if (itemName == "$item_hammer")
             {
                 v = Helper.applyModifierValue(v, Configuration.Current.StaminaUsage.hammer);
             }
             else if (itemName == "$item_hoe")
             {
                 v = Helper.applyModifierValue(v, Configuration.Current.StaminaUsage.hoe);
             }
             else if (itemName == "$item_cultivator")
             {
                 v = Helper.applyModifierValue(v, Configuration.Current.StaminaUsage.cultivator);
             }
         }
         else if (methodName.Equals(nameof(Player.PlayerAttackInput)))
         {
             ItemDrop.ItemData item = __instance.GetCurrentWeapon();
             if (item?.m_shared.m_skillType == Skills.SkillType.Bows)
             {
                 v = Helper.applyModifierValue(v, Configuration.Current.StaminaUsage.bows);
             }
         }
         else if (methodName.Equals(nameof(Player.BlockAttack)))
         {
             v = Helper.applyModifierValue(v, Configuration.Current.StaminaUsage.blocking);
         }
     }
 }
Beispiel #2
0
        public void Exhibit_Value_Equality()
        {
            var stack0 = new StackTrace(new StackFrame[0]);
            var stack1 = new StackTrace(new StackFrame[0]);
            var stack2 = new StackTrace(new[]
            {
                new StackFrame(100, null, null, null, 0)
            });
            var stack3 = new StackTrace(new[]
            {
                new StackFrame(100, null, null, null, 0)
            });
            var stack4 = new StackTrace(new[]
            {
                new StackFrame(101, null, null, null, 0)
            });

            stack0.Equals(stack0).Should().BeTrue();
            stack0.Equals(null).Should().BeFalse();
            stack0.Equals((object)null).Should().BeFalse();
            stack0.Equals(new object()).Should().BeFalse();
            stack1.Equals(stack0).Should().BeTrue();
            stack2.Equals(stack1).Should().BeFalse();
            stack2.Equals(stack3).Should().BeTrue();
            stack3.Equals(stack4).Should().BeFalse();
            stack0.GetHashCode().Should().Be(stack1.GetHashCode());
            stack2.GetHashCode().Should().Be(stack3.GetHashCode());
            stack0.GetHashCode().Should().NotBe(stack3.GetHashCode());
        }