protected override IEnumerable <Toil> MakeNewToils()
        {
            var followAndAttack = new Toil();

            followAndAttack.initAction = delegate()
            {
                var actor  = followAndAttack.actor;
                var curJob = actor.jobs.curJob;
                var thing  = curJob.GetTarget(this.a).Thing;
                var pawn1  = thing as Pawn;

                pawn1.pather.StopDead();
                pawn1.TakeDamage(new DamageInfo(PurpleIvyDefOf.PI_ToxicExplosion, 3, 0f, -1f, actor, null, null));
                PurpleIvyUtils.DoExplosion(pawn1.Position, actor.Map, 3f, PurpleIvyDefOf.PI_ToxicExplosion, actor);
                if (actor.jobs.curJob != null)
                {
                    actor.jobs.curDriver.Notify_PatherArrived();
                }
                actor.jobs.TryTakeOrderedJob(PurpleIvyUtils.MeleeAttackJob(actor, pawn1));
            };
            followAndAttack.defaultCompleteMode = ToilCompleteMode.Never;
            followAndAttack.EndOnDespawnedOrNull <Toil>(this.a, JobCondition.Succeeded);
            followAndAttack.FailOn <Toil>(new Func <bool>(this.hunterIsKilled));
            yield return(followAndAttack);

            yield break;
        }
示例#2
0
 public void DoDamageToPawn(Pawn pawn)
 {
     if (!pawn.RaceProps.IsMechanoid)
     {
         var damageInfo = new DamageInfo(DamageDefOf.Scratch, 1, 0f, -1f, this, null, null);
         pawn.TakeDamage(damageInfo);
         var hediff = HediffMaker.MakeHediff(PurpleIvyDefOf.PoisonousPurpleHediff,
                                             pawn, null);
         hediff.Severity = 0.1f;
         (pawn).health.AddHediff(hediff, null, null, null);
         var hediff2 = HediffMaker.MakeHediff(PurpleIvyDefOf.HarmfulBacteriaHediff,
                                              pawn, null);
         hediff2.Severity = 0.1f;
         pawn.health.AddHediff(hediff2, null, null, null);
         if (Rand.Chance(0.1f) && pawn.health.hediffSet.GetFirstHediffOfDef(PurpleIvyDefOf.PI_AlienMutation) == null)
         {
             var hediff3 = HediffMaker.MakeHediff(PurpleIvyDefOf.PI_AlienMutation, pawn, null);
             pawn.health.AddHediff(hediff3, null, null, null);
         }
         if (Rand.Chance(0.1f))
         {
             PurpleIvyUtils.MakeFlee(pawn, this);
         }
     }
 }
 public static void Postfix(Map __instance)
 {
     if (__instance.Parent.Faction.def == PurpleIvyDefOf.Genny)
     {
         PurpleIvyUtils.KillAllPawnsExceptAliens(__instance);
     }
 }
示例#4
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map  map = parms.target as Map;
            bool result;
            int  num;

            if (TileFinder.TryFindNewSiteTile(out num, 7, 27, false, true, -1))
            {
                Site site = (Site)WorldObjectMaker.MakeWorldObject(PurpleIvyDefOf.PI_InfectedTile);
                site.Tile = num;
                site.SetFaction(PurpleIvyData.AlienFaction);
                site.AddPart(new SitePart(site, PurpleIvyDefOf.InfectedSite,
                                          PurpleIvyDefOf.InfectedSite.Worker.GenerateDefaultParams
                                              (StorytellerUtility.DefaultSiteThreatPointsNow(), num, PurpleIvyData.AlienFaction)));
                var comp = site.GetComponent <WorldObjectComp_InfectedTile>();
                comp.StartInfection();
                comp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition;
                comp.counter             = 600;
                comp.infectedTile        = site.Tile;
                comp.radius = comp.GetRadius();
                PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter);
                comp.fillRadius(true);
                site.GetComponent <TimeoutComp>().StartTimeout(30 * 60000);
                Find.WorldObjects.Add(site);
                Find.LetterStack.ReceiveLetter("InfectedTile".Translate(),
                                               "InfectedTileDesc".Translate(), LetterDefOf.ThreatBig, site);
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
示例#5
0
 public override void PostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
 {
     if (base.Dead)
     {
         Log.Message("QUEEN DEAD");
         AlienInfectionHediff hediff = (AlienInfectionHediff)HediffMaker.MakeHediff
                                           (PurpleIvyDefOf.PI_AlienInfection, this);
         hediff.instigator = PawnKindDef.Named("Genny_ParasiteOmega");
         var range = new IntRange(30, 50);
         hediff.maxNumberOfCreatures = range.RandomInRange;
         hediff.ageTicks             = new IntRange(40000, 50000).RandomInRange;
         this.health.AddHediff(hediff);
         var corpse = (Corpse)this.ParentHolder;
         PurpleIvyUtils.SpawnNests(this);
     }
     else if (!(dinfo.Instigator is MeteorIncoming))
     {
         var hediff = this.health.hediffSet.hediffs
                      .FirstOrDefault((Hediff h) => h.def == PurpleIvyDefOf.PI_CrashlandedDowned);
         if (hediff != null)
         {
             this.health.hediffSet.hediffs.Remove(hediff);
             RestUtility.Awake(this);
         }
     }
     base.PostApplyDamage(dinfo, totalDamageDealt);
 }
示例#6
0
 public override void ExposeData()
 {
     base.ExposeData();
     Scribe_Values.Look <int>(ref this.weatherEndingTick, "weatherEndingTick", 0, true);
     if (Scribe.mode == LoadSaveMode.PostLoadInit)
     {
         purpleFog.durationRange       = new IntRange(10000, 10000);
         purpleFoggyRain.durationRange = new IntRange(10000, 10000);
         empStorm.durationRange        = new IntRange(10000, 10000);
         foreach (Map map in AffectedMaps)
         {
             var comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>();
             if (comp != null)
             {
                 int  count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count;
                 bool temp;
                 this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp);
             }
             else
             {
                 Log.Message("3 Comp null - GameCondition_PurpleFog");
             }
         }
     }
 }
