private static bool IsCellShielded(IntVec3 origin, int cellIndex, Map map, IEnumerable <IShieldField> shields)
 {
     return(new FieldQuery(shields, map)
            .IsActive()
            .Intersects(
                PositionUtility.ToVector3WithY(origin, 0),
                PositionUtility.ToVector3WithY(map.cellIndices.IndexToCell(cellIndex), 0))
            .Get()
            .Any());
 }
示例#2
0
        private static bool Block(Bullet crashPod, int damage)
        {
            if (crashPod.Map.GetComponent <ShieldManager>().Block(PositionUtility.ToVector3WithY(crashPod.Position, 0), damage))
            {
                Messages.Message("fd.shields.incident.crashpod.blocked.body".Translate(),
                                 new GlobalTargetInfo(crashPod.Position, crashPod.Map), MessageTypeDefOf.NeutralEvent);
                crashPod.def.projectile.soundExplode.PlayOneShot(
                    SoundInfo.InMap(new TargetInfo(crashPod.Position, crashPod.Map)));
                crashPod.Destroy();
                return(true);
            }

            return(false);
        }
示例#3
0
 private static bool HandleGeneric(Skyfaller skyfaller)
 {
     try
     {
         if (skyfaller.Map.GetComponent <ShieldManager>().Block(PositionUtility.ToVector3WithY(skyfaller.Position, 0),
                                                                Mod.Settings.SkyfallerDamage))
         {
             skyfaller.def.skyfaller.impactSound?.PlayOneShot(
                 SoundInfo.InMap(new TargetInfo(skyfaller.Position, skyfaller.Map)));
             Messages.Message("fd.shields.incident.skyfaller.blocked.body".Translate(), new GlobalTargetInfo(skyfaller.Position, skyfaller.Map), MessageTypeDefOf.NeutralEvent);
             skyfaller.Destroy();
             return(false);
         }
     }
     catch (InvalidOperationException) {}
     return(true);
 }
示例#4
0
 private static bool HandlePod(DropPodIncoming pod)
 {
     try
     {
         if (pod.Map.GetComponent <ShieldManager>().Block(PositionUtility.ToVector3WithY(pod.Position, 0), Mod.Settings.DropPodDamage))
         {
             // OfType<Pawn>() causes weirdness here
             foreach (var pawn in pod.Contents.innerContainer.Where(p => p is Pawn).Select(p => (Pawn)p))
             {
                 KillPawn(pawn, pod.Position, pod.Map);
             }
             pod.Destroy();
             Messages.Message("fd.shields.incident.droppod.blocked.body".Translate(), new GlobalTargetInfo(pod.Position, pod.Map), MessageTypeDefOf.NeutralEvent);
             return(false);
         }
     }
     catch (InvalidOperationException) {}
     return(true);
 }
示例#5
0
        private static bool Block(Bullet crashPod, int damage)
        {
            var crashPodBlocked = new FieldQuery(crashPod.Map)
                                  .IsActive()
                                  .Intersects(PositionUtility.ToVector3WithY(crashPod.Position, 0))
                                  .Block(damage);

            if (crashPodBlocked)
            {
                Messages.Message("fd.shields.incident.crashpod.blocked.body".Translate(),
                                 new GlobalTargetInfo(crashPod.Position, crashPod.Map), MessageTypeDefOf.NeutralEvent);
                crashPod.def.projectile.soundExplode.PlayOneShot(
                    SoundInfo.InMap(new TargetInfo(crashPod.Position, crashPod.Map)));
                crashPod.Destroy();
                return(true);
            }

            return(false);
        }