コード例 #1
0
 public static bool ImpactSomething(Projectile __instance)
 {
     if (__instance.def.projectile.flyOverhead)
     {
         RoofDef roofDef = __instance.Map.roofGrid.RoofAt(__instance.Position);
         if (roofDef != null)
         {
             if (roofDef.isThickRoof)
             {
                 ThrowDebugText(__instance, "hit-thick-roof", __instance.Position);
                 __instance.def.projectile.soundHitThickRoof.PlayOneShot((SoundInfo) new TargetInfo(__instance.Position, __instance.Map, false));
                 __instance.Destroy(DestroyMode.Vanish);
                 return(false);
             }
             if (__instance.Position.GetEdifice(__instance.Map) == null || __instance.Position.GetEdifice(__instance.Map).def.Fillage != FillCategory.Full)
             {
                 RoofCollapserImmediate.DropRoofInCells(__instance.Position, __instance.Map, (List <Thing>)null);
             }
         }
     }
     if (__instance.usedTarget.HasThing && CanHit(__instance, __instance.usedTarget.Thing))
     {
         if (__instance.usedTarget.Thing is Pawn thing && thing.GetPosture() != PawnPosture.Standing && ((double)(origin(__instance) - destination(__instance)).MagnitudeHorizontalSquared() >= 20.25 && !Rand.Chance(0.2f)))
         {
             ThrowDebugText(__instance, "miss-laying", __instance.Position);
             //Impact.Invoke(__instance, new object[] { (Thing)null });
             Impact(__instance, null);
         }
         else
         {
             Impact(__instance, __instance.usedTarget.Thing);
         }
     }
コード例 #2
0
        protected virtual void HitRoof()
        {
            if (!this.def.skyfaller.hitRoof)
            {
                return;
            }
            CellRect cr = this.OccupiedRect();

            if (cr.Cells.Any((IntVec3 x) => x.Roofed(this.Map)))
            {
                RoofDef roof = cr.Cells.First((IntVec3 x) => x.Roofed(this.Map)).GetRoof(base.Map);
                if (!roof.soundPunchThrough.NullOrUndefined())
                {
                    roof.soundPunchThrough.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
                }
                RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(base.Map).Cells.Where(delegate(IntVec3 c)
                {
                    if (!c.InBounds(this.Map))
                    {
                        return(false);
                    }
                    if (cr.Contains(c))
                    {
                        return(true);
                    }
                    if (c.GetFirstPawn(this.Map) != null)
                    {
                        return(false);
                    }
                    Building edifice = c.GetEdifice(this.Map);
                    return(edifice == null || !edifice.def.holdsRoof);
                }), base.Map, null);
            }
        }
コード例 #3
0
 //Modified collision with downed pawns
 private void ImpactSomething()
 {
     //Not modified, just mortar code
     if (def.projectile.flyOverhead)
     {
         RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position);
         if (roofDef != null)
         {
             if (roofDef.isThickRoof)
             {
                 this.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
                 this.Destroy(DestroyMode.Vanish);
                 return;
             }
             if (base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full)
             {
                 RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map);
             }
         }
     }
     //Modified
     if (assignedTarget != null && assignedTarget.Position == Position)
     //it was aimed at something and that something is still there
     {
         ImpactThroughBodySize(assignedTarget,
                               GetProjectileHeight(shotHeight, distanceFromOrigin, shotAngle, shotSpeed));
     }
     else
     {
         Thing thing = base.Map.thingGrid.ThingAt(Position, ThingCategory.Pawn);
         if (thing != null)
         {
             ImpactThroughBodySize(thing,
                                   GetProjectileHeight(shotHeight, distanceFromOrigin, shotAngle, shotSpeed));
             return;
         }
         List <Thing> list   = base.Map.thingGrid.ThingsListAt(Position);
         float        height = list.Count > 0
             ? GetProjectileHeight(shotHeight, distanceFromOrigin, shotAngle, shotSpeed)
             : 0;
         if (height > 0)
         {
             for (int i = 0; i < list.Count; i++)
             {
                 Thing thing2   = list[i];
                 bool  impacted = ImpactThroughBodySize(thing2, height);
                 if (impacted)
                 {
                     return;
                 }
             }
         }
         Impact(null);
     }
 }