示例#7
0
        public void SpreadPlants()
        {
            //Pick a random direction cell
            IntVec3 dir = new IntVec3();

            //dir = GenAdj.RandomAdjacentCellCardinal(Position);
            dir = GenRadial.RadialCellsAround(this.Position, Convert.ToInt32(this.Growth * 20), true)
                  .RandomElement();
            //If in bounds
            try
            {
                if (dir.InBounds(this.Map))
                {
                    TerrainDef terrain = dir.GetTerrain(this.Map);
                    if (terrain != null)
                    {
                        if (terrain.defName != "WaterDeep" &&
                            terrain.defName != "WaterShallow" &&
                            terrain.defName != "MarshyTerrain")
                        {
                            if (!PurpleIvyUtils.AlienPlantInCell(this.Map, dir))
                            {
                                SpawnIvy(dir);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("ERROR:" + ex.Message);
            }
        }
示例#8
0
        protected override void Explode()
        {
            Map map = base.Map;

            this.Destroy(DestroyMode.Vanish);
            if (this.def.projectile.explosionEffect != null)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(base.Position, map, false), new TargetInfo(base.Position, map, false));
                effecter.Cleanup();
            }
            IntVec3   position         = base.Position;
            Map       map2             = map;
            float     explosionRadius  = this.def.projectile.explosionRadius;
            DamageDef damageDef        = this.def.projectile.damageDef;
            int       damageAmount     = base.DamageAmount;
            float     armorPenetration = base.ArmorPenetration;
            SoundDef  soundExplode     = this.def.projectile.soundExplode;
            ThingDef  equipmentDef     = this.equipmentDef;
            ThingDef  def   = this.def;
            Thing     thing = this.intendedTarget.Thing;
            ThingDef  postExplosionSpawnThingDef   = this.def.projectile.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = this.def.projectile.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = this.def.projectile.postExplosionSpawnThingCount;
            ThingDef  preExplosionSpawnThingDef    = this.def.projectile.preExplosionSpawnThingDef;
            float     preExplosionSpawnChance      = this.def.projectile.preExplosionSpawnChance;
            int       preExplosionSpawnThingCount  = this.def.projectile.preExplosionSpawnThingCount;

            PurpleIvyUtils.DoExplosion(position, map2, explosionRadius, damageDef, launcher, damageAmount, armorPenetration, soundExplode, equipmentDef, def, thing, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, preExplosionSpawnChance, preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff, new float?(this.origin.AngleToFlat(this.destination)), null);
        }
            private static bool Prefix(Thing __instance, DestroyMode mode)
            {
                MapComponent_MapEvents comp = null;

                if (__instance.Map != null)
                {
                    comp = __instance.Map.GetComponent <MapComponent_MapEvents>();
                }
                else if (__instance.ParentHolder is Thing t && t.Map != null)
                {
                    comp = t.Map.GetComponent <MapComponent_MapEvents>();
                }
                if (comp != null && comp.ToxicDamages.ContainsKey(__instance))
                {
                    //Thing newNest = ThingMaker.MakeThing(ThingDefOf.AIPersonaCore);
                    //GenSpawn.Spawn(newNest, building.Position, building.Map);
                    comp.ToxicDamages.Remove(__instance);
                    comp.ToxicDamagesThings.Remove(__instance);
                    if (PurpleIvyUtils.IsChunkOrMineable(__instance))
                    {
                        comp.ToxicDamagesChunks.Remove(__instance.Position);
                    }
                }
                return(true);
            }
 public override void LoadedGame()
 {
     base.LoadedGame();
     PurpleIvyData.TotalFogProgress    = new Dictionary <WorldObjectComp_InfectedTile, float>();
     PurpleIvyData.TotalPollutedBiomes = new List <int>();
     foreach (var worldObject in Find.WorldObjects.AllWorldObjects)
     {
         var comp = worldObject.GetComponent <WorldObjectComp_InfectedTile>();
         if (comp != null)
         {
             PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter);
             //comp.fillRadius(forced: true); // causes crash when loading a save with infected sites
         }
     }
     for (int i = 0; i < Find.WorldGrid.TilesCount; i++)
     {
         if (Find.WorldGrid[i].biome.defName.Contains("PI_"))
         {
             PurpleIvyData.TotalPollutedBiomes.Add(i);
         }
     }
     if (Find.FactionManager.AllFactions.Where(x => x.def == PurpleIvyDefOf.Genny).Count() == 0)
     {
         Log.Message("No alien faction in the game, fixing it");
         Faction faction = FactionGenerator.NewGeneratedFaction(PurpleIvyDefOf.Genny);
         faction.TrySetRelationKind(Faction.OfPlayer, FactionRelationKind.Hostile, false, null, null);
         Find.FactionManager.Add(faction);
     }
 }
示例#11
0
        public static void Postfix(Map __instance)
        {
            Log.Message("WeatherChecker: " + __instance.ToString());
            bool comeFromOuterSource;
            var  tempComp = new WorldObjectComp_InfectedTile();

            tempComp.infectedTile = __instance.Tile;
            if (PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out comeFromOuterSource) > 0f &&
                !__instance.gameConditionManager.ConditionIsActive(PurpleIvyDefOf.PurpleFogGameCondition))
            {
                GameCondition_PurpleFog gameCondition =
                    (GameCondition_PurpleFog)GameConditionMaker.MakeConditionPermanent
                        (PurpleIvyDefOf.PurpleFogGameCondition);
                __instance.gameConditionManager.RegisterCondition(gameCondition);
                tempComp.parent = __instance.Parent;
                tempComp.StartInfection();
                tempComp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition;
                tempComp.counter             = 0;
                tempComp.infected            = false;
                tempComp.infectedTile        = __instance.Tile;
                tempComp.radius = tempComp.GetRadius();
                PurpleIvyData.TotalFogProgress[tempComp] = PurpleIvyUtils.getFogProgress(tempComp.counter);
                tempComp.fillRadius();
                __instance.Parent.AllComps.Add(tempComp);
            }
        }
示例#12
0
 public override void PostMapGenerate()
 {
     base.PostMapGenerate();
     PurpleIvyUtils.KillAllPawnsExceptAliens(this.Map);
     foreach (var item in this.Map.listerThings.AllThings.Where(item => item.Faction != Faction.OfPlayer))
     {
         item.Destroy(DestroyMode.Vanish);
     }
 }
示例#13
0
 public static void UpdateBiomes()
 {
     if (PurpleIvyData.BiomesToClear == true)
     {
         PurpleIvyUtils.ClearAlienBiomesOuterTheSources();
         PurpleIvyData.BiomesToClear = false;
     }
     Find.World.renderer.SetDirty <WorldLayerRegenerateBiomes>();
     PurpleIvyData.BiomesDirty = false;
 }
