Пример #1
0
        // Token: 0x06000051 RID: 81 RVA: 0x00004498 File Offset: 0x00002698
        internal void JPHitRoof(bool up)
        {
            if (!this.def.skyfaller.hitRoof)
            {
                return;
            }
            CellRect cr;

            if (up)
            {
                IntVec3 hrpcell   = IntVec3Utility.ToIntVec3(base.DrawPos);
                IntVec2 punchsize = new IntVec2(3, 3);
                cr = GenAdj.OccupiedRect(hrpcell, base.Rotation, punchsize);
            }
            else
            {
                cr = GenAdj.OccupiedRect(this);
            }
            if (cr.Cells.Any((IntVec3 x) => GridsUtility.Roofed(x, this.Map)))
            {
                RoofDef roof = GridsUtility.GetRoof(cr.Cells.First((IntVec3 x) => GridsUtility.Roofed(x, this.Map)), base.Map);
                if (!SoundDefHelper.NullOrUndefined(roof.soundPunchThrough))
                {
                    SoundStarter.PlayOneShot(roof.soundPunchThrough, new TargetInfo(base.Position, base.Map, false));
                }
                RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(base.Map).Cells.Where(delegate(IntVec3 c)
                {
                    if (!GenGrid.InBounds(c, this.Map))
                    {
                        return(false);
                    }
                    if (cr.Contains(c))
                    {
                        return(true);
                    }
                    if (GridsUtility.GetFirstPawn(c, this.Map) != null)
                    {
                        return(false);
                    }
                    Building edifice = GridsUtility.GetEdifice(c, this.Map);
                    return(edifice == null || !edifice.def.holdsRoof);
                }), base.Map, null);
                if (up)
                {
                    this.PilotRoofPunchUp = true;
                    return;
                }
                this.PilotRoofPunchDown = true;
            }
        }
Пример #2
0
        private void PlayExplosionSound(SoundDef explosionSound)
        {
            bool devMode = Prefs.DevMode;
            bool flag;

            if (devMode)
            {
                flag = (explosionSound != null);
            }
            else
            {
                flag = !SoundDefHelper.NullOrUndefined(explosionSound);
            }
            bool flag2 = flag;

            if (flag2)
            {
                SoundStarter.PlayOneShot(explosionSound, new TargetInfo(base.Position, base.Map, false));
            }
            else
            {
                SoundStarter.PlayOneShot(this.damType.soundExplosion, new TargetInfo(base.Position, base.Map, false));
            }
        }
Пример #3
0
        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;
                if (thing != actor.pather.Destination.Thing || (!this.pawn.pather.Moving && !this.pawn.Position.AdjacentTo8WayOrInside(thing)))
                {
                    RoofDef roofDef = actor.Map.roofGrid.RoofAt(actor.Position);
                    if (roofDef != null)
                    {
                        if (roofDef != RoofDefOf.RoofConstructed)
                        {
                            return;
                        }
                        if (!SoundDefHelper.NullOrUndefined(roofDef.soundPunchThrough))
                        {
                            SoundStarter.PlayOneShot(roofDef.soundPunchThrough, new TargetInfo(actor.Position, actor.Map, false));
                            CellRect.CellRectIterator iterator = CellRect.CenteredOn(actor.Position, 1).GetIterator();
                            while (!iterator.Done())
                            {
                                Find.CurrentMap.roofGrid.SetRoof(iterator.Current, null);
                                iterator.MoveNext();
                            }
                        }
                    }
                    RoofDef roofDef2 = actor.Map.roofGrid.RoofAt(thing.Position);
                    if (roofDef2 != null)
                    {
                        if (roofDef2 != RoofDefOf.RoofConstructed)
                        {
                            return;
                        }
                        if (!SoundDefHelper.NullOrUndefined(roofDef2.soundPunchThrough))
                        {
                            SoundStarter.PlayOneShot(roofDef2.soundPunchThrough, new TargetInfo(actor.Position, actor.Map, false));
                            CellRect.CellRectIterator iterator2 = CellRect.CenteredOn(thing.Position, 1).GetIterator();
                            while (!iterator2.Done())
                            {
                                Find.CurrentMap.roofGrid.SetRoof(iterator2.Current, null);
                                iterator2.MoveNext();
                            }
                        }
                    }
                }
                actor.pather.StartPath(thing, PathEndMode.OnCell);
                actor.Position = thing.Position;
                actor.pather.StopDead();
                pawn1.pather.StopDead();
                pawn1.TakeDamage(new DamageInfo(PurpleIvyDefOf.AlienToxicSting, 3, 0f, -1f, actor, null, null));
                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;
        }