public static float CalculateAdjusted(float spread, Projectile instance) { if (instance.def.HasModExtension <ScattershotProjectileExtension>()) { ScattershotProjectileExtension ext = instance.def.GetModExtensionFast <ScattershotProjectileExtension>(); spread += ext.spread * (instance.usedTarget.Cell.DistanceTo(instance.Launcher.Position) / ext.perCells); } return(spread); }
public static void ExtraProjectiles(Projectile projectile2, Thing launcher, Vector3 origin, LocalTargetInfo usedTarget, LocalTargetInfo intendedTarget, ProjectileHitFlags hitFlags, bool preventFriendlyFire, Thing equipment, ThingDef targetCoverDef, ShootLine shootLine, Verb_LaunchProjectile instance) { IDrawnWeaponWithRotation weapon = null; Pawn pawn = launcher as Pawn; if (pawn != null && pawn.equipment != null) { weapon = pawn.equipment.Primary as IDrawnWeaponWithRotation; } if (weapon == null) { Building_LaserGun turret = launcher as Building_LaserGun; if (turret != null) { weapon = turret.gun as IDrawnWeaponWithRotation; } } if (weapon != null) { float angle = (usedTarget.CenterVector3 - origin).AngleFlat() - (intendedTarget.CenterVector3 - origin).AngleFlat(); weapon.RotationOffset = (angle + 180) % 360 - 180; } projectile2.Launch(launcher, origin, usedTarget, intendedTarget, hitFlags, preventFriendlyFire, equipment, targetCoverDef); int extras = 0; IAdvancedVerb Props = instance.verbProps as IAdvancedVerb; if (Props != null) { extras = Props.ScattershotCount; } else { ScattershotProjectileExtension ext = projectile2.def.GetModExtensionFast <ScattershotProjectileExtension>(); if (ext != null && ext.projectileCount.HasValue) { extras = ext.projectileCount.Value; } } if (extras > 0) { for (int i = 0; i < extras; i++) { Projectile projectile3 = (Projectile)GenSpawn.Spawn(projectile2.def, shootLine.Source, launcher.Map, WipeMode.Vanish); projectile3.Launch(launcher, origin, usedTarget, intendedTarget, hitFlags, preventFriendlyFire, equipment, targetCoverDef); } } }