示例#14
0
 public override void Tick()
 {
     base.Tick();
     spawnticks--;
     if (spawnticks <= 0)
     {
         PurpleIvyUtils.SpawnNests(this);
         spawnticks = 15000;
     }
 }
 public override void PostPostRemove()
 {
     Log.Message("PostPostRemove");
     this.counter = 0;
     this.StopInfection();
     this.radius = -1; // -1 is set to allow filRadius remove alien biome in the place
     PurpleIvyData.BiomesDirty   = true;
     PurpleIvyData.BiomesToClear = true;
     PurpleIvyUtils.UpdateBiomes();
     base.PostPostRemove();
 }
示例#16
0
 public override void Init()
 {
     LessonAutoActivator.TeachOpportunity(ConceptDefOf.ForbiddingDoors, OpportunityType.Critical);
     LessonAutoActivator.TeachOpportunity(ConceptDefOf.AllowedAreas, OpportunityType.Critical);
     purpleFog.durationRange       = new IntRange(10000, 10000);
     purpleFoggyRain.durationRange = new IntRange(10000, 10000);
     empStorm.durationRange        = new IntRange(10000, 10000);
     foreach (Map map in this.AffectedMaps)
     {
         this.fogProgress[map] = 0f;
         int count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count;
         count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count;
         var comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>();
         if (comp != null)
         {
             bool temp;
             this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp);
             if (this.fogProgress[map] <= 0)
             {
                 this.End();
                 Find.LetterStack.ReceiveLetter("PurpleFogReceded".Translate(),
                                                "PurpleFogRecededDesc".Translate(), LetterDefOf.PositiveEvent);
             }
         }
         else
         {
             Log.Message("1 Comp null - GameCondition_PurpleFog");
         }
         weatherAge = map.weatherManager.curWeatherAge;
         bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses
                    .Contains(typeof(WeatherOverlay_Fog));
         if (fog != true)
         {
             Log.Message("Transitioning to purple fog in the " + map);
             map.weatherManager.TransitionTo(purpleFog);
         }
         else
         {
             Log.Message("Transitioning to purple fog in the " + map);
             map.weatherManager.TransitionTo(WeatherDefOf.Clear);
             map.weatherManager.TransitionTo(purpleFog);
             map.weatherManager.curWeatherAge = weatherAge;
         }
     }
 }
示例#17
0
 public static void ClearAlienBiomesOuterTheSources()
 {
     for (int i = PurpleIvyData.TotalPollutedBiomes.Count - 1; i >= 0; i--)
     {
         int tile = PurpleIvyData.TotalPollutedBiomes[i];
         if (PurpleIvyUtils.TileInRadiusOfInfectedSites(tile) != true)
         {
             Log.Message("Return old biome: " + tile.ToString());
             BiomeDef origBiome = Find.WorldGrid[tile].biome;
             BiomeDef newBiome  = BiomeDef.Named(origBiome.defName.ReplaceFirst("PI_", string.Empty));
             Find.WorldGrid[tile].biome = newBiome;
             PurpleIvyData.TotalPollutedBiomes.Remove(tile);
             PurpleIvyData.BiomesToRenderNow.Add(tile);
         }
     }
 }
示例#18
0
 public override float SkyTargetLerpFactor(Map map)
 {
     if (this.fogProgress.ContainsKey(map))
     {
         return(this.fogProgress[map]);
     }
     else
     {
         Log.Error("Something went wrong with the map " + map + ". It was not represented in " +
                   "the fogProgress dictionary.");
         bool temp;
         var  comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>();
         if (comp == null)
         {
             Log.Message("Adding new comp, due missing the one in the mapParent");
             comp = new WorldObjectComp_InfectedTile();
             int count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count;
             count      += map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count;
             comp.parent = map.Parent;
             comp.StartInfection();
             comp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition;
             comp.counter             = count;
             comp.infectedTile        = map.Tile;
             comp.radius = comp.GetRadius();
             PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter);
             comp.fillRadius();
             map.Parent.AllComps.Add(comp);
             PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(count);
             this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp);
         }
         else
         {
             this.fogProgress[map] = 0f;
             Log.Message("The fogProgress value is reset to 0");
         }
         return(this.fogProgress[map]);
     }
 }
        public List <Pawn> generateAliensFrom(WorldObjectComp_InfectedTile site)
        {
            List <Pawn> list = new List <Pawn>();
            int         AlphaParasitesCount = site.counter / 33;
            int         BetaParasitesCount  = site.counter / 22;
            int         GammaParasitesCount = site.counter / 22;
            int         OmegaParasitesCount = site.counter / 11;

            AlphaParasitesCount = (AlphaParasitesCount / 10) - (site.AlienPowerSpent / 33);
            BetaParasitesCount  = (BetaParasitesCount / 10) - (site.AlienPowerSpent / 33);
            GammaParasitesCount = (GammaParasitesCount / 10) - (site.AlienPowerSpent / 33);
            OmegaParasitesCount = (OmegaParasitesCount / 10) - (site.AlienPowerSpent / 33);

            Log.Message("counter: " + site.counter.ToString()
                        + " AlphaParasitesCount " + AlphaParasitesCount.ToString()
                        + " BetaParasitesCount " + BetaParasitesCount.ToString()
                        + " GammaParasitesCount " + GammaParasitesCount.ToString()
                        + " OmegaParasitesCount " + OmegaParasitesCount.ToString());

            foreach (var i in Enumerable.Range(1, AlphaParasitesCount))
            {
                Pawn NewPawn = PurpleIvyUtils.GenerateParasite(PurpleIvyData.Genny_ParasiteAlpha);
                list.Add(NewPawn);
            }
            foreach (var i in Enumerable.Range(1, BetaParasitesCount))
            {
                Pawn NewPawn = PurpleIvyUtils.GenerateParasite(PurpleIvyData.Genny_ParasiteBeta);
                list.Add(NewPawn);
            }

            foreach (var i in Enumerable.Range(1, GammaParasitesCount))
            {
                Pawn NewPawn = PurpleIvyUtils.GenerateParasite(PurpleIvyData.Genny_ParasiteGamma);
                list.Add(NewPawn);
            }
            foreach (var i in Enumerable.Range(1, OmegaParasitesCount))
            {
                Pawn NewPawn = PurpleIvyUtils.GenerateParasite(PurpleIvyData.Genny_ParasiteOmega);
                list.Add(NewPawn);
            }
            site.AlienPowerSpent = AlphaParasitesCount + BetaParasitesCount
                                   + GammaParasitesCount + OmegaParasitesCount;
            return(list);
        }
