Preparing to refactor entity module

This commit is contained in:
Anuken
2019-02-02 14:42:47 -05:00
parent 636bfdb530
commit 6b2f2d0664
4 changed files with 10 additions and 18 deletions

View File

@@ -16,7 +16,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.content;
/** Class for controlling status effects on an entity.*/
public class StatusController implements Saveable{
public class Statuses implements Saveable{
private static final StatusEntry globalResult = new StatusEntry();
private static final Array<StatusEntry> removals = new Array<>();

View File

@@ -23,6 +23,7 @@ import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.Teams.TeamData;
import io.anuke.mindustry.net.Interpolator;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.StatusEffect;
import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Pos;
@@ -36,7 +37,7 @@ import java.io.IOException;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.tilesize;
public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait, InventoryTrait{
public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait{
/**Total duration of hit flash effect*/
public static final float hitDuration = 9f;
/**Percision divisor of velocity, used when writing. For example a value of '2' would mean the percision is 1/2 = 0.5-size chunks.*/
@@ -48,26 +49,20 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
private static final Rectangle queryRect = new Rectangle();
private static final Vector2 moveVector = new Vector2();
public final UnitInventory inventory = new UnitInventory(this);
public float rotation;
public float hitTime;
protected final Interpolator interpolator = new Interpolator();
protected final StatusController status = new StatusController();
protected Team team = Team.blue;
protected final Statuses status = new Statuses();
protected final ItemStack inventory = new ItemStack(content.item(0), 0);
protected float drownTime;
protected Team team = Team.blue;
protected float drownTime, hitTime;
@Override
public boolean movable(){
return !isDead();
}
@Override
public UnitInventory getInventory(){
return inventory;
}
@Override
public boolean collidesGrid(int x, int y){
return !isFlying();
@@ -114,7 +109,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
@Override
public void onDeath(){
inventory.clear();
inventory.amount = 0;
drownTime = 0f;
status.clear();
Events.fire(new UnitDestroyEvent(this));
@@ -344,10 +339,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
Draw.rect(getIconRegion(), x + offsetX, y + offsetY, rotation - 90);
}
public void drawView(){
Fill.circle(x, y, getViewDistance());
}
public float getViewDistance(){
return 135f;
}

View File

@@ -7,6 +7,7 @@ import io.anuke.arc.math.geom.Vector2;
* Used to group entities together, for formations and such.
* Usually, squads are used by units spawned in the same wave.
*/
//TODO remove? is this necessary?
public class Squad{
public Vector2 direction = new Vector2();
public int units;

View File

@@ -9,7 +9,7 @@ import io.anuke.arc.graphics.Color;
import io.anuke.arc.math.Mathf;
import io.anuke.arc.util.Time;
import io.anuke.mindustry.content.Fx;
import io.anuke.mindustry.entities.StatusController.StatusEntry;
import io.anuke.mindustry.entities.Statuses.StatusEntry;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.game.Content;