コード例 #4
0
        //Modified collision with downed pawns
        private void ImpactSomething()
        {
            if (BlockerRegistry.ImpactSomethingCallback(this, launcher))
            {
                this.Destroy();
                return;
            }
            var pos = ExactPosition.ToIntVec3();

            //Not modified, just mortar code
            if (def.projectile.flyOverhead)
            {
                var roofDef = Map.roofGrid.RoofAt(pos);
                if (roofDef != null)
                {
                    if (roofDef.isThickRoof)
                    {
                        def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(pos, Map));
                        Destroy();
                        return;
                    }
                    if (pos.GetEdifice(Map) == null || pos.GetEdifice(Map).def.Fillage != FillCategory.Full)
                    {
                        RoofCollapserImmediate.DropRoofInCells(pos, Map);
                    }
                }
            }

            // FIXME : Early opt-out
            Thing thing = pos.GetFirstPawn(Map);

            if (thing != null && TryCollideWith(thing))
            {
                return;
            }

            var list = Map.thingGrid.ThingsListAt(pos).Where(t => t is Pawn || t.def.Fillage != FillCategory.None).ToList();

            if (list.Count > 0)
            {
                foreach (var thing2 in list)
                {
                    if (TryCollideWith(thing2))
                    {
                        return;
                    }
                }
            }

            ExactPosition = ExactPosition;
            landed        = true;
            Impact(null);
        }
コード例 #5
0
        //Modified collision with downed pawns
        private void ImpactSomething()
        {
            //Not modified, just mortar code
            if (def.projectile.flyOverhead)
            {
                RoofDef roofDef = base.Map.roofGrid.RoofAt(Position);
                if (roofDef != null)
                {
                    if (roofDef.isThickRoof)
                    {
                        this.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
                        this.Destroy(DestroyMode.Vanish);
                        return;
                    }
                    if (base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full)
                    {
                        RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map);
                    }
                }
            }
            //Modified
            var height = Height;

            // Determine flight path - Need to refactor this to be less hacky
            var pos     = Vec2Position;
            var lastPos = Vector2.Lerp(this.origin, Destination, (fTicks - 1) / StartingTicksToImpact);

            var vec3dest    = new Vector3(pos.x, GetHeightAtTicks(FlightTicks), pos.y);
            var vec3lastPos = new Vector3(lastPos.x, GetHeightAtTicks(FlightTicks - 1), lastPos.y);
            var shotLine    = new Ray(vec3lastPos, (vec3dest - vec3lastPos));

            // FIXME : Early opt-out
            Thing thing = Position.GetFirstPawn(Map);

            if (thing != null && TryCollideWith(thing, shotLine))
            {
                return;
            }
            List <Thing> list = Map.thingGrid.ThingsListAt(Position).Where(t => t is Pawn || t.def.Fillage != FillCategory.None).ToList();

            if (list.Count > 0)
            {
                foreach (var thing2 in list)
                {
                    if (TryCollideWith(thing2, shotLine))
                    {
                        return;
                    }
                }
            }
            Impact(null);
        }
