public FloatMenuAcceptanceReport CanGiveRansom(Caravan caravan, MapParent mapParent)
        {
            if (mapParent == null || !mapParent.Spawned)
            {
                return(false);
            }

            var  comp      = ((DoomsdaySite)mapParent).GetComponent <DoomsdayUltimatumComp>();
            int  remaining = 50000 - comp.FactionSilver;
            bool hasSilver = CaravanInventoryUtility.HasThings(caravan, ThingDefOf.Silver, remaining);

            return(hasSilver);
        }
Ejemplo n.º 2
0
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, MapParent mapParent)
        {
            foreach (var option in CaravanArrivalActionUtility.GetFloatMenuOptions(() => caravanAction.CanVisit(caravan, mapParent), () => caravanAction, "EnterMap".Translate(mapParent.Label), caravan, mapParent.Tile, mapParent))
            {
                yield return(option);
            }

            int  reqCount  = 50000 - comp.FactionSilver;
            bool hasSilver = CaravanInventoryUtility.HasThings(caravan, ThingDefOf.Silver, reqCount);

            foreach (var option in CaravanArrivalActionUtility.GetFloatMenuOptions(() => caravanAction2.CanGiveRansom(caravan, mapParent), () => caravanAction2, hasSilver ? "GiveRansom".Translate() : "NotEnoughSilverDoom".Translate(), caravan, mapParent.Tile, mapParent))
            {
                yield return(option);
            }
        }
        private bool PlayerOrItemStashHasAIPersonaCore()
        {
            List <Map> maps = Find.Maps;

            for (int i = 0; i < maps.Count; i++)
            {
                if (maps[i].listerThings.ThingsOfDef(ThingDefOf.AIPersonaCore).Count > 0)
                {
                    return(true);
                }
            }
            List <Caravan> caravans = Find.WorldObjects.Caravans;

            for (int j = 0; j < caravans.Count; j++)
            {
                if (caravans[j].IsPlayerControlled && CaravanInventoryUtility.HasThings(caravans[j], ThingDefOf.AIPersonaCore, 1, null))
                {
                    return(true);
                }
            }
            List <Site> sites = Find.WorldObjects.Sites;

            for (int k = 0; k < sites.Count; k++)
            {
                ItemStashContentsComp component = ((WorldObject)sites[k]).GetComponent <ItemStashContentsComp>();
                if (component != null)
                {
                    ThingOwner contents = component.contents;
                    for (int l = 0; l < contents.Count; l++)
                    {
                        if (contents[l].def == ThingDefOf.AIPersonaCore)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
 private bool CheckItems(Caravan caravan, ThingDef thingDef, int count)
 {
     return(CaravanInventoryUtility.HasThings(caravan, thingDef, count));
 }