Fixed launched items not saving

This commit is contained in:
Anuken
2019-11-22 23:10:50 -05:00
parent cb29bee8f5
commit a1fb3e27ab
9 changed files with 33 additions and 11 deletions

View File

@@ -5,7 +5,7 @@ import io.anuke.arc.*;
import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*;
import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.ctype.UnlockableContent;
import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.game.EventType.*;
@@ -189,6 +189,7 @@ public class Logic implements ApplicationListener{
for(Item item : content.items()){
if(tile == null || tile.entity == null || tile.entity.items == null) continue;
data.addItem(item, tile.entity.items.get(item));
Events.fire(new LaunchItemEvent(item, tile.entity.items.get(item)));
}
world.removeBlock(tile);
}

View File

@@ -429,12 +429,15 @@ public class UI implements ApplicationListener, Loadable{
}
public void showCustomConfirm(String title, String text, String yes, String no, Runnable confirmed){
public void showCustomConfirm(String title, String text, String yes, String no, Runnable confirmed, Runnable denied){
FloatingDialog dialog = new FloatingDialog(title);
dialog.cont.add(text).width(mobile ? 400f : 500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
dialog.buttons.defaults().size(200f, 54f).pad(2f);
dialog.setFillParent(false);
dialog.buttons.addButton(no, dialog::hide);
dialog.buttons.addButton(no, () -> {
dialog.hide();
denied.run();
});
dialog.buttons.addButton(yes, () -> {
dialog.hide();
confirmed.run();

View File

@@ -37,6 +37,14 @@ public class EventType{
public static class LaunchEvent{}
public static class LaunchItemEvent{
public final ItemStack stack;
public LaunchItemEvent(Item item, int amount){
this.stack = new ItemStack(item, amount);
}
}
public static class MapMakeEvent{}
public static class MapPublishEvent{}

View File

@@ -9,7 +9,7 @@ import io.anuke.mindustry.type.*;
@Serialize
public class Stats{
/** Items delivered to global resoure counter. Zones only. */
public transient ObjectIntMap<Item> itemsDelivered = new ObjectIntMap<>();
public ObjectIntMap<Item> itemsDelivered = new ObjectIntMap<>();
/** Enemy (red team) units destroyed. */
public int enemyUnitsDestroyed;
/** Total waves lasted. */

View File

@@ -29,6 +29,14 @@ public class JsonIO{
super.writeValue(value, knownType, elementType);
}
}
@Override
protected String convertToString(Object object){
if(object instanceof MappableContent){
return ((MappableContent)object).name;
}
return super.convertToString(object);
}
};
public static Json json(){

View File

@@ -74,6 +74,9 @@ public class HostDialog extends FloatingDialog{
ui.showCustomConfirm("$setting.publichost.name", "$public.confirm", "$yes", "$no", () -> {
Core.settings.putSave("publichost", true);
platform.updateLobby();
}, () -> {
Core.settings.putSave("publichost", false);
platform.updateLobby();
});
}));
}

View File

@@ -80,6 +80,7 @@ public class LaunchPad extends StorageBlock{
int used = Math.min(entity.items.get(item), itemCapacity);
data.addItem(item, used);
entity.items.remove(item, used);
Events.fire(new LaunchItemEvent(item, used));
}
}
}