Turret serverside rotation fix
This commit is contained in:
@@ -25,6 +25,7 @@ import mindustry.graphics.*;
|
|||||||
import mindustry.logic.*;
|
import mindustry.logic.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.*;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.draw.*;
|
import mindustry.world.draw.*;
|
||||||
import mindustry.world.meta.*;
|
import mindustry.world.meta.*;
|
||||||
@@ -252,6 +253,14 @@ public class Turret extends ReloadTurret{
|
|||||||
public abstract BulletType type();
|
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{
|
public class TurretBuild extends ReloadTurretBuild implements ControlBlock{
|
||||||
//TODO storing these as instance variables is horrible design
|
//TODO storing these as instance variables is horrible design
|
||||||
/** Turret sprite offset, based on recoil. Updated every frame. */
|
/** Turret sprite offset, based on recoil. Updated every frame. */
|
||||||
@@ -277,20 +286,6 @@ public class Turret extends ReloadTurret{
|
|||||||
|
|
||||||
float lastRangeChange;
|
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
|
@Override
|
||||||
public void remove(){
|
public void remove(){
|
||||||
super.remove();
|
super.remove();
|
||||||
@@ -505,6 +500,11 @@ public class Turret extends ReloadTurret{
|
|||||||
heatReq = calculateHeat(sideHeat);
|
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
|
//turret always reloads regardless of whether it's targeting something
|
||||||
if(reloadWhileCharging || !charging()){
|
if(reloadWhileCharging || !charging()){
|
||||||
updateReload();
|
updateReload();
|
||||||
|
|||||||
Reference in New Issue
Block a user