コード例 #6
0
ファイル: OrbitalStrike.cs プロジェクト: Ogliss/AdMechArmoury
        public bool HitRoof(IntVec3 c)
        {
            RoofDef roofDef = base.Map.roofGrid.RoofAt(c);

            if (roofDef != null)
            {
                this.ThrowDebugText("hit-roofed-Cell", c);
                if (roofDef.isThickRoof)
                {
                    this.ThrowDebugText("hit-thick-roof", c);
                    if (Rand.Chance(strikeDef.roofThickCollapseChance))
                    {
                        this.ThrowDebugText("collapse-thick-roof", c);
                        if (c.GetEdifice(base.Map) == null || c.GetEdifice(base.Map).def.Fillage != FillCategory.Full)
                        {
                            RoofCollapserImmediate.DropRoofInCells(c, base.Map, null);
                        }
                    }
                    else
                    {
                        this.ThrowDebugText("stopped-thick-roof", c);
                        if (this.weaponDef?.projectile?.soundHitThickRoof != null)
                        {
                            this.weaponDef.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(c, base.Map, false));
                        }
                        return(true);
                    }
                }
                else
                {
                    this.ThrowDebugText("hit-thin-roof", c);
                    if (Rand.Chance(strikeDef.roofThinCollapseChance))
                    {
                        this.ThrowDebugText("collapse-thin-roof", c);
                        if (c.GetEdifice(base.Map) == null || c.GetEdifice(base.Map).def.Fillage != FillCategory.Full)
                        {
                            RoofCollapserImmediate.DropRoofInCells(c, base.Map, null);
                        }
                    }
                    else
                    {
                        this.ThrowDebugText("stopped-thin-roof", c);
                        if (this.weaponDef?.projectile?.soundHitThickRoof != null)
                        {
                            this.weaponDef.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(c, base.Map, false));
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
コード例 #7
0
ファイル: JPSkyFaller.cs プロジェクト: zwfengineer/Jetpack
        // 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;
            }
        }
コード例 #8
0
 private void DestroyRoofs()
 {
     removedRoofsTmp.Clear();
     foreach (IntVec3 item in from x in GenRadial.RadialCellsAround(base.Position, 4.2f, useCenter: true)
              where x.InBounds(base.Map)
              select x)
     {
         if (!CellImmuneToDamage(item) && item.Roofed(base.Map))
         {
             RoofDef roof = item.GetRoof(base.Map);
             if (!roof.isThickRoof && !roof.isNatural)
             {
                 RoofCollapserImmediate.DropRoofInCells(item, base.Map);
                 removedRoofsTmp.Add(item);
             }
         }
     }
     if (removedRoofsTmp.Count > 0)
     {
         RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(removedRoofsTmp, base.Map, removalMode: true);
     }
 }
コード例 #9
0
        // Token: 0x06000089 RID: 137 RVA: 0x00005548 File Offset: 0x00003748
        internal void GHHitRoof(IntVec3 hrpcell, Pawn user)
        {
            var punchsize = new IntVec2(2, 2);
            var cr        = GenAdj.OccupiedRect(hrpcell, user.Rotation, punchsize);

            if (!cr.Cells.Any(x => x.Roofed(Map)))
            {
                return;
            }

            var roof = cr.Cells.First(x => x.Roofed(Map)).GetRoof(Map);

            if (!roof.soundPunchThrough.NullOrUndefined())
            {
                roof.soundPunchThrough.PlayOneShot(new TargetInfo(user.Position, Map));
            }

            RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(Map).Cells.Where(
                                                       delegate(IntVec3 c)
            {
                if (!c.InBounds(Map))
                {
                    return(false);
                }

                if (cr.Contains(c))
                {
                    return(true);
                }

                if (c.GetFirstPawn(Map) != null)
                {
                    return(false);
                }

                var edifice = c.GetEdifice(Map);
                return(edifice == null || !edifice.def.holdsRoof);
            }), Map);
        }
コード例 #10
0
ファイル: Sonic_Blast.cs プロジェクト: Ogliss/AdMechArmoury
 private void DestroyRoofs()
 {
     this.removedRoofsTmp.Clear();
     foreach (IntVec3 intVec in from x in GenRadial.RadialCellsAround(base.Position, this.Graphic.drawSize.magnitude * 0.75f, true)
              where x.InBounds(base.Map)
              select x)
     {
         if (!this.CellImmuneToDamage(intVec) && intVec.Roofed(base.Map))
         {
             RoofDef roof = intVec.GetRoof(base.Map);
             if (!roof.isThickRoof && !roof.isNatural)
             {
                 RoofCollapserImmediate.DropRoofInCells(intVec, base.Map, null);
                 this.removedRoofsTmp.Add(intVec);
             }
         }
     }
     if (this.removedRoofsTmp.Count > 0)
     {
         RoofCollapseCellsFinder.CheckCollapseFlyingRoofs(this.removedRoofsTmp, base.Map, true, false);
     }
 }
