コード例 #1
0
        public override void PawnDied(Corpse corpse)
        {
            float      radius = 2f;
            CompLeaper comp   = corpse.InnerPawn.GetComp <CompLeaper>();

            if (comp != null)
            {
                radius = comp.explosionRadius;
            }
            bool flag = corpse.InnerPawn.ageTracker.CurLifeStageIndex == 0;

            if (flag)
            {
                radius = radius * Rand.Range(.8f, 1f);
            }
            else
            {
                bool flag2 = corpse.InnerPawn.ageTracker.CurLifeStageIndex == 1;
                if (flag2)
                {
                    radius = radius * Rand.Range(1.2f, 1.8f);
                }
                else
                {
                    radius = radius * Rand.Range(1.5f, 2f);
                }
            }
            GenExplosion.DoExplosion(corpse.Position, corpse.Map, radius, DamageDefOf.Burn, corpse.InnerPawn, Rand.Range(12, 16));
        }
コード例 #2
0
        public void SingleSpawnLoop(SpawnThings spawnables, IntVec3 position, Map map)
        {
            bool flag = spawnables.def != null;

            if (flag)
            {
                Faction faction = pawn.Faction;
                bool    flag2   = spawnables.def.race != null;
                if (flag2)
                {
                    bool flag3 = spawnables.kindDef == null;
                    if (flag3)
                    {
                        Log.Error("Missing kinddef");
                    }
                    else
                    {
                        newPawn = (TMPawnSummoned)PawnGenerator.GeneratePawn(spawnables.kindDef, faction);
                        newPawn.validSummoning = true;
                        newPawn.Spawner        = this.Caster;
                        newPawn.Temporary      = true;
                        newPawn.TicksToDestroy = 1800;

                        try
                        {
                            GenSpawn.Spawn(newPawn, position, map);
                            CompLeaper comp = newPawn.GetComp <CompLeaper>();
                            comp.explosionRadius += (verVal * .2f);
                        }
                        catch
                        {
                            Log.Message("TM_Exception".Translate(
                                            pawn.LabelShort,
                                            this.def.defName
                                            ));
                            this.Destroy(DestroyMode.Vanish);
                        }
                        if (newPawn.Faction != null && newPawn.Faction != Faction.OfPlayer)
                        {
                            Lord lord = null;
                            if (newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) => p != newPawn))
                            {
                                Predicate <Thing> validator = (Thing p) => p != newPawn && ((Pawn)p).GetLord() != null;
                                Pawn p2 = (Pawn)GenClosest.ClosestThing_Global(newPawn.Position, newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction), 99999f, validator, null);
                                lord = p2.GetLord();
                            }
                            bool flag4 = lord == null;
                            if (flag4)
                            {
                                LordJob_DefendPoint lordJob = new LordJob_DefendPoint(newPawn.Position);
                                lord = LordMaker.MakeNewLord(faction, lordJob, map, null);
                            }
                            lord.AddPawn(newPawn);
                        }
                    }
                }
                else
                {
                    Log.Message("Missing race");
                }
            }
        }