This commit is contained in:
Anuken
2020-06-26 14:27:26 -04:00
parent eabc5c15c7
commit fdf7c88083
228 changed files with 1219 additions and 1163 deletions

View File

@@ -11,6 +11,7 @@ import mindustry.content.*;
import mindustry.entities.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
import mindustry.game.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.type.*;
@@ -25,6 +26,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Import float x, y, rotation, elevation, maxHealth, drag, armor, hitSize, health;
@Import boolean dead;
@Import Team team;
private UnitController controller;
private UnitType type;
@@ -60,13 +62,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override
public float bounds(){
return hitSize() * 2f;
return hitSize * 2f;
}
@Override
public void controller(UnitController next){
this.controller = next;
if(controller.unit() != this) controller.unit(this);
if(controller.unit() != base()) controller.unit(base());
}
@Override
@@ -128,7 +130,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
public void afterSync(){
//set up type info after reading
setStats(this.type);
controller.unit(this);
controller.unit(base());
}
@Override
@@ -140,13 +142,13 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override
public void add(){
teamIndex.updateCount(team(), 1);
teamIndex.updateCount(team, 1);
}
@Override
public void remove(){
teamIndex.updateCount(team(), -1);
controller.removed(this);
teamIndex.updateCount(team, -1);
controller.removed(base());
}
@Override
@@ -155,17 +157,17 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
Effects.shake(type.landShake, type.landShake, this);
}
type.landed(this);
type.landed(base());
}
@Override
public void update(){
type.update(this);
type.update(base());
drag(type.drag * (isGrounded() ? (floorOn().dragMultiplier) : 1f));
//apply knockback based on spawns
if(team() != state.rules.waveTeam){
if(team != state.rules.waveTeam){
float relativeSize = state.rules.dropZoneRadius + bounds()/2f + 1f;
for(Tile spawn : spawner.getSpawns()){
if(within(spawn.worldx(), spawn.worldy(), relativeSize)){
@@ -180,7 +182,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
if(tile != null && isGrounded()){
//unit block update
if(tile.entity != null){
tile.entity.unitOn(this);
tile.entity.unitOn(base());
}
//kill when stuck in wall
@@ -208,7 +210,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override
public void display(Table table){
type.display(this, table);
type.display(base(), table);
}
@Override
@@ -218,17 +220,17 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
@Override
public void draw(){
type.draw(this);
type.draw(base());
}
@Override
public boolean isPlayer(){
return controller instanceof Playerc;
return controller instanceof Player;
}
@Nullable
public Playerc getPlayer(){
return isPlayer() ? (Playerc)controller : null;
public Player getPlayer(){
return isPlayer() ? (Player)controller : null;
}
@Override
@@ -240,12 +242,12 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
float flammability = item().flammability * stack().amount;
Damage.dynamicExplosion(x, y, flammability, explosiveness, 0f, bounds() / 2f, Pal.darkFlame);
Effects.scorch(x, y, (int)(hitSize() / 5));
Effects.scorch(x, y, (int)(hitSize / 5));
Fx.explosion.at(this);
Effects.shake(2f, 2f, this);
type.deathSound.at(this);
Events.fire(new UnitDestroyEvent(this));
Events.fire(new UnitDestroyEvent(base()));
if(explosiveness > 7f && isLocal()){
Events.fire(Trigger.suicideBomb);
@@ -260,7 +262,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
if(dead || net.client()) return;
//deaths are synced; this calls killed()
Call.onUnitDeath(this);
Call.onUnitDeath(base());
}
@Override