Esempio n. 1
0
        public override void OnSucessfullCast(Saveable_Caster caster, IEnumerable <Thing> targets, IExposable effectState)
        {
            MapComponent_Ability component = MapComponent_Ability.GetOrCreate();

            foreach (Pawn target in targets)
            {
                AbilityEffect_UtilityChangeKind evolveItem = this.items.First(i => i.from.Contains(target.def));


                Brain brain = target.GetSquadBrain();
                foreach (PawnKindDef kind in evolveItem.to)
                {
                    Pawn newPawn = AbilityEffect_Revive.Copy(caster.pawn, kind, target.Faction);
                    GenSpawn.Spawn(newPawn, target.Position);

                    if (brain != null)
                    {
                        brain.AddPawn(newPawn);
                    }
                }

                Building building = StoreUtility.StoringBuilding(target);
                if (building != null)
                {
                    ((Building_Storage)building).Notify_LostThing(target);
                }
                target.Destroy(DestroyMode.Vanish);
            }
        }
Esempio n. 2
0
        public override void OnSucessfullCast(Saveable_Caster caster, IEnumerable <Thing> targets, IExposable effectState)
        {
            MapComponent_Ability component = MapComponent_Ability.GetOrCreate();

            Brain brain = caster.pawn.GetSquadBrain();

            foreach (Corpse corpse in targets)
            {
                List <PawnKindDef> newKinds = new List <PawnKindDef>();
                if (this.changes != null)
                {
                    AbilityEffect_UtilityChangeKind kind = this.changes.FirstOrDefault(i => i.from.Contains(corpse.innerPawn.def));
                    if (kind != null)
                    {
                        newKinds.AddRange(kind.to);
                    }
                    else
                    {
                        newKinds.Add(corpse.innerPawn.kindDef);
                    }
                }
                else
                {
                    newKinds.Add(corpse.innerPawn.kindDef);
                }

                foreach (PawnKindDef kindDef in newKinds)
                {
                    Pawn newPawn = AbilityEffect_Revive.Copy(caster.pawn, kindDef, this.changeFaction ? caster.pawn.Faction : corpse.innerPawn.Faction);

                    if (corpse.innerPawn == caster.pawn)
                    {
                        component.ReplacePawnAbility(caster, newPawn);
                    }

                    IntVec3 position = corpse.Position;

                    GenSpawn.Spawn(newPawn, position);

                    if ((newPawn.Faction == caster.pawn.Faction) &&
                        (brain != null))
                    {
                        brain.AddPawn(newPawn);
                    }
                }

                Building building = StoreUtility.StoringBuilding(corpse);
                if (building != null)
                {
                    ((Building_Storage)building).Notify_LostThing(corpse);
                }
                corpse.Destroy(DestroyMode.Vanish);

                //if (this.healUntil > 0)
                //{
                //    HediffSet hediffSet = newPawn.healthTracker.hediffSet;
                //    while ((newPawn.healthTracker.summaryHealth.SummaryHealthPercent >= this.healUntil) &&
                //        (AbilityEffect_Revive.HittablePartsViolence(hediffSet).Any<BodyPartRecord>()))
                //    {
                //        BodyPartRecord bodyPartRecord = AbilityEffect_Revive.HittablePartsViolence(hediffSet).RandomElementByWeight((BodyPartRecord x) => x.absoluteFleshCoverage);
                //        int amount = Rand.RangeInclusive(8, 25);
                //        DamageDef def;
                //        if (bodyPartRecord.depth == BodyPartDepth.Outside)
                //            def = HealthUtility.RandomViolenceDamageType();
                //        else
                //            def = DamageDefOf.Blunt;
                //        DamageInfo dinfo = new DamageInfo(def, amount, null, new BodyPartDamageInfo?(new BodyPartDamageInfo(bodyPartRecord, false, (List<HediffDef>)null)), null);
                //        newPawn.TakeDamage(dinfo);
                //    }
                //}
            }
        }