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));
}
}
}

View File

@@ -195,17 +195,15 @@ public class SStats implements SteamUserStatsCallback{
});
Events.on(LaunchEvent.class, e -> {
int total = 0;
for(Item item : Vars.content.items()){
total += Vars.state.stats.itemsDelivered.get(item, 0);
}
if(state.rules.tutorial){
completeTutorial.complete();
}
SStat.timesLaunched.add();
SStat.itemsLaunched.add(total);
});
Events.on(LaunchItemEvent.class, e -> {
SStat.itemsLaunched.add(e.stack.amount);
});
Events.on(WaveEvent.class, e -> {

View File

@@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=d969b56929d87efc946e72e31ac75184b0745e5d
archash=5b8474248a6631f8f889153785c5f1202803651e