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); }
static bool Prefix(TurretTop __instance, float ___curRotationInt, Building_Turret ___parentTurret, Vector3 recoilDrawOffset, float recoilAngleOffset) { Building_LaserGunCE turret = ___parentTurret as Building_LaserGunCE; if (turret == null) { return(true); } float rotation = ___curRotationInt; if (turret.TargetCurrentlyAimingAt.HasThing) { rotation = (turret.TargetCurrentlyAimingAt.CenterVector3 - turret.TrueCenter()).AngleFlat(); } IDrawnWeaponWithRotation gunRotation = turret.Gun as IDrawnWeaponWithRotation; if (gunRotation != null) { rotation += gunRotation.RotationOffset; } Material material = ___parentTurret.def.building.turretTopMat; SpinningLaserGunTurret spinningGun = turret.Gun as SpinningLaserGunTurret; if (spinningGun != null) { spinningGun.turret = turret; material = spinningGun.Graphic.MatSingle; } Vector3 b = new Vector3(___parentTurret.def.building.turretTopOffset.x, 0f, ___parentTurret.def.building.turretTopOffset.y); float turretTopDrawSize = ___parentTurret.def.building.turretTopDrawSize; Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(turret.DrawPos + Altitudes.AltIncVect + b, (rotation + (float)TurretTop.ArtworkRotation).ToQuat(), new Vector3(turretTopDrawSize, 1f, turretTopDrawSize)); Graphics.DrawMesh(MeshPool.plane10, matrix, material, 0); return(false); }