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); } } }
static bool Prefix(TurretTop __instance) { Building_LaserGun turret = parentTurretField.GetValue(__instance) as Building_LaserGun; if (turret == null) { return(true); } float rotation = (float)curRotationIntField.GetValue(__instance); 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 = turret.def.building.turretTopMat; SpinningLaserGunTurret spinningGun = turret.gun as SpinningLaserGunTurret; if (spinningGun != null) { spinningGun.turret = turret; material = spinningGun.Graphic.MatSingle; } Vector3 b = new Vector3(turret.def.building.turretTopOffset.x, 0f, turret.def.building.turretTopOffset.y); float turretTopDrawSize = turret.def.building.turretTopDrawSize; Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(turret.DrawPos + Altitudes.AltIncVect + b, rotation.ToQuat(), new Vector3(turretTopDrawSize, 1f, turretTopDrawSize)); Graphics.DrawMesh(MeshPool.plane10, matrix, material, 0); return(false); }