Пример #1
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);
 }
Пример #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            var followAndAttack = new Toil();

            followAndAttack.tickAction = delegate()
            {
                var actor  = followAndAttack.actor;
                var curJob = actor.jobs.curJob;
                var thing  = curJob.GetTarget(this.a).Thing;
                var pawn1  = thing as Pawn;
                if (thing != actor.pather.Destination.Thing || (!this.pawn.pather.Moving && !this.pawn.Position.AdjacentTo8WayOrInside(thing)))
                {
                    actor.pather.StartPath(thing, PathEndMode.Touch);
                }
                else
                {
                    if (!this.pawn.Position.AdjacentTo8WayOrInside(thing))
                    {
                        return;
                    }
                    if (thing is Pawn && pawn1.Downed && !curJob.killIncappedTarget)
                    {
                        this.EndJobWith(JobCondition.Succeeded);
                    }
                    var victim = (Pawn)thing;
                    if (actor.meleeVerbs.TryMeleeAttack(thing, null, true))
                    {
                        this.numMeleeAttacksLanded++;
                        if (this.numMeleeAttacksLanded >= curJob.maxNumMeleeAttacks)
                        {
                            this.EndJobWith(JobCondition.Succeeded);
                        }
                        if (10f >= Rand.Range(0f, 100f))
                        {
                            if (!victim.RaceProps.IsMechanoid && PurpleIvyData.maxNumberOfCreatures.ContainsKey(actor.def.defName) &&
                                thing.TryGetComp <AlienInfection>() == null)
                            {
                                AlienInfectionHediff hediff = (AlienInfectionHediff)HediffMaker.MakeHediff
                                                                  (PurpleIvyDefOf.PI_AlienInfection, victim);
                                hediff.instigator = this.pawn.kindDef;
                                victim.health.AddHediff(hediff);
                            }
                        }
                    }
                }
            };
            followAndAttack.defaultCompleteMode = ToilCompleteMode.Never;
            followAndAttack.EndOnDespawnedOrNull <Toil>(this.a, JobCondition.Succeeded);
            followAndAttack.FailOn <Toil>(new Func <bool>(this.hunterIsKilled));
            yield return(followAndAttack);

            yield break;
        }
Пример #3
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);
                    }
                }
            }
        }