Turret serverside rotation fix
This commit is contained in:
@@ -25,6 +25,7 @@ import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.draw.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -252,6 +253,14 @@ public class Turret extends ReloadTurret{
|
||||
public abstract BulletType type();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void placeEnded(Tile tile, @Nullable Unit builder, int rotation, @Nullable Object config){
|
||||
super.placeEnded(tile, builder, rotation, config);
|
||||
if(rotate && tile.build instanceof TurretBuild turret){
|
||||
turret.rotation = tile.build.rotdeg();
|
||||
}
|
||||
}
|
||||
|
||||
public class TurretBuild extends ReloadTurretBuild implements ControlBlock{
|
||||
//TODO storing these as instance variables is horrible design
|
||||
/** Turret sprite offset, based on recoil. Updated every frame. */
|
||||
@@ -277,20 +286,6 @@ public class Turret extends ReloadTurret{
|
||||
|
||||
float lastRangeChange;
|
||||
|
||||
@Override
|
||||
public void placed(){
|
||||
super.placed();
|
||||
if(rotate){
|
||||
rotation = rotdeg();
|
||||
}
|
||||
}
|
||||
|
||||
//overridden so that the rotation isn't affected during repairs (standard placed() code isn't called)
|
||||
@Override
|
||||
public void onRepaired(){
|
||||
super.placed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(){
|
||||
super.remove();
|
||||
@@ -505,6 +500,11 @@ public class Turret extends ReloadTurret{
|
||||
heatReq = calculateHeat(sideHeat);
|
||||
}
|
||||
|
||||
if(rotate){
|
||||
//sync underlying rotation; 0-3 rotation is a shadowed field
|
||||
((Building)this).rotation = Mathf.mod(Mathf.round(rotation / 90f), 4);
|
||||
}
|
||||
|
||||
//turret always reloads regardless of whether it's targeting something
|
||||
if(reloadWhileCharging || !charging()){
|
||||
updateReload();
|
||||
|
||||
Reference in New Issue
Block a user