public override void OnComplete()
        {
            var faction = Find.FactionManager.RandomNonHostileFaction(minTechLevel: TechLevel.Industrial);

            if (faction == null)
            {
                faction = FactionGenerator.NewGeneratedFaction();
            }
            faction.TryAffectGoodwillWith(Faction.OfPlayer, 50);
            target.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -50);
            faction.TryAffectGoodwillWith(target.Faction, -200);
            target.SetFaction(faction);

            var map = target.Map;

            if (map == null)
            {
                return;
            }
            var storyComp = Find.Storyteller.storytellerComps.First(x => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
            var parms     = storyComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, map);

            parms.faction         = faction;
            parms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
            parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
            parms.raidArrivalModeForQuickMilitaryAid = true;
            parms.points = 4000;
            IncidentDefOf.RaidFriendly.Worker.TryExecute(parms);
        }
        public override void OnTick()
        {
            var map = Find.CurrentMap;

            if (map != null && map.Parent == target && (Find.TickManager.TicksGame - map.generationTick + 1) % 1000 == 0)
            {
                Complete();
                var storyComp = Find.Storyteller.storytellerComps.First(x => x is StorytellerComp_OnOffCycle || x is StorytellerComp_RandomMain);
                var parms     = storyComp.GenerateParms(IncidentCategoryDefOf.ThreatBig, map);
                parms.faction         = alliedFaction;
                parms.raidStrategy    = RaidStrategyDefOf.ImmediateAttackFriendly;
                parms.raidArrivalMode = PawnsArrivalModeDefOf.EdgeWalkIn;
                parms.raidArrivalModeForQuickMilitaryAid = true;
                parms.points = 5000;
                IncidentDefOf.RaidFriendly.Worker.TryExecute(parms);

                target.SetFaction(alliedFaction);
            }
        }
 public override void OnExpire()
 {
     target.SetFaction(alliedFaction);
 }