예제 #1
0
        public override void PostAdd(DamageInfo?dinfo)
        {
            var comp = this.pawn.TryGetComp <AlienInfection>();

            if (comp == null)
            {
                var dummyCorpse = PurpleIvyDefOf.InfectedCorpseDummy;
                comp = new AlienInfection();
                comp.Initialize(dummyCorpse.GetCompProperties <CompProperties_AlienInfection>());
                comp.parent = this.pawn;
                if (instigator == null)
                {
                    instigator = DefDatabase <PawnKindDef> .AllDefsListForReading
                                 .Where(x => x.defName.Contains("Genny_Parasite")).ToList().RandomElement <PawnKindDef>();
                }
                var range       = PurpleIvyData.maxNumberOfCreatures[instigator.race.defName];
                int randomRange = range.RandomInRange;
                comp.maxNumberOfCreatures = (int)(randomRange * this.pawn.BodySize);
                if (comp.maxNumberOfCreatures > 0)
                {
                    Log.Message("Infection count based on body size: " + this.pawn +
                                " - body size: " + this.pawn.BodySize + " - initial value: " + randomRange +
                                " after: " + comp.maxNumberOfCreatures);
                    comp.Props.maxNumberOfCreatures = range;
                    comp.Props.typesOfCreatures     = new List <string>()
                    {
                        instigator.defName
                    };
                    comp.Props.incubationPeriod = new IntRange(10000, 40000);
                    comp.Props.IncubationData   = new IncubationData
                    {
                        tickStartHediff = new IntRange(2000, 4000),
                        deathChance     = 90,
                        hediff          = HediffDefOf.Pregnant.defName
                    };
                    Log.Message("1 Adding infected comp to " + this.pawn);
                    this.pawn.AllComps.Add(comp);
                }
                else
                {
                    Log.Message(this.pawn + " - zero count of infection");
                    this.pawn.health.hediffSet.hediffs.Remove(this);
                    this.PostRemoved();
                }
            }
        }
예제 #2
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);
                    }
                }
            }
        }