public override void Arrived(Caravan caravan)
        {
            List <Thing> list = CaravanInventoryUtility.TakeThings(caravan, (Thing thing) =>
            {
                if (quest.RequestItems.ContainsKey(thing.def))
                {
                    int remaining = quest.RequestItems[thing.def];

                    int num    = Mathf.Min(remaining, thing.stackCount);
                    remaining -= num;
                    quest.RequestItems[thing.def] = remaining;

                    return(num);
                }

                return(0);
            });

            for (int i = 0; i < list.Count; i++)
            {
                list[i].Destroy();
            }

            QuestSite site = (QuestSite)mapParent;

            site.EndQuest(caravan, EndCondition.Success);
        }
Exemplo n.º 2
0
 public override void Notify_CaravanFormed(QuestSite site, Caravan caravan)
 {
     if (Won)
     {
         site.EndQuest(caravan, EndCondition.Success);
     }
 }
        private void TryTransfer(Caravan caravan)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("Quest_MissingPeople_End".Translate());
            int saved = 0;

            foreach (var pawn in quest.SavedPawns)
            {
                if (caravan.ContainsPawn(pawn))
                {
                    caravan.RemovePawn(pawn);
                    saved++;
                    builder.AppendLine($"- {pawn.Name.ToStringFull}");
                    pawn.Destroy();
                }
            }

            EndCondition condition = EndCondition.Success;

            if (saved == quest.SavedPawns.Count)
            {
                builder.Append("Quest_MissingPeople_EndFull".Translate(Quest.Faction.Name));
            }
            else
            {
                if (saved == 0)
                {
                    builder.Append("Quest_MissingPeople_Fiasko".Translate(Quest.Faction.Name));
                    condition = EndCondition.Fail;
                }
                else
                {
                    builder.Append("Quest_MissingPeople_EndPart".Translate());
                }
            }

            if (caravan.pawns.Count == 0)
            {
                Find.WorldObjects.Remove(caravan);
            }

            Find.LetterStack.ReceiveLetter("Quest_MissingPeople_EndQuest".Translate(), builder.ToString(), LetterDefOf.NeutralEvent);
            QuestSite site = (QuestSite)mapParent;

            site.EndQuest(caravan, condition);
        }