コード例 #1
0
 public static bool Prefix(SObject __instance, Vector2 tileLocation, GameLocation environment)
 {
     try
     {
         //  Example: If you combined 3 furnaces together and placed it on a tile, then when you remove it, the Game will already refund 1 of them, so this patch is intended to
         //  refund the other 2 combined quantity
         if (__instance.IsCombinableObject() && __instance.TryGetCombinedQuantity(out int CombinedQuantity) && CombinedQuantity > 1)
         {
             SObject CombinedRefund = new SObject(Vector2.Zero, __instance.ParentSheetIndex, false)
             {
                 Stack = CombinedQuantity - 1
             };
             Game1.createItemDebris(CombinedRefund, tileLocation * 64f, (Game1.player.FacingDirection + 2) % 4, null, -1);
         }
         return(true);
     }
     catch (Exception ex)
     {
         ModEntry.Logger.Log(string.Format("Unhandled Error in {0}.{1}:\n{2}", nameof(PerformRemoveActionPatch), nameof(Prefix), ex), LogLevel.Error);
         return(true);
     }
 }