Skip to content

Commit a229c7e

Browse files
committed
commanding
1 parent e518181 commit a229c7e

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

main/src/omaloon/entities/comp/ChainedComp.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import mindustry.*;
99
import mindustry.gen.*;
1010
import mindustry.type.*;
11+
import mindustry.ai.*;
12+
import mindustry.ai.types.*;
1113
import omaloon.annotations.Annotations.*;
1214
import omaloon.gen.*;
1315
import omaloon.type.*;
@@ -188,6 +190,22 @@ public void splitTop(){
188190

189191
@Override
190192
public void update(){
193+
if(head != null && head != self() && !dead &&
194+
((Unit)self()).controller() instanceof CommandAI ai &&
195+
head instanceof Unit u && u.controller() instanceof CommandAI hai &&
196+
ai.command == UnitCommand.moveCommand && ai.hasCommand()){
197+
198+
if(ai.attackTarget == null){
199+
if(u.within(ai.targetPos, Math.max(u.hitSize() / 2f, 5f))){
200+
ai.clearCommands();
201+
ai.command(null);
202+
}else if(!hai.hasCommand() || !ai.targetPos.equals(hai.targetPos)){
203+
hai.command(ai.command);
204+
hai.commandPosition(ai.targetPos);
205+
}
206+
}
207+
}
208+
191209
if(head.type() instanceof GlasmoreUnitType headType){
192210
if(headType.killSmallChains && chainLength() < headType.segmentUnits){
193211
if(dead) Call.unitDestroy(id());
@@ -199,7 +217,9 @@ public void update(){
199217
@Replace
200218
public void rotateMove(Vec2 vec){
201219
if(head != null && head != self()){
202-
head.rotateMove(vec);
220+
if(((Unit)self()).isPlayer()){
221+
head.rotateMove(vec);
222+
}
203223
return;
204224
}
205225
float len = vec.len();

0 commit comments

Comments
 (0)