示例#20
0
 public override void Tick()
 {
     base.Tick();
     if (Find.TickManager.TicksGame > this.recoveryTick)
     {
         var hediff = this.health.hediffSet.hediffs
                      .FirstOrDefault((Hediff h) => h.def == PurpleIvyDefOf.PI_CrashlandedDowned);
         if (hediff != null)
         {
             this.health.hediffSet.hediffs.Remove(hediff);
             RestUtility.Awake(this);
         }
     }
     spawnticks--;
     if (spawnticks <= 0)
     {
         PurpleIvyUtils.SpawnNests(this);
         spawnticks = new IntRange(15000, 30000).RandomInRange;
     }
 }
示例#21
0
        public List <Pawn> GeneratePawns(IncidentParms parms)
        {
            List <Pawn> pawns  = new List <Pawn>();
            float       points = parms.points;

            if (PurpleIvyData.combatPoints.Where(x => x.Value >= points) != null)
            {
                while (points >= 35f)
                {
                    var combatCandidat = PurpleIvyData.combatPoints[PurpleIvyData.Genny_ParasiteOmega];
                    if (points >= combatCandidat)
                    {
                        points -= combatCandidat;
                        Pawn alien = PurpleIvyUtils.GenerateParasite(PurpleIvyData.Genny_ParasiteOmega);
                        pawns.Add(alien);
                    }
                }
            }
            return(pawns);
        }
示例#22
0
        public static float getFogProgressWithOuterSources(int count, WorldObjectComp_InfectedTile comp, out bool comeFromOuterSource)
        {
            var result = PurpleIvyUtils.getFogProgress(count);
            //Log.Message("fog progress: " + result.ToString());
            var outerSource = 0f;

            foreach (var data in PurpleIvyData.TotalFogProgress.Where(data => data.Key != comp))
            {
                int distance = Find.WorldGrid.TraversalDistanceBetween(comp.infectedTile, data.Key.infectedTile, true, int.MaxValue);
                if (distance <= data.Key.radius)
                {
                    float floatRadius = ((float)data.Key.counter - 500f) / 100f;
                    if (floatRadius < 0)
                    {
                        floatRadius = 0;
                    }
                    float newValue = GetPartFromPercentage(GetPercentageFromPartWhole(floatRadius, distance) / 100f, data.Value);
                    if (newValue > data.Value)
                    {
                        outerSource += data.Value;
                    }
                    else
                    {
                        outerSource += newValue;
                    }
                }
            }
            if (outerSource < 0f)
            {
                outerSource = 0f;
            }
            if (result == 0f && outerSource > 0f)
            {
                comeFromOuterSource = true;
            }
            else
            {
                comeFromOuterSource = false;
            }
            return(result + outerSource);
        }
示例#23
0
        protected virtual void Ignite()
        {
            Map map = Map;

            Destroy();
            var radius        = def.projectile.explosionRadius;
            var cellsToAffect = SimplePool <List <IntVec3> > .Get();

            cellsToAffect.Clear();
            cellsToAffect.AddRange(def.projectile.damageDef.Worker.ExplosionCellsToHit(Position, map, radius));
            for (int i = 0; i < 4; i++)
            {
                PurpleIvyMoteMaker.ThrowToxicPostExplosionSmoke(Position.ToVector3Shifted() + Gen.RandomHorizontalVector(radius * 0.7f), map, radius * 0.6f);
            }
            //Fire explosion should be tiny.
            if (this.def.projectile.explosionEffect != null)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(this.Position, map, false), new TargetInfo(this.Position, map, false));
                effecter.Cleanup();
            }
            PurpleIvyUtils.DoExplosion(this.Position, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.GetDamageAmount(1, null), this.def.projectile.GetArmorPenetration(1, null), this.def.projectile.soundExplode, this.equipmentDef, this.def, null, this.def.projectile.postExplosionSpawnThingDef, this.def.projectile.postExplosionSpawnChance, this.def.projectile.postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, this.def.projectile.preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff);
        }
示例#24
0
 public override void Tick()
 {
     base.Tick();
     if (this.activeDamage && Find.TickManager.TicksGame % Rand.RangeInclusive(40, 80) == 0)
     {
         try
         {
             List <Pawn> pawnsToDamage = new List <Pawn>();
             if (GenGrid.InBounds(this.Position, this.Map))
             {
                 foreach (var t in this.Map.thingGrid.ThingsListAt(this.Position))
                 {
                     if (t is Pawn pawn && !pawn.Dead && pawn.Faction != PurpleIvyData.AlienFaction)
                     {
                         pawnsToDamage.Add(pawn);
                     }
                 }
             }
             foreach (var pawn in pawnsToDamage)
             {
                 pawn.TakeDamage(new DamageInfo(PurpleIvyDefOf.PI_ToxicBurn, 1f));
                 if (Rand.Chance(0.1f))
                 {
                     pawn.stances.stunner.StunFor(Rand.RangeInclusive(100, 200), null);
                 }
                 if (Rand.Chance(0.1f) && pawn.health.hediffSet.GetFirstHediffOfDef(PurpleIvyDefOf.PI_AlienMutation) == null)
                 {
                     var hediff3 = HediffMaker.MakeHediff(PurpleIvyDefOf.PI_AlienMutation, pawn, null);
                     pawn.health.AddHediff(hediff3, null, null, null);
                 }
                 PurpleIvyUtils.MakeFlee(pawn, this);
             }
         }
         catch { };
     }
 }
