protected void DestroySkyfaller(Skyfaller faller) { if (this.IsActive()) { GenExplosion.DoExplosion(faller.DrawPos.ToIntVec3(), this.Map, 1, DamageDefOf.Bomb, faller, 0); faller.Destroy(); } workingSet.Remove(faller); }
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); }
public static void Prefix(Skyfaller __instance) //patch the tick, not the creation - means shields can turn on in time to do something { if (__instance.Map != null && __instance.ticksToImpact <= 20) { var thingDefExtension = __instance.def.GetModExtension <ThingDefExtension>() ?? ThingDefExtension.defaultValues; ShieldGeneratorUtility.CheckIntercept(__instance, __instance.Map, thingDefExtension.shieldDamageIntercepted, DamageDefOf.Blunt, () => __instance.OccupiedRect().Cells, () => thingDefExtension.shieldDamageIntercepted > -1, postIntercept: s => { if (s.Energy > 0) { switch (__instance) { case DropPodIncoming dropPod: if (ShieldGeneratorUtility.CheckPodHostility(dropPod)) { var innerContainer = dropPod.Contents.innerContainer; for (int i = 0; i < innerContainer.Count; i++) { var thing = innerContainer[i]; if (thing is Pawn pawn) { ShieldGeneratorUtility.KillPawn(pawn, dropPod.Position, dropPod.Map); } } dropPod.Destroy(); return; } return; case DropPodLeaving _: return; default: __instance.Destroy(); return; } } }); } }