public void Setup(Thing launcher, Vector3 origin, Vector3 destination, Verb verb = null, Thing hitThing = null, Effecter effecter = null, EffecterDef effecterDef = null) { //SetColor(launcher); this.launcher = launcher; this.verb = verb; this.a = origin; this.b = destination; this.hitThing = hitThing ?? null; this.effecter = effecter ?? null; this.effecterDef = effecterDef ?? null; Map map = verb?.Caster?.Map ?? launcher.Map; Vector3 dir = (destination - origin).normalized; dir.y = 0; Vector3 a = origin;// += dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength); if (verb != null) { if (verb.Muzzle(out float barrelLength, out float barrelOffset, out float bulletOffset, out FleckDef flareDef, out float flareSize, out FleckDef smokeDef, out float smokeSize)) { a = origin -= dir * (barrelOffset * (verb.EquipmentSource.def.graphicData.drawSize.magnitude / 4)); a.y += 0.0367346928f; if (flareDef != null) { IAdvancedVerb properties = verb.verbProps as IAdvancedVerb; Rand.PushState(); AdeptusFleckMaker.Static(a, map, flareDef, flareSize, properties?.MuzzleFlareColor, properties != null && properties.MuzzleFlareRotates ? (float?)Rand.Range(0, 350) : null, projDef.lifetime); Rand.PopState(); } if (smokeDef != null) { AdeptusFleckMaker.ThrowSmoke(a, smokeSize, map, smokeDef); } } FleckMaker.Static(a, launcher.Map, FleckDefOf.ShotFlash, verb.verbProps.muzzleFlashScale); } if (effecter == null) { TriggerEffect(effecterDef, b, hitThing); } ProjectileVFX ext = this.projDef.GetModExtensionFast <ProjectileVFX>(); if (ext != null && destination.InBounds(launcher.Map)) { Vector3 pos = destination; ThingDef explosionMoteDef = ext.ExplosionMoteDef ?? projDef.projectile.damageDef.explosionCellMote ?? null; SoundDef sound = projDef.projectile.damageDef.soundExplosion; Color? color = ext.useGraphicColor ? projDef.graphic.color : (ext.useGraphicColorTwo ? projDef.graphic.colorTwo : projDef.projectile.damageDef.explosionColorCenter); float scale = ext.scaleWithProjectile ? projDef.graphic.drawSize.magnitude : 1f; ext.ImpactEffects(pos, map, explosionMoteDef, ext.ExplosionMoteSize * scale, color, sound, ext.ImpactMoteDef, ext.ImpactMoteSize * scale, ext.ImpactGlowMoteDef, ext.ImpactGlowMoteSize * scale, hitThing, null, (int)((projDef.lifetime - ticks) * 1.1f)); // ext.ImpactEffects(destination, launcher.Map, ext.ExplosionMoteDef ?? this.projDef.projectile.damageDef.explosionCellMote, ext.ExplosionMoteSize, this.projDef.projectile.damageDef.explosionColorCenter, this.projDef.projectile.damageDef.soundExplosion, ext.ImpactMoteDef, ext.ImpactMoteSize, ext.ImpactGlowMoteDef, ext.ImpactGlowMoteSize, hitThing); } }
private void EffectTick() { if (!this.nextExplosionCell.IsValid) { this.ticksToNextEffect = this.warmupTicks - this.bombIntervalTicks; this.GetNextExplosionCell(); } this.ticksToNextEffect--; if (this.ticksToNextEffect <= 0 && base.TicksLeft >= this.bombIntervalTicks) { SoundDefOf.Bombardment_PreImpact.PlayOneShot(new TargetInfo(this.nextExplosionCell, base.Map, false)); this.projectiles.Add(new OrbitalBombardment.BombardmentProjectile(base.Map, 60, this.nextExplosionCell, strikeDef.ordnance, this.angle)); this.ticksToNextEffect = this.bombIntervalTicks; this.GetNextExplosionCell(); } for (int i = this.projectiles.Count - 1; i >= 0; i--) { this.projectiles[i].Tick(); if (this.projectiles[i].LifeTime == 5 && this.projectiles[i].targetCell.Roofed(base.Map)) { if (base.HitRoof(this.projectiles[i].targetCell)) { this.projectiles.RemoveAt(i); continue; } } if (this.projectiles[i].LifeTime <= 0) { IntVec3 targetCell = this.projectiles[i].targetCell; Map map = base.Map; float randomInRange = this.explosionRadiusRange.RandomInRange; DamageDef bomb = this.projectiles[i].ordnance.projectile.damageDef; Thing instigator = this.instigator; int damAmount = this.projectiles[i].ordnance.projectile.GetDamageAmount_NewTmp(this.def, null); float armorPenetration = this.projectiles[i].ordnance.projectile.GetArmorPenetration(this); SoundDef explosionSound = null; ThingDef def = this.def; Vector3 vector = targetCell.ToVector3ShiftedWithAltitude(AltitudeLayer.Skyfaller); if (this.projectiles[i].ordnance.HasModExtension <ProjectileVFX>()) { ProjectileVFX effects = this.projectiles[i].ordnance.GetModExtensionFast <ProjectileVFX>(); effects.ImpactEffects(vector, map, effects.ExplosionMoteDef ?? this.projectiles[i].ordnance.projectile.damageDef.explosionCellMote, randomInRange, this.projectiles[i].ordnance.projectile.damageDef.explosionColorCenter, this.projectiles[i].ordnance.projectile.damageDef.soundExplosion, effects.ImpactMoteDef, randomInRange, effects.ImpactGlowMoteDef, randomInRange); } GenExplosion.DoExplosion(targetCell, map, randomInRange, bomb, instigator, damAmount, armorPenetration, explosionSound, this.weaponDef, def, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, null); this.projectiles.RemoveAt(i); } } }
private static void EffectProjectileExtension(ProjectileCE __instance, Vector3 vector, Thing hitThing) { if (__instance is LaserBeamCE beam) { return; /* * bool shielded = hitThing.IsShielded() && beam.def.IsWeakToShields; * * LaserGunDef defWeapon = beam.EquipmentDef as LaserGunDef; * Vector3 dir = (beam.destination - beam.origin).normalized; * dir.y = 0; * * Vector3 a = beam.origin + dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength); * Vector3 b; * if (hitThing == null) * { * b = beam.destination; * } * else if (shielded) * { * Rand.PushState(); * b = hitThing.TrueCenter() - dir.RotatedBy(Rand.Range(-22.5f, 22.5f)) * 0.8f; * Rand.PopState(); * } * else if ((beam.destination - hitThing.TrueCenter()).magnitude < 1) * { * b = beam.destination; * } * else * { * Rand.PushState(); * b = hitThing.TrueCenter(); * b.x += Rand.Range(-0.5f, 0.5f); * b.z += Rand.Range(-0.5f, 0.5f); * Rand.PopState(); * } * vector = b; */ } if (__instance.def.HasModExtension <ProjectileVFX>()) { ProjectileVFX effects = __instance.def.GetModExtension <ProjectileVFX>(); effects.ImpactEffects(vector, __instance.Map, effects.ExplosionMoteDef ?? __instance.def.projectile.damageDef.explosionCellMote, effects.ExplosionMoteSize, __instance.def.projectile.damageDef.explosionColorCenter, __instance.def.projectile.damageDef.soundExplosion, effects.ImpactMoteDef, effects.ImpactMoteSize, effects.ImpactGlowMoteDef, effects.ImpactGlowMoteSize, hitThing); } }