static bool Prefix(TurretTop __instance, Vector3 recoilDrawOffset, float recoilAngleOffset, float ___curRotationInt, Building_Turret ___parentTurret) { Building_LaserGun turret = ___parentTurret as Building_LaserGun; 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 offset = new Vector3(___parentTurret.def.building.turretTopOffset.x, 0f, ___parentTurret.def.building.turretTopOffset.y).RotatedBy(___curRotationInt); float scale = ___parentTurret.def.building.turretTopDrawSize; offset = offset.RotatedBy(recoilAngleOffset); offset += recoilDrawOffset; Matrix4x4 Matrix = default(Matrix4x4); Matrix.SetTRS(___parentTurret.DrawPos + Altitudes.AltIncVect + offset, (___curRotationInt + (float)TurretTop.ArtworkRotation).ToQuat(), new Vector3(scale, 1f, scale)); Graphics.DrawMesh(MeshPool.plane10, Matrix, material, 0); return(false); }
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); }