Many various bugfixes, more aggressive memory optimization
This commit is contained in:
@@ -502,7 +502,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait {
|
||||
|
||||
movement.setZero();
|
||||
|
||||
String section = "player_" + (playerIndex + 1);
|
||||
String section = control.input(playerIndex).section;
|
||||
|
||||
float xa = Inputs.getAxis(section, "move_x");
|
||||
float ya = Inputs.getAxis(section, "move_y");
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
||||
|
||||
this.status.readSave(stream);
|
||||
this.inventory.readSave(stream);
|
||||
this.team = Team.values()[team];
|
||||
this.team = Team.all[team];
|
||||
this.health = health;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
||||
@@ -220,7 +220,7 @@ public class Units {
|
||||
/**Iterates over all units in a rectangle.*/
|
||||
public static void getNearby(Rectangle rect, Consumer<Unit> cons){
|
||||
|
||||
for(Team team : Team.values()){
|
||||
for(Team team : Team.all){
|
||||
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||
if(!group.isEmpty()){
|
||||
EntityPhysics.getNearby(group, rect, entity -> cons.accept((Unit)entity));
|
||||
@@ -253,7 +253,7 @@ public class Units {
|
||||
/**Iterates over all units.*/
|
||||
public static void getAllUnits(Consumer<Unit> cons){
|
||||
|
||||
for(Team team : Team.values()){
|
||||
for(Team team : Team.all){
|
||||
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||
for(Unit unit : group.all()){
|
||||
cons.accept(unit);
|
||||
|
||||
@@ -145,7 +145,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
y = data.readFloat();
|
||||
velocity.x = data.readFloat();
|
||||
velocity.y = data.readFloat();
|
||||
team = Team.values()[data.readByte()];
|
||||
team = Team.all[data.readByte()];
|
||||
type = BulletType.getByID(data.readByte());
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ import static io.anuke.mindustry.Vars.world;
|
||||
public interface BuilderTrait {
|
||||
//these are not instance variables!
|
||||
Translator[] tmptr = {new Translator(), new Translator(), new Translator(), new Translator()};
|
||||
float placeDistance = 200f;
|
||||
float placeDistance = 140f;
|
||||
float mineDistance = 70f;
|
||||
|
||||
/**Returns the queue for storing build requests.*/
|
||||
@@ -118,7 +118,8 @@ public interface BuilderTrait {
|
||||
|
||||
Tile tile = world.tile(current.x, current.y);
|
||||
|
||||
if(unit.distanceTo(tile) > placeDistance) { //out of range, skip it.
|
||||
if(unit.distanceTo(tile) > placeDistance || //out of range, skip it
|
||||
(current.lastEntity != null && current.lastEntity.isDead())) { //build/destroy request has died, skip it
|
||||
getPlaceQueue().removeFirst();
|
||||
}else if(current.remove){
|
||||
|
||||
@@ -144,6 +145,7 @@ public interface BuilderTrait {
|
||||
|
||||
//otherwise, update it.
|
||||
BreakEntity entity = tile.entity();
|
||||
current.lastEntity = entity;
|
||||
|
||||
entity.addProgress(core, unit, 1f / entity.breakTime * Timers.delta() * getBuildPower(tile));
|
||||
unit.rotation = Mathf.slerpDelta(unit.rotation, unit.angleTo(entity), 0.4f);
|
||||
@@ -174,6 +176,7 @@ public interface BuilderTrait {
|
||||
|
||||
//otherwise, update it.
|
||||
BuildEntity entity = tile.entity();
|
||||
current.lastEntity = entity;
|
||||
|
||||
entity.addProgress(core.items, 1f / entity.recipe.cost * Timers.delta() * getBuildPower(tile));
|
||||
if(unit instanceof Player){
|
||||
@@ -288,7 +291,9 @@ public interface BuilderTrait {
|
||||
public final int x, y, rotation;
|
||||
public final Recipe recipe;
|
||||
public final boolean remove;
|
||||
|
||||
public boolean requested;
|
||||
public TileEntity lastEntity;
|
||||
|
||||
public float progress;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface SyncTrait extends Entity, TypeTrait {
|
||||
|
||||
/**Whether smoothing of entities is enabled when using multithreading; not yet implemented.*/
|
||||
static boolean isSmoothing(){
|
||||
return threads.isEnabled() && threads.getFPS() <= Gdx.graphics.getFramesPerSecond() / 2f;
|
||||
return threads.isEnabled() && threads.getTPS() <= Gdx.graphics.getFramesPerSecond() / 2f;
|
||||
}
|
||||
|
||||
/**Sets the position of this entity and updated the interpolator.*/
|
||||
|
||||
Reference in New Issue
Block a user