From d42c0e3c4855954985fb51145a5dbfa2e6d5833b Mon Sep 17 00:00:00 2001 From: MEEPofFaith <54301439+MEEPofFaith@users.noreply.github.com> Date: Fri, 4 Nov 2022 13:04:35 -0700 Subject: [PATCH] baseRotation + rotationLimit compatability (#7820) --- core/src/mindustry/entities/units/WeaponMount.java | 1 + core/src/mindustry/type/Weapon.java | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/entities/units/WeaponMount.java b/core/src/mindustry/entities/units/WeaponMount.java index 3bdd92f9a4..2bf0df7e6e 100644 --- a/core/src/mindustry/entities/units/WeaponMount.java +++ b/core/src/mindustry/entities/units/WeaponMount.java @@ -47,5 +47,6 @@ public class WeaponMount{ public WeaponMount(Weapon weapon){ this.weapon = weapon; + this.rotation = weapon.baseRotation; } } diff --git a/core/src/mindustry/type/Weapon.java b/core/src/mindustry/type/Weapon.java index a048118d48..ccc82ecbc0 100644 --- a/core/src/mindustry/type/Weapon.java +++ b/core/src/mindustry/type/Weapon.java @@ -43,7 +43,7 @@ public class Weapon implements Cloneable{ public boolean alternate = true; /** whether to rotate toward the target independently of unit */ public boolean rotate = false; - /** rotation at which this weapon is locked to if rotate = false. TODO buggy!*/ + /** rotation at which this weapon starts at. TODO buggy!*/ public float baseRotation = 0f; /** whether to draw the outline on top. */ public boolean top = true; @@ -282,9 +282,9 @@ public class Weapon implements Cloneable{ mount.targetRotation = Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - unit.rotation; mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, rotateSpeed * Time.delta); if(rotationLimit < 360){ - float dst = Angles.angleDist(mount.rotation, 0f); + float dst = Angles.angleDist(mount.rotation, baseRotation); if(dst > rotationLimit/2f){ - mount.rotation = Angles.moveToward(mount.rotation, 0, dst - rotationLimit/2f); + mount.rotation = Angles.moveToward(mount.rotation, baseRotation, dst - rotationLimit/2f); } } }else if(!rotate){