From 872b4491f6f331ab23ac01cf4886a17b980d138e Mon Sep 17 00:00:00 2001 From: MaxDorob Date: Tue, 16 Apr 2024 21:16:15 +0600 Subject: [PATCH 1/3] spinRate support --- .../CombatExtended/Projectiles/ProjectileCE.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs index 346df35707..49828163bc 100644 --- a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs +++ b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs @@ -1206,9 +1206,16 @@ public override void DrawAt(Vector3 drawLoc, bool flip = false) } else { + Quaternion shadowRotation = ExactRotation; + Quaternion projectileRotation = DrawRotation; + if (def.projectile.spinRate != 0f) + { + float num2 = 60f / def.projectile.spinRate; + shadowRotation = projectileRotation = Quaternion.AngleAxis(Find.TickManager.TicksGame % num2 / num2 * 360f, Vector3.up); + } //Projectile //Graphics.DrawMesh(MeshPool.plane10, DrawPos, DrawRotation, def.DrawMatSingle, 0); - Graphics.DrawMesh(MeshPool.GridPlane(def.graphicData.drawSize), DrawPos, DrawRotation, def.DrawMatSingle, 0); + Graphics.DrawMesh(MeshPool.GridPlane(def.graphicData.drawSize), DrawPos, projectileRotation, def.DrawMatSingle, 0); //Shadow if (castShadow) @@ -1221,7 +1228,7 @@ public override void DrawAt(Vector3 drawLoc, bool flip = false) //TODO : Vary ShadowMat plane //Graphics.DrawMesh(MeshPool.plane08, shadowPos, ExactRotation, ShadowMaterial, 0); - Graphics.DrawMesh(MeshPool.GridPlane(def.graphicData.drawSize), shadowPos, ExactRotation, ShadowMaterial, 0); + Graphics.DrawMesh(MeshPool.GridPlane(def.graphicData.drawSize), shadowPos, shadowRotation, ShadowMaterial, 0); } Comps_PostDraw(); From d0c927fce70de29e5ac645bcd38ec27f999566df Mon Sep 17 00:00:00 2001 From: MaxDorob Date: Fri, 19 Apr 2024 15:34:11 +0600 Subject: [PATCH 2/3] Changed rotation --- .../CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs index 49828163bc..125311644f 100644 --- a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs +++ b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs @@ -1211,7 +1211,9 @@ public override void DrawAt(Vector3 drawLoc, bool flip = false) if (def.projectile.spinRate != 0f) { float num2 = 60f / def.projectile.spinRate; - shadowRotation = projectileRotation = Quaternion.AngleAxis(Find.TickManager.TicksGame % num2 / num2 * 360f, Vector3.up); + var spinRotation = Quaternion.AngleAxis(Find.TickManager.TicksGame % num2 / num2 * 360f, Vector3.up); + shadowRotation *= spinRotation; + projectileRotation *= spinRotation; } //Projectile //Graphics.DrawMesh(MeshPool.plane10, DrawPos, DrawRotation, def.DrawMatSingle, 0); From c5c040af66efcc89d5aee995245b5621cfed07d6 Mon Sep 17 00:00:00 2001 From: MaxDorob Date: Sat, 20 Apr 2024 15:29:47 +0600 Subject: [PATCH 3/3] Changed to const --- .../CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs index 125311644f..9706090c92 100644 --- a/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs +++ b/Source/CombatExtended/CombatExtended/Projectiles/ProjectileCE.cs @@ -1210,7 +1210,7 @@ public override void DrawAt(Vector3 drawLoc, bool flip = false) Quaternion projectileRotation = DrawRotation; if (def.projectile.spinRate != 0f) { - float num2 = 60f / def.projectile.spinRate; + float num2 = GenTicks.TicksPerRealSecond / def.projectile.spinRate; var spinRotation = Quaternion.AngleAxis(Find.TickManager.TicksGame % num2 / num2 * 360f, Vector3.up); shadowRotation *= spinRotation; projectileRotation *= spinRotation;