Unit command prototype

This commit is contained in:
Anuken
2022-02-08 18:30:35 -05:00
parent 2fabd39ea1
commit f9efbb6686
15 changed files with 146 additions and 20 deletions

View File

@@ -119,7 +119,7 @@ abstract class CommanderComp implements Entityc, Posc{
//reset controlled units
for(Unit unit : controlling){
if(unit.controller().isBeingControlled(self())){
unit.controller(unit.type.createController());
unit.controller(unit.type.createController(unit));
}
}

View File

@@ -82,7 +82,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
textFadeTime = 0f;
x = y = 0f;
if(!dead()){
unit.controller(unit.type.createController());
unit.resetController();
unit = Nulls.unit;
}
}
@@ -203,7 +203,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
if(this.unit != Nulls.unit){
//un-control the old unit
this.unit.controller(this.unit.type.createController());
this.unit.resetController();
}
this.unit = unit;
if(unit != Nulls.unit){

View File

@@ -259,7 +259,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
}
public void resetController(){
controller(type.createController());
controller(type.createController(self()));
}
@Override
@@ -291,6 +291,10 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
return controller instanceof AIController;
}
public boolean isCommandable(){
return controller instanceof CommandAI;
}
public int count(){
return team.data().countType(type);
}
@@ -307,7 +311,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
this.hitSize = type.hitSize;
this.hovering = type.hovering;
if(controller == null) controller(type.createController());
if(controller == null) controller(type.createController(self()));
if(mounts().length != type.weapons.size) setupWeapons(type);
if(abilities.length != type.abilities.size){
abilities = new Ability[type.abilities.size];
@@ -328,7 +332,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
public void afterRead(){
afterSync();
//reset controller state
controller(type.createController());
controller(type.createController(self()));
}
@Override