This commit is contained in:
Anuken
2018-09-05 21:30:03 -04:00
parent 2c8962cf5f
commit ae30bdd599
4 changed files with 10 additions and 17 deletions

View File

@@ -16,7 +16,6 @@ import io.anuke.mindustry.entities.effect.ItemDrop;
import io.anuke.mindustry.entities.effect.Lightning; import io.anuke.mindustry.entities.effect.Lightning;
import io.anuke.mindustry.entities.effect.Puddle; import io.anuke.mindustry.entities.effect.Puddle;
import io.anuke.mindustry.entities.traits.TypeTrait; import io.anuke.mindustry.entities.traits.TypeTrait;
import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.game.Content; import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.ContentList; import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.game.MappableContent; import io.anuke.mindustry.game.MappableContent;
@@ -204,9 +203,9 @@ public class ContentLoader{
return (T)temporaryMapper.get(type.ordinal()).get(id); return (T)temporaryMapper.get(type.ordinal()).get(id);
} }
if(id < 0){ //offset negative values by 256, as they are probably a product of byte overflow //offset negative values by 256, as they are probably a product of byte overflow
id += 256; if(id < 0) id += 256;
}
if(id >= contentMap[type.ordinal()].size || id < 0){ if(id >= contentMap[type.ordinal()].size || id < 0){
throw new RuntimeException("No " + type.name() + " with ID '" + id + "' found!"); throw new RuntimeException("No " + type.name() + " with ID '" + id + "' found!");
} }
@@ -236,7 +235,7 @@ public class ContentLoader{
} }
public Array<Item> items(){ public Array<Item> items(){
return getBy(ContentType.block); return getBy(ContentType.item);
} }
public Item item(int id){ public Item item(int id){
@@ -259,14 +258,6 @@ public class ContentLoader{
return (BulletType) getByID(ContentType.bullet, id); return (BulletType) getByID(ContentType.bullet, id);
} }
public Array<UnitType> units(){
return getBy(ContentType.unit);
}
public UnitType unit(int id){
return (UnitType) getByID(ContentType.unit, id);
}
/** /**
* Registers sync IDs for all types of sync entities. * Registers sync IDs for all types of sync entities.
* Do not register units here! * Do not register units here!

View File

@@ -91,7 +91,7 @@ public class Logic extends Module{
//this never triggers in PvP; only for checking sector game-overs //this never triggers in PvP; only for checking sector game-overs
private void checkGameOver(){ private void checkGameOver(){
if(state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){ if(!state.mode.isPvp && state.teams.get(defaultTeam).cores.size == 0 && !state.gameOver){
state.gameOver = true; state.gameOver = true;
Events.fire(new GameOverEvent()); Events.fire(new GameOverEvent());
} }

View File

@@ -17,6 +17,7 @@ import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.gen.Call; import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.graphics.Palette; import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.type.ItemStack; import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Weapon; import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
@@ -385,7 +386,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
this.isWave = stream.readBoolean(); this.isWave = stream.readBoolean();
this.spawner = stream.readInt(); this.spawner = stream.readInt();
this.type = content.unit(type); this.type = content.getByID(ContentType.unit, type);
add(); add();
} }
@@ -400,7 +401,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
public void read(DataInput data, long time) throws IOException{ public void read(DataInput data, long time) throws IOException{
float lastx = x, lasty = y, lastrot = rotation; float lastx = x, lasty = y, lastrot = rotation;
super.readSave(data); super.readSave(data);
this.type = content.unit(data.readByte()); this.type = content.getByID(ContentType.unit, data.readByte());
this.spawner = data.readInt(); this.spawner = data.readInt();
interpolator.read(lastx, lasty, x, y, time, rotation); interpolator.read(lastx, lasty, x, y, time, rotation);

View File

@@ -10,6 +10,7 @@ import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.UnitType; import io.anuke.mindustry.entities.units.UnitType;
import io.anuke.mindustry.game.Team; import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.ContentType;
import io.anuke.mindustry.ui.dialogs.FloatingDialog; import io.anuke.mindustry.ui.dialogs.FloatingDialog;
import io.anuke.mindustry.ui.dialogs.GenViewDialog; import io.anuke.mindustry.ui.dialogs.GenViewDialog;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
@@ -149,7 +150,7 @@ public class DebugFragment extends Fragment{
t.row(); t.row();
t.addButton("spawn", () -> { t.addButton("spawn", () -> {
FloatingDialog dialog = new FloatingDialog("debug spawn"); FloatingDialog dialog = new FloatingDialog("debug spawn");
for(UnitType type : content.units()){ for(UnitType type : content.<UnitType>getBy(ContentType.unit)){
dialog.content().addImageButton("white", 40, () -> { dialog.content().addImageButton("white", 40, () -> {
BaseUnit unit = type.create(player.getTeam()); BaseUnit unit = type.create(player.getTeam());
unit.setWave(); unit.setWave();