New save slot system / Buffed smelter / Fixed flying shadow glitches

This commit is contained in:
Anuken
2018-07-17 09:18:19 -04:00
parent f184b0700f
commit d7812ec030
8 changed files with 28 additions and 30 deletions

View File

@@ -41,8 +41,8 @@ public class Vars{
public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases"; public static final String releasesURL = "https://api.github.com/repos/Anuken/Mindustry/releases";
public static final int maxTextLength = 150; public static final int maxTextLength = 150;
public static final int maxNameLength = 40; public static final int maxNameLength = 40;
public static final int maxCharNameLength = 20; //public static final int maxCharNameLength = 20;
public static final int saveSlots = 64; // public static final int saveSlots = 64;
public static final float itemSize = 5f; public static final float itemSize = 5f;
public static final int tilesize = 8; public static final int tilesize = 8;
public static final int sectorSize = 256; public static final int sectorSize = 256;

View File

@@ -21,7 +21,7 @@ public class CraftingBlocks extends BlockList implements ContentList{
health = 70; health = 70;
result = Items.carbide; result = Items.carbide;
craftTime = 45f; craftTime = 45f;
burnDuration = 35f; burnDuration = 46f;
useFlux = true; useFlux = true;
consumes.items(new ItemStack[]{new ItemStack(Items.tungsten, 3)}); consumes.items(new ItemStack[]{new ItemStack(Items.tungsten, 3)});

View File

@@ -276,7 +276,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
@Override @Override
public void drawShadow(){ public void drawShadow(){
Draw.rect(mech.iconRegion, x - elevation * elevationScale, y - elevation * elevationScale, rotation - 90); Draw.rect(mech.iconRegion, x , y, rotation - 90);
} }
@Override @Override

View File

@@ -19,6 +19,7 @@ import io.anuke.ucore.entities.impl.DestructibleEntity;
import io.anuke.ucore.entities.trait.DamageTrait; import io.anuke.ucore.entities.trait.DamageTrait;
import io.anuke.ucore.entities.trait.DrawTrait; import io.anuke.ucore.entities.trait.DrawTrait;
import io.anuke.ucore.entities.trait.SolidTrait; import io.anuke.ucore.entities.trait.SolidTrait;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Fill; import io.anuke.ucore.graphics.Fill;
import io.anuke.ucore.util.Geometry; import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
@@ -44,7 +45,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
* Maximum absolute value of a velocity vector component. * Maximum absolute value of a velocity vector component.
*/ */
public static final float maxAbsVelocity = 127f / velocityPercision; public static final float maxAbsVelocity = 127f / velocityPercision;
public static final float elevationScale = 4f;
private static final Vector2 moveVector = new Vector2(); private static final Vector2 moveVector = new Vector2();
@@ -59,7 +59,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
protected Vector2 velocity = new Translator(0f, 0.0001f); protected Vector2 velocity = new Translator(0f, 0.0001f);
protected float hitTime; protected float hitTime;
protected float drownTime; protected float drownTime;
protected float elevation;
@Override @Override
public UnitInventory getInventory(){ public UnitInventory getInventory(){
@@ -235,10 +234,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
if(isFlying()){ if(isFlying()){
x += velocity.x / getMass() * Timers.delta(); x += velocity.x / getMass() * Timers.delta();
y += velocity.y / getMass() * Timers.delta(); y += velocity.y / getMass() * Timers.delta();
if(tile != null){
elevation = Mathf.lerpDelta(elevation, tile.elevation, 0.04f);
}
}else{ }else{
boolean onLiquid = floor.isLiquid; boolean onLiquid = floor.isLiquid;
@@ -318,6 +313,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
} }
public void drawShadow(){ public void drawShadow(){
Draw.rect(getIconRegion(), x , y, rotation - 90);
} }
public void drawView(){ public void drawView(){

View File

@@ -123,11 +123,6 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
} }
@Override
public void drawShadow(){
Draw.rect(type.region, x - elevation * elevationScale, y - elevation * elevationScale, rotation - 90);
}
@Override @Override
public CarriableTrait getCarry(){ public CarriableTrait getCarry(){
return carrying; return carrying;

View File

@@ -4,9 +4,9 @@ import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.core.GameState.State; import io.anuke.mindustry.core.GameState.State;
import io.anuke.mindustry.game.EventType.StateChangeEvent; import io.anuke.mindustry.game.EventType.StateChangeEvent;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.io.SaveIO; import io.anuke.mindustry.io.SaveIO;
import io.anuke.mindustry.io.SaveMeta; import io.anuke.mindustry.io.SaveMeta;
import io.anuke.mindustry.maps.Map;
import io.anuke.ucore.core.Events; import io.anuke.ucore.core.Events;
import io.anuke.ucore.core.Settings; import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
@@ -33,12 +33,15 @@ public class Saves{
public void load(){ public void load(){
saves.clear(); saves.clear();
for(int i = 0; i < saveSlots; i++){ int[] slots = Settings.getJson("save-slots", int[].class);
if(SaveIO.isSaveValid(i)){
SaveSlot slot = new SaveSlot(i); for(int i = 0; i < slots.length; i++){
int index = slots[i];
if(SaveIO.isSaveValid(index)){
SaveSlot slot = new SaveSlot(index);
saves.add(slot); saves.add(slot);
slot.meta = SaveIO.getData(i); slot.meta = SaveIO.getData(index);
nextSlot = i + 1; nextSlot = Math.max(index + 1, nextSlot);
} }
} }
} }
@@ -80,10 +83,6 @@ public class Saves{
return saving; return saving;
} }
public boolean canAddSave(){
return nextSlot < saveSlots;
}
public void addSave(String name){ public void addSave(String name){
SaveSlot slot = new SaveSlot(nextSlot); SaveSlot slot = new SaveSlot(nextSlot);
nextSlot++; nextSlot++;
@@ -92,6 +91,8 @@ public class Saves{
SaveIO.saveToSlot(slot.index); SaveIO.saveToSlot(slot.index);
slot.meta = SaveIO.getData(slot.index); slot.meta = SaveIO.getData(slot.index);
current = slot; current = slot;
saveSlots();
} }
public SaveSlot importSave(FileHandle file) throws IOException{ public SaveSlot importSave(FileHandle file) throws IOException{
@@ -102,6 +103,7 @@ public class Saves{
saves.add(slot); saves.add(slot);
slot.meta = SaveIO.getData(slot.index); slot.meta = SaveIO.getData(slot.index);
current = slot; current = slot;
saveSlots();
return slot; return slot;
} }
@@ -109,6 +111,15 @@ public class Saves{
return saves; return saves;
} }
private void saveSlots(){
int[] result = new int[saves.size];
for(int i = 0; i < result.length; i++){
result[i] = saves.get(i).index;
}
Settings.putJson("save-slots", result);
Settings.save();
}
public class SaveSlot{ public class SaveSlot{
public final int index; public final int index;
SaveMeta meta; SaveMeta meta;

View File

@@ -22,10 +22,6 @@ public class SaveDialog extends LoadDialog{
} }
public void addSetup(){ public void addSetup(){
if(!control.getSaves().canAddSave()){
return;
}
slots.row(); slots.row();
slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14 * 3, () -> slots.addImageTextButton("$text.save.new", "icon-add", "clear", 14 * 3, () ->
ui.showTextInput("$text.save", "$text.save.newslot", "", text -> { ui.showTextInput("$text.save", "$text.save.newslot", "", text -> {

View File

@@ -123,7 +123,7 @@ public class HudFragment extends Fragment{
//paused table //paused table
parent.fill(t -> { parent.fill(t -> {
t.top().visible(() -> state.is(State.paused) && !Net.active()); t.top().visible(() -> state.is(State.paused) && !Net.active());
t.table(top -> top.add("[orange]< " + Bundles.get("text.paused") + " >").pad(6).get().setFontScale(fontScale * 0.75f)); t.table("pane", top -> top.add("[orange]< " + Bundles.get("text.paused") + " >").pad(6).get().setFontScale(fontScale * 1.5f));
}); });
//'saving' indicator //'saving' indicator