Massive amount of bugfixes, too many to list in commit log

This commit is contained in:
Anuken
2018-07-05 12:05:53 -04:00
parent 4a32706c5a
commit b9ef88951e
33 changed files with 278 additions and 156 deletions

View File

@@ -55,6 +55,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
public float boostHeat;
public Color color = new Color();
public Mech mech;
public int spawner;
public NetConnection con;
public int playerIndex = 0;
@@ -63,7 +64,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
public TargetTrait target;
public TargetTrait moveTarget;
private boolean respawning;
private float walktime;
private Queue<BuildRequest> placeQueue = new ThreadQueue<>();
private Tile mining;
@@ -175,6 +175,11 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
return mech.weapon.getAmmoType(item) != null && inventory.canAcceptAmmo(mech.weapon.getAmmoType(item));
}
@Override
public void added() {
baseRotation = 90f;
}
@Override
public void addAmmo(Item item) {
inventory.addAmmo(mech.weapon.getAmmoType(item));
@@ -222,7 +227,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
if(player == null) return;
player.dead = true;
player.respawning = false;
player.placeQueue.clear();
player.dropCarry();
@@ -435,11 +439,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
if(isDead()){
isBoosting = false;
boostHeat = 0f;
CoreEntity entity = (CoreEntity)getClosestCore();
if (!respawning && entity != null) {
entity.trySetPlayer(this);
}
updateRespawning();
return;
}
@@ -656,7 +656,6 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
inventory.clear();
placeQueue.clear();
dead = true;
respawning = false;
trail.clear();
health = maxHealth();
@@ -667,12 +666,18 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
return isShooting && inventory.hasAmmo() && (!isBoosting || mech.flying);
}
public void setRespawning(){
respawning = true;
public void updateRespawning(){
CoreEntity entity = (CoreEntity)getClosestCore();
if (entity != null) {
this.spawner = entity.tile.id();
entity.updateSpawning(this);
}
}
public void setRespawning(boolean respawning){
this.respawning = respawning;
public void beginRespawning(SpawnerTrait spawner){
this.spawner = spawner.getTile().packedPosition();
this.dead = true;
}
@Override
@@ -735,6 +740,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
buffer.writeByte(mech.id);
buffer.writeBoolean(isBoosting);
buffer.writeInt(mining == null ? -1 : mining.packedPosition());
buffer.writeInt(spawner);
writeBuilding(buffer);
}
@@ -750,6 +756,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
mech = Upgrade.getByID(buffer.readByte());
boolean boosting = buffer.readBoolean();
int mine = buffer.readInt();
spawner = buffer.readInt();
readBuilding(buffer, !isLocal);
interpolator.read(lastx, lasty, x, y, time, rotation);

View File

@@ -131,6 +131,10 @@ public class TileEntity extends BaseEntity implements TargetTrait {
}
}
public Tile getTile(){
return tile;
}
@Override
public Team getTeam() {
return tile.getTeam();

View File

@@ -132,6 +132,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
@Override
public void readSave(DataInput stream) throws IOException {
byte team = stream.readByte();
boolean dead = stream.readBoolean();
float x = stream.readFloat();
float y = stream.readFloat();
byte xv = stream.readByte();
@@ -141,6 +142,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
this.status.readSave(stream);
this.inventory.readSave(stream);
this.dead = dead;
this.team = Team.all[team];
this.health = health;
this.x = x;
@@ -151,6 +153,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
public void writeSave(DataOutput stream, boolean net) throws IOException {
stream.writeByte(team.ordinal());
stream.writeBoolean(isDead());
stream.writeFloat(net ? interpolator.target.x : x);
stream.writeFloat(net ? interpolator.target.y : y);
stream.writeByte((byte)(Mathf.clamp(velocity.x, -maxAbsVelocity, maxAbsVelocity) * velocityPercision));

View File

@@ -192,7 +192,9 @@ public interface BuilderTrait extends Entity{
entity.construct(unit, core, 1f / entity.buildCost * Timers.delta() * getBuildPower(tile));
}
unit.rotation = Mathf.slerpDelta(unit.rotation, unit.angleTo(entity), 0.4f);
if(unit.distanceTo(tile) <= placeDistance){
unit.rotation = Mathf.slerpDelta(unit.rotation, unit.angleTo(entity), 0.4f);
}
current.progress = entity.progress();
}
@@ -239,7 +241,11 @@ public interface BuilderTrait extends Entity{
Tile tile = world.tile(request.x, request.y);
Draw.color(unit.distanceTo(tile) > placeDistance || request.remove ? Palette.remove : Palette.accent);
if(unit.distanceTo(tile) > placeDistance){
return;
}
Draw.color(Palette.accent);
float focusLen = 3.8f + Mathf.absin(Timers.time(), 1.1f, 0.6f);
float px = unit.x + Angles.trnsx(unit.rotation, focusLen);
float py = unit.y + Angles.trnsy(unit.rotation, focusLen);

View File

@@ -0,0 +1,10 @@
package io.anuke.mindustry.entities.traits;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.world.Tile;
public interface SpawnerTrait {
Tile getTile();
void updateSpawning(Unit unit);
float getSpawnProgress();
}

View File

@@ -12,6 +12,7 @@ import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.effect.ScorchDecal;
import io.anuke.mindustry.entities.traits.ShooterTrait;
import io.anuke.mindustry.entities.traits.SpawnerTrait;
import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.TeamInfo.TeamData;
@@ -52,7 +53,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
protected boolean isWave;
protected Squad squad;
protected int spawner = -1;
protected int spawner;
/**Initialize the type and team of this unit. Only call once!*/
public void init(UnitType type, Team team){
@@ -62,8 +63,8 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
this.team = team;
}
public void setSpawner(UnitFactoryEntity spawner) {
this.spawner = spawner.tile.packedPosition();
public void setSpawner(Tile tile) {
this.spawner = tile.packedPosition();
}
public UnitType getType() {
@@ -92,6 +93,19 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
((TileEntity)target).tile.block().flags.contains(flag);
}
public void updateRespawning(){
if(spawner == -1) return;
Tile tile = world.tile(spawner);
if(tile != null && tile.entity != null){
if(tile.entity instanceof SpawnerTrait){
((SpawnerTrait) tile.entity).updateSpawning(this);
}
}else{
spawner = -1;
}
}
public void setState(UnitState state){
this.state.set(state);
}
@@ -254,6 +268,11 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
if(hitTime < 0) hitTime = 0;
if(isDead()){
updateRespawning();
return;
}
if(Net.client()){
interpolate();
status.update(this);
@@ -322,7 +341,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
hitboxTile.setSize(type.hitsizeTile);
state.set(getStartState());
heal();
health(maxHealth());
}
@Override
@@ -353,6 +372,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
public void write(DataOutput data) throws IOException{
super.writeSave(data);
data.writeByte(type.id);
data.writeInt(spawner);
}
@Override
@@ -360,6 +380,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
float lastx = x, lasty = y, lastrot = rotation;
super.readSave(data);
this.type = UnitType.getByID(data.readByte());
this.spawner = data.readInt();
interpolator.read(lastx, lasty, x, y, time, rotation);
rotation = lastrot;