Automatic assignment of entities

This commit is contained in:
Anuken
2020-04-27 01:31:41 -04:00
parent 2f3c098b50
commit a4d49f5d17
11 changed files with 102 additions and 29 deletions

View File

@@ -25,6 +25,8 @@ import static mindustry.Vars.*;
@EntityDef(value = {Playerc.class}, serialize = false)
@Component
abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Drawc{
static final float deathDelay = 30f;
@NonNull @ReadOnly Unitc unit = Nulls.unit;
@ReadOnly Team team = Team.sharded;
@@ -33,6 +35,7 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
boolean admin, typing;
Color color = new Color();
float mouseX, mouseY;
float deathTimer;
String lastText = "";
float textFadeTime;
@@ -76,8 +79,12 @@ abstract class PlayerComp implements UnitController, Entityc, Syncc, Timerc, Dra
x(unit.x());
y(unit.y());
unit.team(team);
deathTimer = 0;
}else if(core != null){
core.requestSpawn((Playerc)this);
deathTimer += Time.delta();
if(deathTimer >= deathDelay){
core.requestSpawn((Playerc)this);
}
}
textFadeTime -= Time.delta() / (60 * 5);