public void Impact(Thing hitThing, Vector3 muzzle) { bool shielded = hitThing.IsShielded() && laserBeamDef.IsWeakToShields; LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 dir = (destination - muzzle).normalized; Vector3 b; if (hitThing == null) { b = destination; } else if (shielded) { b = hitThing.TrueCenter() - dir.RotatedBy(Rand.Range(-22.5f, 22.5f)) * 0.8f; } else if ((destination - hitThing.TrueCenter()).magnitude < 1) { b = destination; } else { b = hitThing.TrueCenter(); b.x += Rand.Range(-0.5f, 0.5f); b.z += Rand.Range(-0.5f, 0.5f); } /* * bool createsExplosion = this.def.projectile.explosionRadius>0f; * if (createsExplosion) * { * this.Explode(hitThing, false); * GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(this, this.def.projectile.damageDef, this.launcher.Faction); * } */ Pawn pawn = launcher as Pawn; IDrawnWeaponWithRotation weapon = null; if (pawn != null && pawn.equipment != null) { weapon = pawn.equipment.Primary as IDrawnWeaponWithRotation; } if (weapon == null) { Building_LaserGunCE turret = launcher as Building_LaserGunCE; if (turret != null) { weapon = turret.Gun as IDrawnWeaponWithRotation; } } if (hitThing is Pawn && shielded) { DamageModifier *= laserBeamDef.shieldDamageMultiplier; SpawnBeamReflections(muzzle, b, 5); } base.Impact(hitThing); }
public override void Impact(Thing hitThing) { LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 dir = (destination - Origin).normalized; Vector3 a = Origin + dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength); Impact(hitThing, a); }