protected override void Impact(Thing hitThing) { Map map = base.Map; if (!this.initialized) { caster = this.launcher as Pawn; CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>(); verVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Custom, "TM_Explosion", "_ver", true); pwrVal = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_Custom, "TM_Explosion", "_pwr", true); this.arcaneDmg = comp.arcaneDmg; this.CheckSpawnSustainer(); this.strikePos = base.Position; this.duration = 360 - (verVal * 3); this.damage = this.DamageAmount * this.arcaneDmg * (1f + (.02f * pwrVal)); this.radius = this.def.projectile.explosionRadius + (int)(verVal / 10); this.initialized = true; this.outerRing = TM_Calc.GetOuterRing(this.strikePos, radius - 1, radius); Color color = colorInt.ToColor; Projectile_Explosion.MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color); } if (this.sustainer != null) { this.sustainer.info.volumeFactor = this.age / this.duration; this.sustainer.Maintain(); if (this.TicksLeft <= 0) { this.sustainer.End(); this.sustainer = null; } } //there are 6 + 3 phases to explosion (this is no simple matter) //phase 1 - warmup and power collection; depicted by wind drawing into a focal point //phase 2 - pause (for dramatic effect) //phase 3 - initial explosion, ie the "shockwave" //phase 4 - ripping winds (the debris launched by the explosion) //phase 5 - burning winds (heat and flame - scorched earth) //phase 6 - aftershock //training adds 3 phases //phase 3a - emp //phase 4a - secondary explosions //phase 5a - radiation //warmup 2 seconds if (this.age <= (int)(this.duration * .4f) && this.outerRing.Count > 0) { for (int i = 0; i < 3; i++) { Vector3 startPos = outerRing.RandomElement().ToVector3Shifted(); Vector3 direction = TM_Calc.GetVector(startPos, strikePos.ToVector3Shifted()); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, startPos, this.Map, .8f, .3f, .05f, .6f, 0, 12f, (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(), 0); } } else if (this.age <= (int)(this.duration * .6f)) { //pause } else if (this.age > (int)(this.duration * .6f) && !phase3Flag) { if (!phase2Flag) { TargetInfo ti = new TargetInfo(this.strikePos, map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 2, 0f, .1f, .4f, 0, 15f); Effecter igniteED = TorannMagicDefOf.TM_ExplosionED.Spawn(); igniteED.Trigger(new TargetInfo(this.strikePos, map, false), new TargetInfo(this.strikePos, map, false)); igniteED.Cleanup(); SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikePos, map, false), MaintenanceType.None); info.pitchFactor = .75f; info.volumeFactor = 2.6f; TorannMagicDefOf.TM_FireWooshSD.PlayOneShot(info); this.phase2Flag = true; } this.expandingTick++; if (expandingTick <= this.radius) { IntVec3 centerCell = base.Position; if (this.expandingTick <= 1 || oldExplosionCells.Count() <= 0) { oldExplosionCells = GenRadial.RadialCellsAround(centerCell, expandingTick - 1, true); } else { oldExplosionCells = newExplosionCells; } newExplosionCells = GenRadial.RadialCellsAround(centerCell, expandingTick, true); IEnumerable <IntVec3> explosionCells = newExplosionCells.Except(oldExplosionCells); foreach (IntVec3 cell in explosionCells) { if (cell.InBounds(map)) { Vector3 heading = (cell - centerCell).ToVector3(); Vector3 direction = TM_Calc.GetVector(centerCell, cell); float angle = (Quaternion.AngleAxis(90, Vector3.up) * direction).ToAngleFlat(); if (this.expandingTick >= 6 && this.expandingTick < 8) { TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_DirectionalDirt, cell.ToVector3Shifted(), map, .8f, .2f, .15f, .5f, 0, 7f, angle, angle); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_ExpandingFlame, cell.ToVector3Shifted(), map, 1.1f, .3f, .02f, .25f, 0, 15f, angle, angle); } List <Thing> hitList = cell.GetThingList(map); for (int j = 0; j < hitList.Count; j++) { Thing burnThing = hitList[j]; DamageInfo dinfo = new DamageInfo(DamageDefOf.Flame, Mathf.RoundToInt(Rand.Range(this.damage * .25f, this.damage * .35f)), 1, -1, this.launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown); burnThing.TakeDamage(dinfo); } } } } else { TargetInfo ti = new TargetInfo(this.strikePos, map, false); TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, 4, 0f, .1f, .4f, .5f, 2f); this.expandingTick = 0; this.phase3Flag = true; } } else if (phase3Flag) { this.expandingTick++; if (expandingTick < 4) { float energy = 80000 * this.arcaneDmg; GenTemperature.PushHeat(this.strikePos, this.Map, energy); GenExplosion.DoExplosion(this.strikePos, this.Map, this.radius / (4 - this.expandingTick), DamageDefOf.Bomb, this.launcher, Mathf.RoundToInt(Rand.Range(this.damage * .7f, this.damage * .9f)), 1, DamageDefOf.Bomb.soundExplosion, null, null, null, null, 0, 0, false, null, 0, 0, .4f, true); } } this.Destroy(DestroyMode.Vanish); }