示例#1
0
 private void TrySatisfyFoodNeed(Pawn pawn, Need_Food food)
 {
     if ((int)food.CurCategory >= 1)
     {
         Thing food2;
         Pawn  owner;
         if (VirtualPlantsUtility.CanEatVirtualPlantsNow(pawn))
         {
             VirtualPlantsUtility.EatVirtualPlants(pawn);
         }
         else if (CaravanInventoryUtility.TryGetBestFood(caravan, pawn, out food2, out owner))
         {
             food.CurLevel += food2.Ingested(pawn, food.NutritionWanted);
             if (food2.Destroyed)
             {
                 if (owner != null)
                 {
                     owner.inventory.innerContainer.Remove(food2);
                     caravan.RecacheImmobilizedNow();
                     caravan.RecacheDaysWorthOfFood();
                 }
                 if (!caravan.notifiedOutOfFood && !CaravanInventoryUtility.TryGetBestFood(caravan, pawn, out food2, out owner))
                 {
                     Messages.Message("MessageCaravanRanOutOfFood".Translate(caravan.LabelCap, pawn.Label, pawn.Named("PAWN")), caravan, MessageTypeDefOf.ThreatBig);
                     caravan.notifiedOutOfFood = true;
                 }
             }
         }
     }
 }
 private static void TrySatisfyFoodNeed(Pawn pawn, Need_Food food, Caravan caravan)
 {
     if ((int)food.CurCategory >= 1)
     {
         Thing thing = default(Thing);
         Pawn  pawn2 = default(Pawn);
         if (VirtualPlantsUtility.CanEatVirtualPlantsNow(pawn))
         {
             VirtualPlantsUtility.EatVirtualPlants(pawn);
         }
         else if (CaravanInventoryUtility.TryGetBestFood(caravan, pawn, out thing, out pawn2))
         {
             food.CurLevel += thing.Ingested(pawn, food.NutritionWanted);
             if (thing.Destroyed)
             {
                 if (pawn2 != null)
                 {
                     pawn2.inventory.innerContainer.Remove(thing);
                     caravan.RecacheImmobilizedNow();
                     caravan.RecacheDaysWorthOfFood();
                 }
                 if (!CaravanInventoryUtility.TryGetBestFood(caravan, pawn, out thing, out pawn2))
                 {
                     Messages.Message("MessageCaravanRunOutOfFood".Translate(caravan.LabelCap, pawn.Label), caravan, MessageTypeDefOf.ThreatBig);
                 }
             }
         }
     }
 }
示例#3
0
 public static void TryAbandonSpecificCountViaInterface(TransferableImmutable t, Caravan caravan)
 {
     Find.WindowStack.Add(new Dialog_Slider("AbandonSliderText".Translate(t.Label), 1, t.TotalStackCount, delegate(int x)
     {
         int num = x;
         for (int i = 0; i < t.things.Count; i++)
         {
             if (num <= 0)
             {
                 break;
             }
             Thing thing  = t.things[i];
             Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
             if (ownerOf == null)
             {
                 Log.Error("Could not find owner of " + thing);
                 return;
             }
             if (num >= thing.stackCount)
             {
                 num -= thing.stackCount;
                 ownerOf.inventory.innerContainer.Remove(thing);
                 thing.Destroy();
             }
             else
             {
                 thing.SplitOff(num).Destroy();
                 num = 0;
             }
         }
         caravan.RecacheImmobilizedNow();
         caravan.RecacheDaysWorthOfFood();
     }));
 }
示例#4
0
 public static void TryAbandonSpecificCountViaInterface(Thing t, Caravan caravan)
 {
     Find.WindowStack.Add(new Dialog_Slider("AbandonSliderText".Translate(t.LabelNoCount), 1, t.stackCount, delegate(int x)
     {
         Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, t);
         if (ownerOf == null)
         {
             Log.Error("Could not find owner of " + t);
         }
         else
         {
             if (x >= t.stackCount)
             {
                 ownerOf.inventory.innerContainer.Remove(t);
                 t.Destroy();
             }
             else
             {
                 t.SplitOff(x).Destroy();
             }
             caravan.RecacheImmobilizedNow();
             caravan.RecacheDaysWorthOfFood();
         }
     }));
 }