コード例 #11
0
 private void HitRoof()
 {
     if (!base.Position.Roofed())
     {
         return;
     }
     RoofCollapserImmediate.DropRoofInCells(this.OccupiedRect().ExpandedBy(1).Cells.Where(delegate(IntVec3 c)
     {
         if (!c.InBounds())
         {
             return(false);
         }
         if (c == base.Position)
         {
             return(true);
         }
         if (Find.ThingGrid.CellContains(c, ThingCategory.Pawn))
         {
             return(false);
         }
         Building edifice = c.GetEdifice();
         return(edifice == null || !edifice.def.holdsRoof);
     }));
 }
コード例 #12
0
        // Token: 0x06000051 RID: 81 RVA: 0x00004498 File Offset: 0x00002698
        internal void JPHitRoof(bool up)
        {
            if (!def.skyfaller.hitRoof)
            {
                return;
            }

            CellRect cr;

            if (up)
            {
                var hrpcell   = base.DrawPos.ToIntVec3();
                var punchsize = new IntVec2(3, 3);
                cr = GenAdj.OccupiedRect(hrpcell, Rotation, punchsize);
            }
            else
            {
                cr = this.OccupiedRect();
            }

            if (!cr.Cells.Any(x => x.Roofed(Map)))
            {
                return;
            }

            var roof = cr.Cells.First(x => x.Roofed(Map)).GetRoof(Map);

            if (!roof.soundPunchThrough.NullOrUndefined())
            {
                roof.soundPunchThrough.PlayOneShot(new TargetInfo(Position, Map));
            }

            RoofCollapserImmediate.DropRoofInCells(cr.ExpandedBy(1).ClipInsideMap(Map).Cells.Where(
                                                       delegate(IntVec3 c)
            {
                if (!c.InBounds(Map))
                {
                    return(false);
                }

                if (cr.Contains(c))
                {
                    return(true);
                }

                if (c.GetFirstPawn(Map) != null)
                {
                    return(false);
                }

                var edifice = c.GetEdifice(Map);
                return(edifice == null || !edifice.def.holdsRoof);
            }), Map);
            if (up)
            {
                PilotRoofPunchUp = true;
                return;
            }

            PilotRoofPunchDown = true;
        }
コード例 #13
0
ファイル: PojectileCP.cs プロジェクト: MDarque/Cyberpunk
 private void ImpactSomething()
 {
     if (this.def.projectile.flyOverhead)
     {
         RoofDef roofDef = Find.RoofGrid.RoofAt(base.Position);
         if (roofDef != null)
         {
             if (roofDef.isThickRoof)
             {
                 this.def.projectile.soundHitThickRoof.PlayOneShot(base.Position);
                 this.Destroy(DestroyMode.Vanish);
                 return;
             }
             if (base.Position.GetEdifice() == null || base.Position.GetEdifice().def.Fillage != FillCategory.Full)
             {
                 RoofCollapserImmediate.DropRoofInCells(base.Position);
             }
         }
     }
     if (this.assignedTarget != null)
     {
         Pawn pawn = this.assignedTarget as Pawn;
         if (pawn != null && pawn.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f && Rand.Value > 0.2f)
         {
             this.Impact(null);
             return;
         }
         this.Impact(this.assignedTarget);
         return;
     }
     else
     {
         ProjectileCP.cellThingsFiltered.Clear();
         List <Thing> thingList = base.Position.GetThingList();
         for (int i = 0; i < thingList.Count; i++)
         {
             Pawn pawn2 = thingList[i] as Pawn;
             if (pawn2 != null)
             {
                 ProjectileCP.cellThingsFiltered.Add(pawn2);
             }
         }
         if (ProjectileCP.cellThingsFiltered.Count > 0)
         {
             this.Impact(ProjectileCP.cellThingsFiltered.RandomElement <Thing>());
             return;
         }
         ProjectileCP.cellThingsFiltered.Clear();
         for (int j = 0; j < thingList.Count; j++)
         {
             Thing thing = thingList[j];
             if (thing.def.fillPercent > 0f || thing.def.passability != Traversability.Standable)
             {
                 ProjectileCP.cellThingsFiltered.Add(thing);
             }
         }
         if (ProjectileCP.cellThingsFiltered.Count > 0)
         {
             this.Impact(ProjectileCP.cellThingsFiltered.RandomElement <Thing>());
             return;
         }
         this.Impact(null);
         return;
     }
 }
