protected void DrawDropSpotShadow() { if (this.ShadowMaterial is null) { return; } FallingBomb.DrawDropSpotShadow(base.DrawPos, base.Rotation, ShadowMaterial, new Vector2(this.RotatedSize.x, this.RotatedSize.z), ticksRemaining); }
private void DropBomb() { for (int i = 0; i < (bombType == BombingType.precise ? this.precisionBombingNumBombs : 1); ++i) { if (innerContainer.Any(x => ((ActiveDropPod)x)?.Contents.innerContainer.Any(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)) ?? false)) { ActiveDropPod srts = (ActiveDropPod)innerContainer.First(); Thing thing = srts?.Contents.innerContainer.FirstOrDefault(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)); if (thing is null) { return; } Thing thing2 = srts?.Contents.innerContainer.Take(thing, 1); IntVec3 bombPos = bombCells[0]; if (bombType == BombingType.carpet) { bombCells.RemoveAt(0); } int timerTickExplode = 20 + Rand.Range(0, 5); //Change later to allow release timer if (SRTSHelper.CEModLoaded) { goto Block_CEPatched; } FallingBomb bombThing = new FallingBomb(thing2, thing2.TryGetComp <CompExplosive>(), this.Map, this.def.skyfaller.shadow); bombThing.HitPoints = int.MaxValue; bombThing.ticksRemaining = timerTickExplode; IntVec3 c = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true) where x.InBounds(this.Map) select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f); bombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c) * -10); bombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c) / bombThing.ticksRemaining; Thing t = GenSpawn.Spawn(bombThing, c, this.Map); GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(t, thing2.TryGetComp <CompExplosive>().Props.explosiveDamageType, null); continue; Block_CEPatched :; ThingComp CEComp = (thing2 as ThingWithComps)?.AllComps.Find(x => x.GetType().Name == "CompExplosiveCE"); FallingBombCE CEbombThing = new FallingBombCE(thing2, CEComp.props, CEComp, this.Map, this.def.skyfaller.shadow); CEbombThing.HitPoints = int.MaxValue; CEbombThing.ticksRemaining = timerTickExplode; IntVec3 c2 = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true) where x.InBounds(this.Map) select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f); CEbombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c2) * -10); CEbombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c2) / CEbombThing.ticksRemaining; Thing CEt = GenSpawn.Spawn(CEbombThing, c2, this.Map); //GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(CEt, DamageDefOf., null); /*Is GenExplosion CE compatible?*/ } } if (bombType == BombingType.precise && bombCells.Any()) { bombCells.Clear(); } }
private void DropBomb() { for (int i = 0; i < (bombType == BombingType.precise ? this.precisionBombingNumBombs : 1); ++i) { if (innerContainer.Any(x => ((ActiveDropPod)x)?.Contents.innerContainer.Any(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)) ?? false)) { ActiveDropPod srts = (ActiveDropPod)innerContainer.First(); Thing thing = srts?.Contents.innerContainer.FirstOrDefault(y => SRTSMod.mod.settings.allowedBombs.Contains(y.def.defName)); if (thing is null) { return; } Thing thing2 = srts?.Contents.innerContainer.Take(thing, 1); IntVec3 bombPos = bombCells[0]; if (bombType == BombingType.carpet) { bombCells.RemoveAt(0); } int timerTickExplode = 20 + Rand.Range(0, 5); //Change later to allow release timer if (SRTSHelper.CEModLoaded) { goto Block_CEPatched; } FallingBomb bombThing = new FallingBomb(thing2, thing2.TryGetComp <CompExplosive>(), this.Map, this.def.skyfaller.shadow); bombThing.HitPoints = int.MaxValue; bombThing.ticksRemaining = timerTickExplode; IntVec3 c = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true) where x.InBounds(this.Map) select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f); bombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c) * -10); bombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c) / bombThing.ticksRemaining; Thing t = GenSpawn.Spawn(bombThing, c, this.Map); GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(t, thing2.TryGetComp <CompExplosive>().Props.explosiveDamageType, null); continue; Block_CEPatched :; // Replaced referencing the projectile trough the detonateProjectile property of the item's def with referencing trough AmmoSetDef. The reason is taht not all mortar shells had detonateProjectile. Don't ask how I came up with this. ProjectileCE_Explosive bombCE = (ProjectileCE_Explosive)ThingMaker.MakeThing((thing2.def as AmmoDef).AmmoSetDefs.Find(set => set.ammoTypes.Any()).ammoTypes.Find(link => link.ammo == (thing2.def as AmmoDef)).projectile, null); //ProjectileCE_Explosive bombCE = (ProjectileCE_Explosive)ThingMaker.MakeThing((AccessTools.Field(thing2.def.GetType(), "detonateProjectile").GetValue(thing2.def) as ThingDef), null); /*ThingComp CEComp = (thing2 as ThingWithComps)?.AllComps.Find(x => x.GetType().Name == "CompExplosiveCE"); * FallingBombCE CEbombThing = new FallingBombCE(thing2, CEComp.props, CEComp, this.Map, this.def.skyfaller.shadow); * CEbombThing.HitPoints = int.MaxValue; * CEbombThing.ticksRemaining = timerTickExplode;*/ IntVec3 c2 = (from x in GenRadial.RadialCellsAround(bombPos, GetCurrentTargetingRadius(), true) where x.InBounds(this.Map) select x).RandomElementByWeight((IntVec3 x) => 1f - Mathf.Min(x.DistanceTo(this.Position) / GetCurrentTargetingRadius(), 1f) + 0.05f); /*CEbombThing.angle = this.angle + (SPTrig.LeftRightOfLine(this.DrawPosCell, this.Position, c2) * -10); * CEbombThing.speed = (float)SPExtra.Distance(this.DrawPosCell, c2) / CEbombThing.ticksRemaining; * Thing CEt = GenSpawn.Spawn(CEbombThing, c2, this.Map);*/ //Basically Im stea- "borrrowing" code from Verb_LaunchProjectileCE. GenSpawn.Spawn(bombCE, this.DrawPosCell, this.Map); bombCE.canTargetSelf = false; bombCE.minCollisionDistance = 1; bombCE.intendedTarget = null; bombCE.AccuracyFactor = 1f; bombCE.Launch(this, this.DrawPosCell.ToIntVec2.ToVector2(), 0f, this.angle + UnityEngine.Random.Range(-60f, 60f), 5f, (float)SPExtra.Distance(this.DrawPosCell, c2), this); //GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(CEt, DamageDefOf., null); /*Is GenExplosion CE compatible?*/ } } if (bombType == BombingType.precise && bombCells.Any()) { bombCells.Clear(); } }