示例#5
0
        public static void TryAbandonOrBanishViaInterface(Thing t, Caravan caravan)
        {
            Pawn p = t as Pawn;

            if (p != null)
            {
                if (!caravan.PawnsListForReading.Any((Pawn x) => x != p && caravan.IsOwner(x)))
                {
                    Messages.Message("MessageCantBanishLastColonist".Translate(), caravan, MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    PawnBanishUtility.ShowBanishPawnConfirmationDialog(p);
                }
            }
            else
            {
                Dialog_MessageBox window = Dialog_MessageBox.CreateConfirmation("ConfirmAbandonItemDialog".Translate(t.Label), delegate
                {
                    Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, t);
                    if (ownerOf == null)
                    {
                        Log.Error("Could not find owner of " + t);
                    }
                    else
                    {
                        ownerOf.inventory.innerContainer.Remove(t);
                        t.Destroy();
                        caravan.RecacheImmobilizedNow();
                        caravan.RecacheDaysWorthOfFood();
                    }
                }, destructive: true);
                Find.WindowStack.Add(window);
            }
        }
示例#6
0
        public static void TryAbandonOrBanishViaInterface(TransferableImmutable t, Caravan caravan)
        {
            Pawn pawn = t.AnyThing as Pawn;

            if (pawn != null)
            {
                TryAbandonOrBanishViaInterface(pawn, caravan);
                return;
            }
            Dialog_MessageBox window = Dialog_MessageBox.CreateConfirmation("ConfirmAbandonItemDialog".Translate(t.LabelWithTotalStackCount), delegate
            {
                for (int i = 0; i < t.things.Count; i++)
                {
                    Thing thing  = t.things[i];
                    Pawn ownerOf = CaravanInventoryUtility.GetOwnerOf(caravan, thing);
                    if (ownerOf == null)
                    {
                        Log.Error("Could not find owner of " + thing);
                        return;
                    }
                    ownerOf.inventory.innerContainer.Remove(thing);
                    thing.Destroy();
                }
                caravan.RecacheImmobilizedNow();
                caravan.RecacheDaysWorthOfFood();
            }, destructive: true);

            Find.WindowStack.Add(window);
        }
示例#7
0
 private static void TrySatisfyFoodNeed(Pawn pawn, Need_Food food, Caravan caravan)
 {
     if (food.CurCategory >= HungerCategory.Hungry)
     {
         Thing thing;
         Pawn  pawn2;
         if (VirtualPlantsUtility.CanEatVirtualPlantsNow(pawn))
         {
             VirtualPlantsUtility.EatVirtualPlants(pawn);
         }
         else if (CaravanInventoryUtility.TryGetBestFood(caravan, pawn, out thing, out pawn2))
         {
             food.CurLevel += thing.Ingested(pawn, food.NutritionWanted);
             if (thing.Destroyed)
             {
                 if (pawn2 != null)
                 {
                     pawn2.inventory.innerContainer.Remove(thing);
                     caravan.RecacheImmobilizedNow();
                     caravan.RecacheDaysWorthOfFood();
                 }
                 if (!caravan.notifiedOutOfFood && !CaravanInventoryUtility.TryGetBestFood(caravan, pawn, out thing, out pawn2))
                 {
                     Messages.Message("MessageCaravanRanOutOfFood".Translate(new object[]
                     {
                         caravan.LabelCap,
                         pawn.Label
                     }), caravan, MessageTypeDefOf.ThreatBig, true);
                     caravan.notifiedOutOfFood = true;
                 }
             }
         }
     }
 }
        public static void IngestDrug(Pawn pawn, Thing drug, Pawn drugOwner, Caravan caravan)
        {
            float     num  = drug.Ingested(pawn, 0f);
            Need_Food food = pawn.needs.food;

            if (food != null)
            {
                food.CurLevel += num;
            }
            if (drug.Destroyed && drugOwner != null)
            {
                drugOwner.inventory.innerContainer.Remove(drug);
                caravan.RecacheImmobilizedNow();
                caravan.RecacheDaysWorthOfFood();
            }
        }