コード例 #14
0
        private void ImpactSomething()
        {
            if (this.def.projectile.flyOverhead)
            {
                RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position);
                if (roofDef != null)
                {
                    if (roofDef.isThickRoof)
                    {
                        SoundStarter.PlayOneShot(this.def.projectile.soundHitThickRoof, new TargetInfo(base.Position, base.Map, false));
                        this.Destroy(0);
                        return;
                    }
                    if (GridsUtility.GetEdifice(base.Position, base.Map) == null || GridsUtility.GetEdifice(base.Position, base.Map).def.Fillage != FillCategory.Full)
                    {
                        RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map, null);
                    }
                }
            }
            if (!this.usedTarget.HasThing || !base.CanHit(this.usedTarget.Thing))
            {
                List <Thing> list = new List <Thing>();
                list.Clear();
                List <Thing> thingList = GridsUtility.GetThingList(base.Position, base.Map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing = thingList[i];
                    if ((thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) && base.CanHit(thing))
                    {
                        list.Add(thing);
                    }
                }
                GenList.Shuffle <Thing>(list);
                for (int j = 0; j < list.Count; j++)
                {
                    Thing thing2 = list[j];
                    Pawn  pawn   = thing2 as Pawn;
                    float num;
                    if (pawn != null)
                    {
                        num = 0.5f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f);
                        if (PawnUtility.GetPosture(pawn) != null && GenGeo.MagnitudeHorizontalSquared(this.origin - this.destination) >= 20.25f)
                        {
                            num *= 0.2f;
                        }
                        if (this.launcher != null && pawn.Faction != null && this.launcher.Faction != null && !FactionUtility.HostileTo(pawn.Faction, this.launcher.Faction))
                        {
                            num *= VerbUtility.InterceptChanceFactorFromDistance(this.origin, base.Position);
                        }
                    }
                    else
                    {
                        num = 1.5f * thing2.def.fillPercent;
                    }
                    if (Rand.Chance(num))
                    {
                        this.Impact(GenCollection.RandomElement <Thing>(list));
                        return;
                    }
                }
                this.Impact(null);
                return;
            }
            Pawn pawn2 = this.usedTarget.Thing as Pawn;

            if (pawn2 != null && PawnUtility.GetPosture(pawn2) != null && GenGeo.MagnitudeHorizontalSquared(this.origin - this.destination) >= 20.25f && !Rand.Chance(0.2f))
            {
                this.Impact(null);
                return;
            }
            this.Impact(this.usedTarget.Thing);
        }
