Ejemplo n.º 1
0
 static bool NPCCheckForAction_Prefix(NPC __instance, Farmer who, ref bool __result)
 {
     if (who.ActiveObject?.ParentSheetIndex == giftID)
     {
         temp = who.ActiveObject;
         var fd = who.friendshipData;
         if (fd.ContainsKey(__instance.Name) && fd[__instance.Name].GiftsToday != 0)
         {
             who.ActiveObject = null;
         }
         else
         {
             // ok, we gave somebody a gift, let's see what we got for them
             givingGift = getGift(__instance);
             if (givingGift == null)
             {
                 // TODO: message here
                 return(false);
             }
             var giveObj = new StardewValley.Object(givingGift.Obj.ParentSheetIndex, 1, quality: givingGift.Obj.Quality);
             who.ActiveObject = giveObj;
             Bubbles.Add(__instance, giveObj.ParentSheetIndex);
         }
     }
     return(true);
 }
Ejemplo n.º 2
0
 static void removeFromChest(GiftToGive gg)
 {
     for (int i = 0; i < gg.Chest.items.Count; i++)
     {
         var obj = gg.Chest.items[i] as StardewValley.Object;
         if (obj != null && obj.ParentSheetIndex == gg.Obj.ParentSheetIndex && obj.Quality == gg.Obj.Quality)
         {
             if (obj.Stack == 1)
             {
                 gg.Chest.items.RemoveAt(i);
             }
             else
             {
                 obj.Stack--;
                 gg.Chest.items[i] = obj;
             }
             break;
         }
     }
 }