Merge remote-tracking branch 'origin/master'

This commit is contained in:
Anuken
2022-11-04 17:28:32 -04:00
2 changed files with 4 additions and 3 deletions

View File

@@ -47,5 +47,6 @@ public class WeaponMount{
public WeaponMount(Weapon weapon){ public WeaponMount(Weapon weapon){
this.weapon = weapon; this.weapon = weapon;
this.rotation = weapon.baseRotation;
} }
} }

View File

@@ -43,7 +43,7 @@ public class Weapon implements Cloneable{
public boolean alternate = true; public boolean alternate = true;
/** whether to rotate toward the target independently of unit */ /** whether to rotate toward the target independently of unit */
public boolean rotate = false; 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; public float baseRotation = 0f;
/** whether to draw the outline on top. */ /** whether to draw the outline on top. */
public boolean top = true; 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.targetRotation = Angles.angle(axisX, axisY, mount.aimX, mount.aimY) - unit.rotation;
mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, rotateSpeed * Time.delta); mount.rotation = Angles.moveToward(mount.rotation, mount.targetRotation, rotateSpeed * Time.delta);
if(rotationLimit < 360){ if(rotationLimit < 360){
float dst = Angles.angleDist(mount.rotation, 0f); float dst = Angles.angleDist(mount.rotation, baseRotation);
if(dst > rotationLimit/2f){ 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){ }else if(!rotate){