コード例 #15
0
 // Token: 0x060052A5 RID: 21157 RVA: 0x00129F58 File Offset: 0x00128358
 private void ImpactSomething()
 {
     if (this.def.projectile.flyOverhead)
     {
         RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position);
         if (roofDef != null)
         {
             if (roofDef.isThickRoof)
             {
                 this.ThrowDebugText("hit-thick-roof", base.Position);
                 this.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
                 this.Destroy(DestroyMode.Vanish);
                 return;
             }
             if (base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full)
             {
                 RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map, null);
             }
         }
     }
     if (!this.usedTarget.HasThing || !this.CanHit(this.usedTarget.Thing))
     {
         Stuffable_Projectile.cellThingsFiltered.Clear();
         List <Thing> thingList = base.Position.GetThingList(base.Map);
         for (int i = 0; i < thingList.Count; i++)
         {
             Thing thing = thingList[i];
             if ((thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) && this.CanHit(thing))
             {
                 Stuffable_Projectile.cellThingsFiltered.Add(thing);
             }
         }
         Stuffable_Projectile.cellThingsFiltered.Shuffle <Thing>();
         for (int j = 0; j < Stuffable_Projectile.cellThingsFiltered.Count; j++)
         {
             Thing thing2 = Stuffable_Projectile.cellThingsFiltered[j];
             float num;
             if (thing2 is Pawn pawn)
             {
                 num = 0.5f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f);
                 if (pawn.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f)
                 {
                     num *= 0.2f;
                 }
                 if (this.launcher != null && pawn.Faction != null && this.launcher.Faction != null && !pawn.Faction.HostileTo(this.launcher.Faction))
                 {
                     num *= VerbUtility.InterceptChanceFactorFromDistance(this.origin, base.Position);
                 }
             }
             else
             {
                 num = 1.5f * thing2.def.fillPercent;
             }
             if (Rand.Chance(num))
             {
                 this.ThrowDebugText("hit-" + num.ToStringPercent(), base.Position);
                 this.Impact(Stuffable_Projectile.cellThingsFiltered.RandomElement <Thing>());
                 return;
             }
             this.ThrowDebugText("miss-" + num.ToStringPercent(), base.Position);
         }
         this.Impact(null);
         return;
     }
     if (this.usedTarget.Thing is Pawn pawn2 && pawn2.GetPosture() != PawnPosture.Standing && (this.origin - this.destination).MagnitudeHorizontalSquared() >= 20.25f && !Rand.Chance(0.2f))
     {
         this.ThrowDebugText("miss-laying", base.Position);
         this.Impact(null);
         return;
     }
     this.Impact(this.usedTarget.Thing);
 }
コード例 #16
0
        // Token: 0x0600000F RID: 15 RVA: 0x000026FC File Offset: 0x000008FC
        private void ImpactSomething()
        {
            bool flyOverhead = this.def.projectile.flyOverhead;

            if (flyOverhead)
            {
                RoofDef roofDef = base.Map.roofGrid.RoofAt(base.Position);
                bool    flag    = roofDef != null;
                if (flag)
                {
                    bool isThickRoof = roofDef.isThickRoof;
                    if (isThickRoof)
                    {
                        this.def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
                        this.Destroy(DestroyMode.Vanish);
                        return;
                    }
                    bool flag2 = base.Position.GetEdifice(base.Map) == null || base.Position.GetEdifice(base.Map).def.Fillage != FillCategory.Full;
                    if (flag2)
                    {
                        RoofCollapserImmediate.DropRoofInCells(base.Position, base.Map, null);
                    }
                }
            }
            bool flag3 = !this.usedTarget.HasThing || !base.CanHit(this.usedTarget.Thing);

            if (flag3)
            {
                List <Thing> list = new List <Thing>();
                list.Clear();
                List <Thing> thingList = base.Position.GetThingList(base.Map);
                for (int i = 0; i < thingList.Count; i++)
                {
                    Thing thing = thingList[i];
                    bool  flag4 = (thing.def.category == ThingCategory.Building || thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item || thing.def.category == ThingCategory.Plant) && base.CanHit(thing);
                    if (flag4)
                    {
                        list.Add(thing);
                    }
                }
                list.Shuffle <Thing>();
                for (int j = 0; j < list.Count; j++)
                {
                    Thing thing2 = list[j];
                    Pawn  pawn   = thing2 as Pawn;
                    bool  flag5  = pawn != null;
                    float num;
                    if (flag5)
                    {
                        num = 0.5f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f);
                        bool flag6 = pawn.GetPosture() != PawnPosture.Standing && GenGeo.MagnitudeHorizontalSquared(this.origin - this.destination) >= 20.25f;
                        if (flag6)
                        {
                            num *= 0.2f;
                        }
                        bool flag7 = this.launcher != null && pawn.Faction != null && this.launcher.Faction != null && !pawn.Faction.HostileTo(this.launcher.Faction);
                        if (flag7)
                        {
                            num *= VerbUtility.InterceptChanceFactorFromDistance(this.origin, base.Position);
                        }
                    }
                    else
                    {
                        num = 1.5f * thing2.def.fillPercent;
                    }
                    bool flag8 = Rand.Chance(num);
                    if (flag8)
                    {
                        this.Impact(list.RandomElement <Thing>());
                        return;
                    }
                }
                this.Impact(null);
            }
            else
            {
                Pawn pawn2 = this.usedTarget.Thing as Pawn;
                bool flag9 = pawn2 != null && pawn2.GetPosture() != PawnPosture.Standing && GenGeo.MagnitudeHorizontalSquared(this.origin - this.destination) >= 20.25f && !Rand.Chance(0.2f);
                if (flag9)
                {
                    this.Impact(null);
                }
                else
                {
                    this.Impact(this.usedTarget.Thing);
                }
            }
        }
