public override void ChooseParts()
 {
     base.ChooseParts();
     alliedFaction = Find.FactionManager.RandomAlliedFaction(minTechLevel: TechLevel.Industrial);
     //alliedFaction = Find.FactionManager.RandomNonHostileFaction(minTechLevel: TechLevel.Industrial);
     target = Find.WorldObjects.Settlements
              .Where(s => s is City && s.Faction.HostileTo(Faction.OfPlayer) &&
                     QuestUtility.Reachable(HomeMap?.Parent, s, 50) &&
                     !s.HasMap)
              .RandomElementWithFallback() as City;
 }
Ejemplo n.º 2
0
        public override void OnResult(Quest quest)
        {
            var map = quest.HomeMap;
            var pos = QuestUtility.FindDropSpot(map);

            DropPodUtility.DropThingsNear(pos, map, things, canRoofPunch: false);
            Find.LetterStack.ReceiveLetter(
                "QuestReceivedLabel".Translate(),
                "QuestReceived".Translate().Formatted(Label),
                LetterDefOf.NeutralEvent,
                new LookTargets(pos, map));
        }
Ejemplo n.º 3
0
        public static T RandomByDistance <T>(this IEnumerable <T> source, WorldObject start, int max)
            where T : WorldObject
        {
            var collection = source
                             .Where(s => QuestUtility.Reachable(start, s))
                             .ToArray();

            var filtered = collection
                           .Where(s => Find.WorldGrid.ApproxDistanceInTiles(start.Tile, s.Tile) <= max)
                           .ToArray();

            return(filtered.RandomElementWithFallback()
                   ?? (collection.Length == 0
                       ? null
                       : collection.MinBy(s => Find.WorldGrid.ApproxDistanceInTiles(start.Tile, s.Tile))));
        }
        public override void ChooseParts()
        {
            base.ChooseParts();
            city = Find.WorldObjects.Settlements
                   .Where(s => s is City city && city.Visitable && !city.Abandoned &&
                          QuestUtility.Reachable(HomeMap?.Parent, s, 50) &&
                          !s.HasMap)
                   .RandomElementWithFallback() as City;
            if (city == null)
            {
                return;
            }
            var faction = city.Faction;

            pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(faction.RandomPawnKind(), faction, PawnGenerationContext.NonPlayer, city.Tile));
            Find.World.worldPawns.PassToWorld(pawn, PawnDiscardDecideMode.KeepForever);
        }
Ejemplo n.º 5
0
        public override void MapComponentTick()
        {
            if ((Find.TickManager.TicksGame + map.Parent.ID) % EventTimeCycle == 0)
            {
                if (!LoadedModManager.GetMod <Mod_Cities>().GetSettings <ModSettings_Cities>().enableEvents)
                {
                    return;
                }

                if (map.Parent is City city && !city.Abandoned)
                {
                    if (city.Faction.HostileTo(Faction.OfPlayer))
                    {
                        var storyComp = Find.Storyteller.storytellerComps.First(x => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                        var parms     = storyComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, map);
                        parms.faction         = city.Faction;
                        parms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
                        parms.raidArrivalMode = DefDatabase <PawnsArrivalModeDef> .GetRandom();

                        parms.raidArrivalModeForQuickMilitaryAid = true;
                        parms.points += RaidPointIncrease;
                        IncidentDefOf.RaidEnemy.Worker.TryExecute(parms);
                    }
                    else
                    {
                        var pos       = QuestUtility.FindDropSpot(map);
                        var things    = new List <Thing>();
                        var foodCount = (int)(map.mapPawns.SpawnedPawnsInFaction(map.ParentFaction).Count *EventTimeCycle / 60000F * DailyFoodGivenPerPerson);
                        for (var i = 0; i < foodCount; i++)
                        {
                            var thing = ThingMaker.MakeThing(ThingDefOf.MealSurvivalPack);
                            map.GetComponent <MapComponent_City>().cityOwnedThings.Add(thing);
                            things.Add(thing);
                        }
                        DropPodUtility.DropThingsNear(pos, map, things, canRoofPunch: false);
                    }
                }
            }
        }