Commandable blocks

This commit is contained in:
Anuken
2022-02-17 16:19:07 -05:00
parent 49a39d42e7
commit 9f3af412f0
12 changed files with 177 additions and 16 deletions

View File

@@ -545,6 +545,16 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
}
/** Called when this building receives a position command. Requires a commandable block. */
public void onCommand(Vec2 target){
}
/** @return the position that this block points to for commands, or null. */
public @Nullable Vec2 getCommandPosition(){
return null;
}
public void handleUnitPayload(Unit unit, Cons<Payload> grabber){
Fx.spawn.at(unit);

View File

@@ -281,6 +281,14 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
return controller instanceof CommandAI;
}
public CommandAI command(){
if(controller instanceof CommandAI ai){
return ai;
}else{
throw new IllegalArgumentException("Unit cannot be commanded - check isCommandable() first.");
}
}
public int count(){
return team.data().countType(type);
}