示例#25
0
        public override void FinalizeInit()
        {
            base.FinalizeInit();
            if (this.ToxicDamagesChunks != null)
            {
                foreach (var b in this.ToxicDamagesChunks)
                {
                    foreach (var t in this.map.thingGrid.ThingsListAt(b.Key))
                    {
                        if (PurpleIvyUtils.IsChunkOrMineable(t))
                        {
                            this.ToxicDamagesChunksDeep[t] = b.Value;
                        }
                    }
                }
            }
            if (this.ToxicDamagesChunksDeep != null)
            {
                foreach (var b in this.ToxicDamagesChunksDeep)
                {
                    this.ToxicDamages[b.Key] = b.Value;
                }
            }

            if (this.ToxicDamagesThings != null)
            {
                foreach (var b in this.ToxicDamagesThings)
                {
                    this.ToxicDamages[b.Key] = b.Value;
                }
            }

            if (this.ToxicDamagesThings != null)
            {
                foreach (var b in this.ToxicDamages)
                {
                    Log.Message("Notifying " + b.Key);
                    ThingsToxicDamageSectionLayerUtility.Notify_ThingHitPointsChanged(this, b.Key, b.Key.MaxHitPoints);
                }
            }

            foreach (Thing t in this.map.listerThings.AllThings)
            {
                Pawn pawn = null;
                if (t is Pawn)
                {
                    pawn = (Pawn)t;
                }
                else if (t is Corpse)
                {
                    Corpse corpse = (Corpse)t;
                    pawn = corpse.InnerPawn;
                }
                else
                {
                    continue;
                }
                AlienInfectionHediff hediff = (AlienInfectionHediff)pawn.health.hediffSet.hediffs
                                              .Where(x => x is AlienInfectionHediff).FirstOrDefault();
                if (hediff != null)
                {
                    var comp = pawn.TryGetComp <AlienInfection>();
                    if (comp == null)
                    {
                        if (hediff.instigator != null)
                        {
                            var dummyCorpse = PurpleIvyDefOf.InfectedCorpseDummy;
                            comp = new AlienInfection();
                            comp.Initialize(dummyCorpse.GetCompProperties <CompProperties_AlienInfection>());
                            comp.parent = pawn;
                            comp.Props.typesOfCreatures = new List <string>()
                            {
                                hediff.instigator.defName
                            };
                            var range = PurpleIvyData.maxNumberOfCreatures[hediff.instigator.race.defName];
                            comp.maxNumberOfCreatures                 = hediff.maxNumberOfCreatures;
                            comp.currentCountOfCreatures              = hediff.currentCountOfCreatures;
                            comp.startOfIncubation                    = hediff.startOfIncubation;
                            comp.tickStartHediff                      = hediff.tickStartHediff;
                            comp.stopSpawning                         = hediff.stopSpawning;
                            comp.Props.maxNumberOfCreatures           = range;
                            comp.Props.incubationPeriod               = new IntRange(10000, 40000);
                            comp.Props.IncubationData                 = new IncubationData();
                            comp.Props.IncubationData.tickStartHediff = new IntRange(2000, 4000);
                            comp.Props.IncubationData.deathChance     = 90;
                            comp.Props.IncubationData.hediff          = HediffDefOf.Pregnant.defName;
                            if (pawn.Dead)
                            {
                                var corpse = pawn.Corpse;
                                corpse.AllComps.Add(comp);
                            }
                            else
                            {
                                pawn.AllComps.Add(comp);
                            }
                        }
                    }
                    else if (pawn.Dead && comp != null)
                    {
                        var corpse = pawn.Corpse;
                        corpse.AllComps.Add(comp);
                    }
                }
            }
        }
        public override void GameComponentTick()
        {
            base.GameComponentTick();
            bool temp;

            if (PurpleIvyData.BiomesDirty == true)
            {
                PurpleIvyUtils.UpdateBiomes();
            }
            if (Find.TickManager.TicksGame % 3451 == 0) // same as for toxic weather
            {
                bool raidHappened = false;
                var  tempComp     = new WorldObjectComp_InfectedTile();
                Log.Message("Total polluted biomes to check: " + PurpleIvyData.TotalPollutedBiomes.Count);
                foreach (var tile in PurpleIvyData.TotalPollutedBiomes)
                {
                    var worldObjects = Find.WorldObjects.ObjectsAt(tile);
                    foreach (var worldObject in worldObjects)
                    {
                        if (worldObject is Caravan caravan)
                        {
                            tempComp.infectedTile = caravan.Tile;
                            float fogProgress = PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out temp);
                            if (fogProgress > 0f)
                            {
                                foreach (Pawn p in caravan.pawns)
                                {
                                    if (p.Faction != PurpleIvyData.AlienFaction && p.RaceProps.IsFlesh)
                                    {
                                        float num = fogProgress / 20; //TODO: balance it
                                        num *= p.GetStatValue(StatDefOf.ToxicSensitivity, true);
                                        if (num != 0f)
                                        {
                                            HealthUtility.AdjustSeverity(p, HediffDefOf.ToxicBuildup, num);
                                        }
                                    }
                                }
                            }
                            if (raidHappened != true)
                            {
                                var infectedSites = getInfectedTilesNearby(worldObject.Tile);
                                if (infectedSites != null && infectedSites.Count > 0)
                                {
                                    if (fogProgress > 0.7f)
                                    {
                                        fogProgress = 0.7f;
                                    }
                                    int           raidChance = (int)(fogProgress * 100);
                                    System.Random random     = new System.Random(caravan.Tile);
                                    Log.Message("An attempt to ambush caravan, raid chance: " + raidChance.ToString()
                                                + " - fogProgress: " + fogProgress.ToString());
                                    if (raidChance >= random.Next(1, 100))
                                    {
                                        Log.Message("The caravan has been ambushed! RaidChance: " + raidChance.ToString()
                                                    + " - fogProgress: " + fogProgress.ToString());
                                        this.AlienAmbush(caravan, infectedSites.RandomElement());
                                        raidHappened = true;
                                    }
                                }
                            }
                        }
                        else if (worldObject is MapParent mapParent)
                        {
                            tempComp.infectedTile = mapParent.Tile;
                            float?fogProgress = null;
                            if (raidHappened != true && mapParent.Map != null)
                            {
                                var infectedSites = getInfectedTilesNearby(mapParent.Tile);
                                if (infectedSites != null && infectedSites.Count > 0)
                                {
                                    fogProgress = PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out temp);
                                    int           raidChance   = (int)(fogProgress * 100) / 10;
                                    System.Random random       = new System.Random();
                                    int           randomChance = random.Next(1, 100);
                                    Log.Message("An attempt to raid map, raid chance: " + raidChance.ToString()
                                                + " - randomChance: " + randomChance.ToString()
                                                + " - fogProgress: " + fogProgress.ToString());
                                    if (raidChance >= randomChance)
                                    {
                                        Log.Message("Alien Raid! RaidChance: " + raidChance.ToString()
                                                    + " - fogProgress: " + fogProgress.ToString() + " map: " + mapParent.Map.ToString());
                                        this.AlienRaid(mapParent.Map, infectedSites.RandomElement());
                                        raidHappened = true;
                                    }
                                }
                            }
                            if (mapParent.Faction != Faction.OfPlayer && mapParent.Faction != PurpleIvyData.AlienFaction)
                            {
                                if (!fogProgress.HasValue)
                                {
                                    fogProgress = PurpleIvyUtils.getFogProgressWithOuterSources(0, tempComp, out temp);
                                }
                                if (fogProgress > 0f)
                                {
                                    int           abandonChance = (int)(fogProgress * 100) / 10;
                                    System.Random random        = new System.Random(Find.TickManager.TicksGame);
                                    Log.Message(mapParent.Faction.ToString());
                                    Log.Message("An attempt to abandon NPC base, abandon chance: " + abandonChance.ToString()
                                                + " - fogProgress: " + fogProgress.ToString());
                                    if (abandonChance >= random.Next(1, 100))
                                    {
                                        Log.Message("NPC base abandoned! Chance: " + abandonChance.ToString()
                                                    + " - fogProgress: " + fogProgress.ToString() + " base: " + mapParent.ToString());
                                        Site site = (Site)WorldObjectMaker.MakeWorldObject(PurpleIvyDefOf.PI_AbandonedBase);
                                        site.Tile = mapParent.Tile;
                                        site.SetFaction(mapParent.Faction);
                                        mapParent.Destroy();
                                        Find.LetterStack.ReceiveLetter("AbandonedBase".Translate(),
                                                                       "AbandonedBaseDesc".Translate(), LetterDefOf.NeutralEvent,
                                                                       site, mapParent.Faction, null, null, null);
                                    }
                                    else
                                    {
                                        int defeatChance = (int)(fogProgress * 100) / 10;
                                        random = new System.Random(Find.TickManager.TicksGame + mapParent.Tile);
                                        Log.Message(mapParent.Faction.ToString());
                                        Log.Message("An attempt to defeat NPC base, defeat chance: " + abandonChance.ToString()
                                                    + " - fogProgress: " + fogProgress.ToString());
                                        if (defeatChance >= random.Next(1, 100))
                                        {
                                            Log.Message("NPC base defeated! Chance: " + defeatChance.ToString()
                                                        + " - fogProgress: " + fogProgress.ToString() + " base: " + mapParent.ToString());
                                            Site site = (Site)WorldObjectMaker.MakeWorldObject(PurpleIvyDefOf.PI_DefeatedBase);
                                            site.Tile = mapParent.Tile;
                                            site.SetFaction(mapParent.Faction);
                                            mapParent.Destroy();
                                            Find.LetterStack.ReceiveLetter("DefeatedBase".Translate(),
                                                                           "DefeatedBaseDesc".Translate(), LetterDefOf.NegativeEvent,
                                                                           site, mapParent.Faction, null, null, null);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
示例#27
0
        public override void GameConditionTick()
        {
            List <Map> affectedMaps = base.AffectedMaps;

            foreach (Map map in affectedMaps)
            {
                //Log.Message(map.weatherManager.curWeather + " - " + map.weatherManager.lastWeather, true);
                if (Find.TickManager.TicksGame % 60 == 0) // for performance
                {
                    int count = map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count;
                    count += map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count;
                    var  comp = map.Parent.GetComponent <WorldObjectComp_InfectedTile>();
                    bool temp;
                    if (comp != null)
                    {
                        this.fogProgress[map] = PurpleIvyUtils.getFogProgressWithOuterSources(count, comp, out temp);
                        if (this.fogProgress[map] <= 0)
                        {
                            this.End();
                            Find.LetterStack.ReceiveLetter("PurpleFogReceded".Translate(),
                                                           "PurpleFogRecededDesc".Translate(), LetterDefOf.PositiveEvent);
                        }
                    }
                    else
                    {
                        Log.Message("2 Comp null - GameCondition_PurpleFog");
                    }
                    Log.Message(map + " - total plants " + count.ToString() + " = fog progress - " + this.fogProgress[map].ToString(), true);
                    weatherAge = map.weatherManager.curWeatherAge;
                    bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses
                               .Contains(typeof(WeatherOverlay_Fog));
                    if (map.weatherManager.curWeather != purpleFog &&
                        Find.TickManager.TicksGame > this.weatherEndingTick ||
                        !map.weatherManager.curWeather.defName.StartsWith("PI_"))
                    {
                        weatherEndingTick = new IntRange(10000, 30000).RandomInRange + Find.TickManager.TicksGame;
                        Log.Message("Transitioning to purple fog in the " + map, true);
                        if (fog == true)
                        {
                            map.weatherManager.TransitionTo(WeatherDefOf.Clear);
                            map.weatherManager.TransitionTo(purpleFog);
                        }
                        else
                        {
                            map.weatherManager.TransitionTo(purpleFog);
                        }
                        map.weatherManager.curWeatherAge = weatherAge;
                    }
                }

                if (Find.TickManager.TicksGame % 3451 == 0)
                {
                    Log.Message("weatherEndingTick: " + this.weatherEndingTick + " - TicksGame: " + Find.TickManager.TicksGame, true);
                    if (this.weatherEndingTick < Find.TickManager.TicksGame && this.fogProgress[map] >= 0.20f)
                    {
                        if (Rand.Chance(this.fogProgress[map]) && map.weatherManager.curWeather != purpleFoggyRain)
                        {
                            WeatherOverlay_PurpleRain weatherOverlay = new WeatherOverlay_PurpleRain();
                            foreach (var overlay in purpleFoggyRain.Worker.overlays)
                            {
                                if (overlay is WeatherOverlay_PurpleRain)
                                {
                                    overlay.worldOverlayMat = MaterialPool.MatFrom("Weather/PurpleRainOverlayWorld2", ShaderDatabase.MetaOverlay);
                                    break;
                                }
                            }
                            weatherEndingTick = new IntRange(10000, 20000).RandomInRange + Find.TickManager.TicksGame;
                            Log.Message("Transitioning to purple rain in the " + map, true);
                            bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses
                                       .Contains(typeof(WeatherOverlay_Fog));
                            weatherAge = map.weatherManager.curWeatherAge;
                            if (fog == true)
                            {
                                map.weatherManager.TransitionTo(WeatherDefOf.Clear);
                                map.weatherManager.TransitionTo(purpleFoggyRain);
                            }
                            else
                            {
                                map.weatherManager.TransitionTo(purpleFoggyRain);
                            }
                            map.weatherManager.curWeatherAge = weatherAge;
                            Find.LetterStack.ReceiveLetter("PurpleRainTripleToxicDamage".Translate(), "PurpleRainTripleToxicDamageDesc".Translate(), LetterDefOf.NeutralEvent, null, null);
                        }
                        else if (Rand.Chance(this.fogProgress[map]) &&
                                 map.weatherManager.curWeather != empStorm)
                        {
                            weatherEndingTick = new IntRange(10000, 20000).RandomInRange + Find.TickManager.TicksGame;
                            Log.Message("Transitioning to emp storm in the " + map, true);
                            bool fog = map.weatherManager.CurWeatherPerceived.overlayClasses
                                       .Contains(typeof(WeatherOverlay_Fog));
                            if (map.weatherManager.curWeather.defName.StartsWith("PI_"))
                            {
                                weatherAge = map.weatherManager.curWeatherAge;
                            }
                            if (fog == true)
                            {
                                map.weatherManager.TransitionTo(WeatherDefOf.Clear);
                                map.weatherManager.TransitionTo(empStorm);
                            }
                            else
                            {
                                map.weatherManager.TransitionTo(empStorm);
                            }
                            map.weatherManager.curWeatherAge = weatherAge;
                            Find.LetterStack.ReceiveLetter("EmpStormTripleToxicDamage".Translate(), "EmpStormTripleToxicDamageDesc".Translate(), LetterDefOf.NeutralEvent, null, null);
                        }
                    }
                    this.DoPawnsToxicDamage(map);
                }
            }
        }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            base.AddEndCondition(delegate()
            {
                var thing = base.GetActor().jobs.curJob.GetTarget(TargetIndex.A).Thing;
                if (thing is Building && !thing.Spawned)
                {
                    return(JobCondition.Incompletable);
                }
                return(JobCondition.Ongoing);
            });
            this.FailOnBurningImmobile <JobDriver_DoBill>(TargetIndex.A);
            this.FailOn <JobDriver_DoBill>(delegate()
            {
                if (!(this.job.GetTarget(TargetIndex.A).Thing is IBillGiver billGiver))
                {
                    return(false);
                }
                if (this.job.bill.DeletedOrDereferenced)
                {
                    return(true);
                }
                if (!billGiver.CurrentlyUsableForBills())
                {
                    return(true);
                }
                return(false);
            });
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            var            tableThing     = this.job.GetTarget(TargetIndex.A).Thing as Building_СontainmentBreach;
            CompRefuelable refuelableComp = tableThing.GetComp <CompRefuelable>();
            Toil           toil           = new Toil();

            toil.initAction = delegate()
            {
                this.job.bill.Notify_DoBillStarted(this.pawn);
                this.workCycleProgress = this.job.bill.recipe.workAmount;
            };
            toil.tickAction = delegate()
            {
                this.workCycleProgress -= StatExtension.GetStatValue(this.pawn, StatDefOf.WorkToMake, true);
                tableThing.UsedThisTick();
                if (!tableThing.CurrentlyUsableForBills() || (refuelableComp != null && !refuelableComp.HasFuel))
                {
                    this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true, true);
                }
                if (this.workCycleProgress <= 0f)
                {
                    SkillDef workSkill = this.job.bill.recipe.workSkill;
                    if (workSkill != null)
                    {
                        SkillRecord skill = this.pawn.skills.GetSkill(workSkill);
                        if (skill != null)
                        {
                            skill.Learn(0.11f * this.job.bill.recipe.workSkillLearnFactor, false);
                        }
                    }
                    GenSpawn.Spawn(tableThing.GetKorsolianToxin(this.job.bill.recipe),
                                   tableThing.InteractionCell, tableThing.Map, 0);
                    Toils_Reserve.Release(TargetIndex.A);
                    PawnUtility.GainComfortFromCellIfPossible(this.pawn, false);
                    this.job.bill.Notify_IterationCompleted(this.pawn, null);
                    this.ReadyForNextToil();
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Never;
            ToilEffects.WithEffect(toil, () => this.job.bill.recipe.effectWorking, TargetIndex.A);
            ToilEffects.PlaySustainerOrSound(toil, () => toil.actor.CurJob.bill.recipe.soundWorking);
            ToilEffects.WithProgressBar(toil, TargetIndex.A, delegate()
            {
                return(PurpleIvyUtils.GetPercentageFromPartWhole
                           (this.job.bill.recipe.workAmount - this.workCycleProgress,
                           (int)this.job.bill.recipe.workAmount) / 100f);
            }, false, 0.5f);
            ToilFailConditions.FailOn <Toil>(toil, delegate()
            {
                IBillGiver billGiver = this.job.GetTarget(TargetIndex.A).Thing as IBillGiver;
                return(this.job.bill.suspended || this.job.bill.DeletedOrDereferenced || (billGiver != null && !billGiver.CurrentlyUsableForBills()));
            });
            yield return(toil);

            yield break;
        }
示例#29
0
 public override void PostMapGenerate()
 {
     base.PostMapGenerate();
     PurpleIvyUtils.KillAllPawnsExceptAliens(this.Map);
 }
示例#30
0
        public override void MapComponentTick()
        {
            base.MapComponentTick();
            if (Find.TickManager.TicksGame % 250 == 0)
            {
                var plants = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy);
                //Log.Message("Checking orbital strike, " + this.OrbitalHelpActive + " - " + plants.Count);
                if (plants != null && ((this.OrbitalHelpActive == true && plants.Count > 0) ||
                                       plants.Count > 2000)) // && Rand.Chance(PurpleIvyData.getFogProgress(plants.Count)))
                {
                    if (this.OrbitalHelpActive == false)
                    {
                        this.OrbitalHelpActive = true;
                        Find.LetterStack.ReceiveLetter("OrbitalHelpFromAncients".Translate(),
                                                       "OrbitalHelpFromAncientsDesc".Translate(),
                                                       LetterDefOf.NeutralEvent, new TargetInfo(plants.RandomElement().Position, map, false));
                    }
                    PowerBeam powerBeam = (PowerBeam)GenSpawn.Spawn(PurpleIvyDefOf.PI_PowerBeam,
                                                                    plants.RandomElement().Position, this.map, 0);
                    powerBeam.duration   = 200;
                    powerBeam.instigator = null;
                    powerBeam.weaponDef  = null;
                    powerBeam.StartStrike();
                }
                if ((plants.Count <= 0 || plants == null) && this.OrbitalHelpActive == true)
                {
                    Log.Message("Orbital help");
                    this.OrbitalHelpActive = false;
                    List <Pawn> list = new List <Pawn>();

                    var alpha = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha);
                    var beta  = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta);
                    var gamma = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma);
                    var omega = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega);
                    var guard = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard);

                    int pawnCount = alpha.Count;
                    pawnCount += beta.Count;
                    pawnCount += gamma.Count;
                    pawnCount += omega.Count;
                    pawnCount += guard.Count;
                    Predicate <IntVec3> predicate = delegate(IntVec3 c)
                    {
                        return(!GridsUtility.Fogged(c, map) &&
                               !GridsUtility.Roofed(c, map) &&
                               GenGrid.InBounds(c, map) &&
                               GenRadial.RadialCellsAround(c, 10, true).Where(x =>
                                                                              map.thingGrid.ThingsListAt(x).Where(y => y.Faction == PurpleIvyData.AlienFaction)
                                                                              != null) != null);
                    };
                    IntVec3 position = CellFinder.RandomClosewalkCellNear(this.map.Center, this.map, 500,
                                                                          predicate);
                    foreach (var num in Enumerable.Range(1, pawnCount / 2))
                    {
                        Faction faction = FactionUtility.DefaultFactionFrom(PurpleIvyDefOf.KorsolianFaction);
                        Pawn    NewPawn = PawnGenerator.GeneratePawn(PurpleIvyDefOf.KorsolianSoldier, faction);
                        if (faction != null && faction != Faction.OfPlayer)
                        {
                            Lord lord = null;
                            if (this.map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) =>
                                                                                     p != NewPawn))
                            {
                                lord = ((Pawn)GenClosest.ClosestThing_Global(NewPawn.Position,
                                                                             this.map.mapPawns.SpawnedPawnsInFaction(faction), 99999f,
                                                                             (Thing p) => p != NewPawn && ((Pawn)p).GetLord() != null, null)).GetLord();
                            }
                            if (lord == null)
                            {
                                var lordJob = new LordJob_AssistColony(Faction.OfPlayer, position);
                                //LordJob_DefendPoint lordJob = new LordJob_DefendPoint(position);
                                lord = LordMaker.MakeNewLord(faction, lordJob, this.map, null);
                            }
                            lord.AddPawn(NewPawn);
                        }
                        Log.Message(NewPawn?.Faction?.def?.defName);
                        list.Add(NewPawn);
                    }
                    DropPodUtility.DropThingsNear(position, this.map, list, 30, false, true, true, true);
                    Find.LetterStack.ReceiveLetter("AncientsLandOnTheGround".Translate(),
                                                   "AncientsLandOnTheGroundDesc".Translate(),
                                                   LetterDefOf.NeutralEvent, new TargetInfo(position, map, false));
                }
                //Log.Message("Alpha limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName]);
                //Log.Message("Beta limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName]);
                //Log.Message("Gamma limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName]);
                //Log.Message("Omega limit: " + PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName]);
                int  count = plants.Count;
                bool comeFromOuterSource;
                var  tempComp = new WorldObjectComp_InfectedTile();
                tempComp.infectedTile = map.Tile;
                if (PurpleIvyUtils.getFogProgressWithOuterSources(count, tempComp, out comeFromOuterSource) > 0f &&
                    !map.gameConditionManager.ConditionIsActive(PurpleIvyDefOf.PurpleFogGameCondition))
                {
                    GameCondition_PurpleFog gameCondition =
                        (GameCondition_PurpleFog)GameConditionMaker.MakeConditionPermanent
                            (PurpleIvyDefOf.PurpleFogGameCondition);
                    map.gameConditionManager.RegisterCondition(gameCondition);
                    if (comeFromOuterSource == false)
                    {
                        Find.LetterStack.ReceiveLetter(gameCondition.LabelCap,
                                                       gameCondition.LetterText, gameCondition.def.letterDef,
                                                       new TargetInfo(map.Center, map, false));
                    }
                    else
                    {
                        Find.LetterStack.ReceiveLetter("PurpleFogСomesFromInfectedSites".Translate(),
                                                       "PurpleFogСomesFromInfectedSitesDesc".Translate(),
                                                       LetterDefOf.ThreatBig, new TargetInfo(map.Center, map, false));
                        Log.Message("PurpleFogСomesFromInfectedSites: " + map.ToString()
                                    + " - " + Find.TickManager.TicksGame.ToString());
                    }
                    if (map.Parent.GetComponent <WorldObjectComp_InfectedTile>() == null)
                    {
                        var comp = new WorldObjectComp_InfectedTile();
                        comp.parent = map.Parent;
                        comp.StartInfection();
                        comp.gameConditionCaused = PurpleIvyDefOf.PurpleFogGameCondition;
                        comp.counter             = count;
                        comp.infectedTile        = map.Tile;
                        comp.radius = comp.GetRadius();
                        PurpleIvyData.TotalFogProgress[comp] = PurpleIvyUtils.getFogProgress(comp.counter);
                        comp.fillRadius();
                        map.Parent.AllComps.Add(comp);
                        Log.Message("Adding comp to: " + map.Parent.ToString());
                    }
                }
            }
            if (Find.TickManager.TicksGame % 60000 == 0)
            {
                int count     = 0;
                var alphaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSac);
                var betaEggs  = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacBeta);
                var gammaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacGamma);
                var nestsEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.EggSacNestGuard);
                var omegaEggs = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.ParasiteEgg);

                Log.Message("Total PurpleIvy count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PurpleIvy).Count.ToString(), true);

                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteAlpha).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteAlpha.defName])
                {
                    foreach (var egg in alphaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in alphaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteAlpha count on the map: " + count.ToString(), true);
                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteBeta).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteBeta.defName])
                {
                    foreach (var egg in betaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in betaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteBeta count on the map: " + count.ToString(), true);
                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteGamma).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteGamma.defName])
                {
                    foreach (var egg in gammaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in gammaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteGamma count on the map: " + count.ToString(), true);
                count = this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteOmega).Count;
                if (count > PurpleIvySettings.TotalAlienLimit[PurpleIvyDefOf.Genny_ParasiteOmega.defName])
                {
                    foreach (var egg in omegaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = true;
                    }
                }
                else
                {
                    foreach (var egg in omegaEggs)
                    {
                        var eggSac = (Building_EggSac)egg;
                        eggSac.TryGetComp <AlienInfection>().stopSpawning = false;
                    }
                }
                Log.Message("Total Genny_ParasiteOmega count on the map: " + count.ToString(), true);
                Log.Message("Total Genny_ParasiteNestGuard count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Genny_ParasiteNestGuard).Count.ToString(), true);
                Log.Message("Total EggSac count on the map: " + alphaEggs.Count.ToString(), true);
                Log.Message("Total EggSac beta count on the map: " + betaEggs.Count.ToString(), true);
                Log.Message("Total EggSac gamma count on the map: " + gammaEggs.Count.ToString(), true);
                Log.Message("Total EggSac NestGuard count on the map: " + nestsEggs.Count.ToString(), true);
                Log.Message("Total ParasiteEgg count on the map: " + omegaEggs.Count.ToString(), true);
                Log.Message("Total GasPump count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GasPump).Count.ToString(), true);
                Log.Message("Total GenTurretBase count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.GenTurretBase).Count.ToString(), true);
                Log.Message("Total Turret_GenMortarSeed count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.Turret_GenMortarSeed).Count.ToString(), true);
                Log.Message("Total Nest count on the map: " +
                            this.map.listerThings.ThingsOfDef(PurpleIvyDefOf.PI_Nest).Count.ToString(), true);
            }
        }