Exemplo n.º 1
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            WorldComponent_MFI_AnnualExpo worldComp = Find.World.GetComponent <WorldComponent_MFI_AnnualExpo>();

            if (worldComp == null)
            {
                return(false);
            }

            if (!TryGetRandomAvailableTargetMap(map: out Map map))
            {
                return(false);
            }

            if (map == null)
            {
                return(false);
            }

            if (!TryFindTile(tile: out int tile))
            {
                return(false);
            }

            if (!TryGetFactionHost(out Faction faction))
            {
                return(false);
            }

            AnnualExpo annualExpo = (AnnualExpo)WorldObjectMaker.MakeWorldObject(def: MFI_DefOf.MFI_AnnualExpoObject);

            annualExpo.Tile = tile;
            annualExpo.GetComponent <TimeoutComp>().StartTimeout(TimeoutDaysRange.RandomInRange * GenDate.TicksPerDay);
            worldComp.events.InRandomOrder().TryMinBy(kvp => kvp.Value, out KeyValuePair <EventDef, int> result);
            annualExpo.eventDef = result.Key;
            annualExpo.host     = faction;
            annualExpo.SetFaction(faction);

            worldComp.timesHeld++;
            worldComp.events[result.Key]++;

            Find.WorldObjects.Add(o: annualExpo);
            Find.LetterStack.ReceiveLetter(label: this.def.letterLabel,
                                           text: "MFI_AnnualExpoLetterText".Translate(
                                               Find.ActiveLanguageWorker.OrdinalNumber(worldComp.TimesHeld),
                                               Find.World.info.name,
                                               annualExpo.host.Name,
                                               annualExpo.eventDef.theme,
                                               annualExpo.eventDef.themeDesc),
                                           textLetterDef: this.def.letterDef,
                                           lookTargets: annualExpo);

            return(true);
        }
 private static FloatMenuAcceptanceReport CanVisit(Caravan caravan, AnnualExpo annualExpo)
 {
     return(annualExpo != null && annualExpo.Spawned);
 }
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, AnnualExpo annualExpo)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(acceptanceReportGetter: () => CanVisit(caravan, annualExpo),
                                                            arrivalActionGetter: () => new CaravanArrivalAction_VisitAnnualExpo(annualExpo),
                                                            label: "VisitPeaceTalks".Translate(annualExpo.Label),
                                                            caravan: caravan, pathDestination: annualExpo.Tile,
                                                            revalidateWorldClickTarget: annualExpo));
 }
 public CaravanArrivalAction_VisitAnnualExpo(AnnualExpo annualExpo)
 {
     this.annualExpo = annualExpo;
 }
 private static FloatMenuAcceptanceReport CanVisit(AnnualExpo annualExpo)
 {
     return(annualExpo is { Spawned : true });
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan, AnnualExpo annualExpo)
 {
     return(CaravanArrivalActionUtility.GetFloatMenuOptions(() => CanVisit(annualExpo),
                                                            () => new CaravanArrivalAction_VisitAnnualExpo(annualExpo),
                                                            "VisitPeaceTalks".Translate(annualExpo.Label),
                                                            caravan, annualExpo.Tile,
                                                            annualExpo));
 }