Fixed launched items not saving
This commit is contained in:
@@ -5,7 +5,7 @@ import io.anuke.arc.*;
|
|||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.core.GameState.*;
|
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.*;
|
||||||
import io.anuke.mindustry.entities.type.*;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
@@ -189,6 +189,7 @@ public class Logic implements ApplicationListener{
|
|||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
if(tile == null || tile.entity == null || tile.entity.items == null) continue;
|
if(tile == null || tile.entity == null || tile.entity.items == null) continue;
|
||||||
data.addItem(item, tile.entity.items.get(item));
|
data.addItem(item, tile.entity.items.get(item));
|
||||||
|
Events.fire(new LaunchItemEvent(item, tile.entity.items.get(item)));
|
||||||
}
|
}
|
||||||
world.removeBlock(tile);
|
world.removeBlock(tile);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
FloatingDialog dialog = new FloatingDialog(title);
|
||||||
dialog.cont.add(text).width(mobile ? 400f : 500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center);
|
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.buttons.defaults().size(200f, 54f).pad(2f);
|
||||||
dialog.setFillParent(false);
|
dialog.setFillParent(false);
|
||||||
dialog.buttons.addButton(no, dialog::hide);
|
dialog.buttons.addButton(no, () -> {
|
||||||
|
dialog.hide();
|
||||||
|
denied.run();
|
||||||
|
});
|
||||||
dialog.buttons.addButton(yes, () -> {
|
dialog.buttons.addButton(yes, () -> {
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
confirmed.run();
|
confirmed.run();
|
||||||
|
|||||||
@@ -37,6 +37,14 @@ public class EventType{
|
|||||||
|
|
||||||
public static class LaunchEvent{}
|
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 MapMakeEvent{}
|
||||||
|
|
||||||
public static class MapPublishEvent{}
|
public static class MapPublishEvent{}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.type.*;
|
|||||||
@Serialize
|
@Serialize
|
||||||
public class Stats{
|
public class Stats{
|
||||||
/** Items delivered to global resoure counter. Zones only. */
|
/** 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. */
|
/** Enemy (red team) units destroyed. */
|
||||||
public int enemyUnitsDestroyed;
|
public int enemyUnitsDestroyed;
|
||||||
/** Total waves lasted. */
|
/** Total waves lasted. */
|
||||||
|
|||||||
@@ -29,6 +29,14 @@ public class JsonIO{
|
|||||||
super.writeValue(value, knownType, elementType);
|
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(){
|
public static Json json(){
|
||||||
|
|||||||
@@ -74,6 +74,9 @@ public class HostDialog extends FloatingDialog{
|
|||||||
ui.showCustomConfirm("$setting.publichost.name", "$public.confirm", "$yes", "$no", () -> {
|
ui.showCustomConfirm("$setting.publichost.name", "$public.confirm", "$yes", "$no", () -> {
|
||||||
Core.settings.putSave("publichost", true);
|
Core.settings.putSave("publichost", true);
|
||||||
platform.updateLobby();
|
platform.updateLobby();
|
||||||
|
}, () -> {
|
||||||
|
Core.settings.putSave("publichost", false);
|
||||||
|
platform.updateLobby();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ public class LaunchPad extends StorageBlock{
|
|||||||
int used = Math.min(entity.items.get(item), itemCapacity);
|
int used = Math.min(entity.items.get(item), itemCapacity);
|
||||||
data.addItem(item, used);
|
data.addItem(item, used);
|
||||||
entity.items.remove(item, used);
|
entity.items.remove(item, used);
|
||||||
|
Events.fire(new LaunchItemEvent(item, used));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,17 +195,15 @@ public class SStats implements SteamUserStatsCallback{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(LaunchEvent.class, e -> {
|
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){
|
if(state.rules.tutorial){
|
||||||
completeTutorial.complete();
|
completeTutorial.complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
SStat.timesLaunched.add();
|
SStat.timesLaunched.add();
|
||||||
SStat.itemsLaunched.add(total);
|
});
|
||||||
|
|
||||||
|
Events.on(LaunchItemEvent.class, e -> {
|
||||||
|
SStat.itemsLaunched.add(e.stack.amount);
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WaveEvent.class, e -> {
|
Events.on(WaveEvent.class, e -> {
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=d969b56929d87efc946e72e31ac75184b0745e5d
|
archash=5b8474248a6631f8f889153785c5f1202803651e
|
||||||
|
|||||||
Reference in New Issue
Block a user