Skip to content

Commit b61f950

Browse files
committed
Command turret controller to quickly set target
1 parent b7eb5c3 commit b61f950

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/extrasandredux/world/blocks/logic/TurretController.java

+21
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import arc.util.*;
1111
import arc.util.io.*;
1212
import extrasandredux.util.*;
13+
import extrasandredux.world.blocks.logic.TurretController.TurretControllerBuild.*;
1314
import mindustry.entities.units.*;
1415
import mindustry.game.*;
1516
import mindustry.gen.*;
@@ -23,6 +24,8 @@
2324
import static mindustry.Vars.*;
2425

2526
public class TurretController extends Block{
27+
protected static Vec2 tmpVec = new Vec2();
28+
2629
protected TextureRegion modeRegion;
2730
protected TextureRegion plugRegion0, plugRegion1;
2831

@@ -36,6 +39,7 @@ public TurretController(String name){
3639
rotateDraw = false;
3740
configurable = true;
3841
saveConfig = false;
42+
commandable = true;
3943

4044
config(Integer.class, (TurretControllerBuild tile, Integer state) -> {
4145
tile.controlState = ControlState.values()[state];
@@ -81,6 +85,23 @@ public class TurretControllerBuild extends Building{
8185
/** x = angle, y = distance */
8286
public Vec2 targetSetting = new Vec2();
8387

88+
@Override
89+
public Vec2 getCommandPosition(){
90+
if(front() instanceof TurretBuild b && b.team == team){
91+
tmpVec.trns(targetSetting.x, targetSetting.y).add(b);
92+
return tmpVec;
93+
}else{
94+
return null;
95+
}
96+
}
97+
98+
@Override
99+
public void onCommand(Vec2 target){
100+
if(front() instanceof TurretBuild b && b.team == team){
101+
targetSetting.set(b.angleTo(target), b.dst(target));
102+
}
103+
}
104+
84105
@Override
85106
public void created(){
86107
targetSetting.set(90, 80);

0 commit comments

Comments
 (0)