コード例 #17
0
        // Token: 0x0600000F RID: 15 RVA: 0x000026FC File Offset: 0x000008FC
        private void ImpactSomething()
        {
            var flyOverhead = def.projectile.flyOverhead;

            if (flyOverhead)
            {
                var roofDef = Map.roofGrid.RoofAt(Position);
                if (roofDef != null)
                {
                    var isThickRoof = roofDef.isThickRoof;
                    if (isThickRoof)
                    {
                        def.projectile.soundHitThickRoof.PlayOneShot(new TargetInfo(Position, Map));
                        Destroy();
                        return;
                    }

                    if (Position.GetEdifice(Map) == null ||
                        Position.GetEdifice(Map).def.Fillage != FillCategory.Full)
                    {
                        RoofCollapserImmediate.DropRoofInCells(Position, Map);
                    }
                }
            }

            if (!usedTarget.HasThing || !CanHit(usedTarget.Thing))
            {
                var list = new List <Thing>();
                list.Clear();
                var thingList = Position.GetThingList(Map);
                foreach (var thing in thingList)
                {
                    if ((thing.def.category == ThingCategory.Building ||
                         thing.def.category == ThingCategory.Pawn || thing.def.category == ThingCategory.Item ||
                         thing.def.category == ThingCategory.Plant) && CanHit(thing))
                    {
                        list.Add(thing);
                    }
                }

                list.Shuffle();
                for (var j = 0; j < list.Count; j++)
                {
                    var   thing2 = list[j];
                    float num;
                    if (thing2 is Pawn pawn)
                    {
                        num = 0.5f * Mathf.Clamp(pawn.BodySize, 0.1f, 2f);
                        if (pawn.GetPosture() != PawnPosture.Standing &&
                            (origin - destination).MagnitudeHorizontalSquared() >= 20.25f)
                        {
                            num *= 0.2f;
                        }

                        if (launcher != null && pawn.Faction != null && launcher.Faction != null &&
                            !pawn.Faction.HostileTo(launcher.Faction))
                        {
                            num *= VerbUtility.InterceptChanceFactorFromDistance(origin, Position);
                        }
                    }
                    else
                    {
                        num = 1.5f * thing2.def.fillPercent;
                    }

                    if (!Rand.Chance(num))
                    {
                        continue;
                    }

                    Impact(list.RandomElement());
                    return;
                }

                Impact(null);
            }
            else
            {
                if (usedTarget.Thing is Pawn pawn2 && pawn2.GetPosture() != PawnPosture.Standing &&
                    (origin - destination).MagnitudeHorizontalSquared() >= 20.25f && !Rand.Chance(0.2f))
                {
                    Impact(null);
                }