isLogicControllable
This commit is contained in:
@@ -49,6 +49,11 @@ public class CommandAI extends AIController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLogicControllable(){
|
||||||
|
return !hasCommand();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAttacking(){
|
public boolean isAttacking(){
|
||||||
return target != null && unit.within(target, unit.range() + 10f);
|
return target != null && unit.within(target, unit.range() + 10f);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,6 +93,11 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
|
|||||||
return isAdded();
|
return isAdded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLogicControllable(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Replace
|
@Replace
|
||||||
public float clipSize(){
|
public float clipSize(){
|
||||||
return unit.isNull() ? 20 : unit.type.hitSize * 2f;
|
return unit.isNull() ? 20 : unit.type.hitSize * 2f;
|
||||||
|
|||||||
@@ -55,6 +55,11 @@ public class AIController implements UnitController{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLogicControllable(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void stopShooting(){
|
public void stopShooting(){
|
||||||
for(var mount : unit.mounts){
|
for(var mount : unit.mounts){
|
||||||
//ignore mount controllable stats too, they should not shoot either
|
//ignore mount controllable stats too, they should not shoot either
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ public interface UnitController{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return whether logic AI can take over */
|
||||||
|
default boolean isLogicControllable(){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
default void updateUnit(){
|
default void updateUnit(){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ public class LExecutor{
|
|||||||
/** Checks is a unit is valid for logic AI control, and returns the controller. */
|
/** Checks is a unit is valid for logic AI control, and returns the controller. */
|
||||||
@Nullable
|
@Nullable
|
||||||
public static LogicAI checkLogicAI(LExecutor exec, Object unitObj){
|
public static LogicAI checkLogicAI(LExecutor exec, Object unitObj){
|
||||||
if(unitObj instanceof Unit unit && unit.isValid() && exec.obj(varUnit) == unit && (unit.team == exec.team || exec.privileged) && !unit.isPlayer() && !(unit.isCommandable() && unit.command().hasCommand())){
|
if(unitObj instanceof Unit unit && unit.isValid() && exec.obj(varUnit) == unit && (unit.team == exec.team || exec.privileged) && unit.controller().isLogicControllable()){
|
||||||
if(unit.controller() instanceof LogicAI la){
|
if(unit.controller() instanceof LogicAI la){
|
||||||
la.controller = exec.building(varThis);
|
la.controller = exec.building(varThis);
|
||||||
return la;
|
return la;
|
||||||
|
|||||||
Reference in New Issue
Block a user