コード例 #1
0
 /// <summary>The method to call before <see cref="FishingRod.attach"/>.</summary>
 private static bool Before_Attach(FishingRod __instance, StardewValley.Object o, ref StardewValley.Object __result)
 {
     if (o != null && o.Category == -21 && __instance.UpgradeLevel > 1)
     {
         StardewValley.Object tmp = __instance.attachments[0];
         if (tmp != null && tmp.canStackWith(o))
         {
             tmp.Stack = o.addToStack(tmp);
             if (tmp.Stack <= 0)
             {
                 tmp = null;
             }
         }
         __instance.attachments[0] = o;
         Game1.playSound("button1");
         __result = tmp;
         return(false);
     }
     if (o != null && o.Category == -22 && __instance.UpgradeLevel > 2)
     {
         // Rewrote this portion
         bool hasEnchant = __instance.hasEnchantmentOfType <MoreLuresEnchantment>();
         if (__instance.attachments[1] == null)
         {
             __instance.attachments[1] = o;
         }
         else if (__instance.attachments[2] == null && hasEnchant)
         {
             __instance.attachments[2] = o;
         }
         else if (__instance.attachments[2] != null && hasEnchant)
         {
             __result = __instance.attachments[2];
             __instance.attachments[2] = o;
         }
         else if (__instance.attachments[1] != null)
         {
             __result = __instance.attachments[1];
             __instance.attachments[1] = o;
         }
         Game1.playSound("button1");
         return(false);
     }
     if (o == null)
     {
         if (__instance.attachments[0] != null)
         {
             StardewValley.Object result2 = __instance.attachments[0];
             __instance.attachments[0] = null;
             Game1.playSound("dwop");
             __result = result2;
             return(false);
         }
         if (__instance.attachments[2] != null)
         {
             StardewValley.Object result3 = __instance.attachments[2];
             __instance.attachments[2] = null;
             Game1.playSound("dwop");
             __result = result3;
             return(false);
         }
         if (__instance.attachments[1] != null)
         {
             StardewValley.Object result3 = __instance.attachments[1];
             __instance.attachments[1] = null;
             Game1.playSound("dwop");
             __result = result3;
             return(false);
         }
     }
     __result = null;
     return(false);
 }