Fixed potential spawner issues

This commit is contained in:
Anuken
2018-11-07 16:41:33 -05:00
parent 6967d4e762
commit 832aac0e6e
4 changed files with 12 additions and 18 deletions

View File

@@ -145,7 +145,7 @@ public class Renderer extends RendererModule{
if(players[0].isDead()){
TileEntity core = players[0].getClosestCore();
if(core != null && players[0].spawner == -1){
if(core != null && players[0].spawner == Unit.noSpawner){
smoothCamera(core.x, core.y, 0.08f);
}else{
smoothCamera(position.x + 0.0001f, position.y + 0.0001f, 0.08f);

View File

@@ -60,7 +60,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
public boolean achievedFlight;
public Color color = new Color();
public Mech mech;
public int spawner = -1;
public int spawner = noSpawner;
public NetConnection con;
public int playerIndex = 0;
@@ -497,7 +497,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
updateRespawning();
return;
}else{
spawner = -1;
spawner = noSpawner;
}
avoidOthers(1f);
@@ -787,7 +787,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
public void updateRespawning(){
if(spawner != -1 && world.tile(spawner) != null && world.tile(spawner).entity instanceof SpawnerTrait){
if(spawner != noSpawner && world.tile(spawner) != null && world.tile(spawner).entity instanceof SpawnerTrait){
((SpawnerTrait) world.tile(spawner).entity).updateSpawning(this);
}else{
CoreEntity entity = (CoreEntity) getClosestCore();
@@ -803,7 +803,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
}
public void endRespawning(){
spawner = -1;
spawner = noSpawner;
}
//endregion

View File

@@ -12,6 +12,7 @@ import io.anuke.mindustry.net.Interpolator;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.StatusEffect;
import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Pos;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.Floor;
import io.anuke.ucore.core.Effects;
@@ -39,6 +40,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
public static final float velocityPercision = 8f;
/**Maximum absolute value of a velocity vector component.*/
public static final float maxAbsVelocity = 127f / velocityPercision;
public static final int noSpawner = Pos.get(-1, 1);
private static final Rectangle queryRect = new Rectangle();
private static final Vector2 moveVector = new Vector2();

View File

@@ -55,7 +55,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
protected boolean isWave;
protected Squad squad;
protected int spawner = -1;
protected int spawner = noSpawner;
/**internal constructor used for deserialization, DO NOT USE*/
public BaseUnit(){
@@ -114,18 +114,10 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
return type;
}
public Tile getSpawner(){
return world.tile(spawner);
}
public void setSpawner(Tile tile){
this.spawner = tile.pos();
}
public void setIntSpawner(int pos){
this.spawner = pos;
}
/**Sets this to a 'wave' unit, which means it has slightly different AI and will not run out of ammo.*/
public void setWave(){
isWave = true;
@@ -146,7 +138,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
}
public void updateRespawning(){
if(spawner == -1) return;
if(spawner == noSpawner) return;
Tile tile = world.tile(spawner);
if(tile != null && tile.entity != null){
@@ -154,7 +146,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
((SpawnerTrait) tile.entity).updateSpawning(this);
}
}else{
spawner = -1;
spawner = noSpawner;
}
}
@@ -308,7 +300,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
avoidOthers(1.25f);
if(spawner != -1 && (world.tile(spawner) == null || world.tile(spawner).entity == null)){
if(spawner != noSpawner && (world.tile(spawner) == null || world.tile(spawner).entity == null)){
damage(health);
}
@@ -341,7 +333,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
@Override
public void removed(){
spawner = -1;
spawner = noSpawner;
}
@Override