diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 53e361382b..b2e221af25 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -78,13 +78,12 @@ schematic.tagexists = That tag already exists. stats = Stats stat.wave = Waves Defeated:[accent] {0} +stat.unitsCreated = Units Created:[accent] {0} stat.enemiesDestroyed = Enemies Destroyed:[accent] {0} stat.built = Buildings Built:[accent] {0} stat.destroyed = Buildings Destroyed:[accent] {0} stat.deconstructed = Buildings Deconstructed:[accent] {0} -stat.delivered = Resources Launched: stat.playtime = Time Played:[accent] {0} -stat.rank = Final Rank: [accent]{0} globalitems = [accent]Total Items map.delete = Are you sure you want to delete the map "[accent]{0}[]"? diff --git a/core/assets/sounds/wind3.ogg b/core/assets/sounds/wind3.ogg new file mode 100644 index 0000000000..35e732725b Binary files /dev/null and b/core/assets/sounds/wind3.ogg differ diff --git a/core/src/mindustry/core/Control.java b/core/src/mindustry/core/Control.java index c8ec84674f..08c811f0f1 100644 --- a/core/src/mindustry/core/Control.java +++ b/core/src/mindustry/core/Control.java @@ -172,13 +172,19 @@ public class Control implements ApplicationListener, Loadable{ Events.on(BlockDestroyEvent.class, e -> { if(e.tile.team() == player.team()){ - state.stats.buildingsDestroyed++; + state.stats.buildingsDestroyed ++; } }); Events.on(UnitDestroyEvent.class, e -> { if(e.unit.team() != player.team()){ - state.stats.enemyUnitsDestroyed++; + state.stats.enemyUnitsDestroyed ++; + } + }); + + Events.on(UnitCreateEvent.class, e -> { + if(e.unit.team == state.rules.defaultTeam){ + state.stats.unitsCreated++; } }); diff --git a/core/src/mindustry/entities/abilities/UnitSpawnAbility.java b/core/src/mindustry/entities/abilities/UnitSpawnAbility.java index c3f826e5a5..04be58be39 100644 --- a/core/src/mindustry/entities/abilities/UnitSpawnAbility.java +++ b/core/src/mindustry/entities/abilities/UnitSpawnAbility.java @@ -7,6 +7,7 @@ import arc.util.*; import mindustry.*; import mindustry.content.*; import mindustry.entities.*; +import mindustry.game.EventType.*; import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; @@ -40,6 +41,7 @@ public class UnitSpawnAbility extends Ability{ Unit u = this.unit.create(unit.team); u.set(x, y); u.rotation = unit.rotation; + Events.fire(new UnitCreateEvent(u, null, unit)); if(!Vars.net.client()){ u.add(); } diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index 5ff6a6f264..c72ffc403c 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -411,14 +411,20 @@ public class EventType{ } } - /** Called when a unit is created in a reconstructor or factory. */ + /** Called when a unit is created in a reconstructor, factory or other unit. */ public static class UnitCreateEvent{ public final Unit unit; - public final Building spawner; + public final @Nullable Building spawner; + public final @Nullable Unit spawnerUnit; - public UnitCreateEvent(Unit unit, Building spawner){ + public UnitCreateEvent(Unit unit, Building spawner, Unit spawnerUnit){ this.unit = unit; this.spawner = spawner; + this.spawnerUnit = spawnerUnit; + } + + public UnitCreateEvent(Unit unit, Building spawner){ + this(unit, spawner, null); } } diff --git a/core/src/mindustry/game/GameStats.java b/core/src/mindustry/game/GameStats.java index 19d404c802..5b54385e32 100644 --- a/core/src/mindustry/game/GameStats.java +++ b/core/src/mindustry/game/GameStats.java @@ -1,52 +1,16 @@ package mindustry.game; -import arc.math.*; -import arc.struct.*; -import mindustry.type.*; - -//TODO more stats: -//- units constructed public class GameStats{ - /** Total items delivered to global resoure counter. Campaign only. */ - public ObjectIntMap itemsDelivered = new ObjectIntMap<>(); /** Enemy (red team) units destroyed. */ public int enemyUnitsDestroyed; /** Total waves lasted. */ public int wavesLasted; - /** Total (ms) time lasted in this save/zone. */ - public long timeLasted; /** Friendly buildings fully built. */ public int buildingsBuilt; /** Friendly buildings fully deconstructed. */ public int buildingsDeconstructed; /** Friendly buildings destroyed. */ public int buildingsDestroyed; - - //unused - public RankResult calculateRank(Sector sector){ - float score = 0; - - int rankIndex = Mathf.clamp((int)score, 0, Rank.all.length - 1); - Rank rank = Rank.all[rankIndex]; - String sign = Math.abs((rankIndex + 0.5f) - score) < 0.2f || rank.name().contains("S") ? "" : (rankIndex + 0.5f) < score ? "-" : "+"; - - return new RankResult(rank, sign); - } - - public static class RankResult{ - public final Rank rank; - /** + or - */ - public final String modifier; - - public RankResult(Rank rank, String modifier){ - this.rank = rank; - this.modifier = modifier; - } - } - - public enum Rank{ - F, D, C, B, A, S, SS; - - public static final Rank[] all = values(); - } + /** Total units created by any means. */ + public int unitsCreated; } diff --git a/core/src/mindustry/ui/dialogs/GameOverDialog.java b/core/src/mindustry/ui/dialogs/GameOverDialog.java index 32e593ea0e..8ab6054b6b 100644 --- a/core/src/mindustry/ui/dialogs/GameOverDialog.java +++ b/core/src/mindustry/ui/dialogs/GameOverDialog.java @@ -4,7 +4,6 @@ import arc.*; import mindustry.core.GameState.*; import mindustry.game.EventType.*; import mindustry.game.*; -import mindustry.type.*; import static mindustry.Vars.*; @@ -52,6 +51,7 @@ public class GameOverDialog extends BaseDialog{ t.margin(13f); t.left().defaults().left(); t.add(Core.bundle.format("stat.wave", state.stats.wavesLasted)).row(); + t.add(Core.bundle.format("stat.unitsCreated", state.stats.unitsCreated)).row(); t.add(Core.bundle.format("stat.enemiesDestroyed", state.stats.enemyUnitsDestroyed)).row(); t.add(Core.bundle.format("stat.built", state.stats.buildingsBuilt)).row(); t.add(Core.bundle.format("stat.destroyed", state.stats.buildingsDestroyed)).row(); @@ -59,17 +59,6 @@ public class GameOverDialog extends BaseDialog{ if(control.saves.getCurrent() != null){ t.add(Core.bundle.format("stat.playtime", control.saves.getCurrent().getPlayTime())).row(); } - if(state.isCampaign() && !state.stats.itemsDelivered.isEmpty()){ - t.add("@stat.delivered").row(); - for(Item item : content.items()){ - if(state.stats.itemsDelivered.get(item, 0) > 0){ - t.table(items -> { - items.add(" [lightgray]" + state.stats.itemsDelivered.get(item, 0)); - items.image(item.uiIcon).size(8 * 3).pad(4); - }).left().row(); - } - } - } if(state.isCampaign() && net.client()){ t.add("@gameover.waiting").padTop(20f).row(); diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 7ced9f8052..f9fb216592 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -108,13 +108,15 @@ public class PowerNode extends PowerBlock{ Core.bundle.format("bar.powerbalance", ((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount((long)(entity.power.graph.getPowerBalance() * 60)))), () -> Pal.powerBar, - () -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded()))); + () -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded()) + )); bars.add("batteries", entity -> new Bar(() -> Core.bundle.format("bar.powerstored", (UI.formatAmount((long)entity.power.graph.getLastPowerStored())), UI.formatAmount((long)entity.power.graph.getLastCapacity())), () -> Pal.powerBar, - () -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getLastCapacity()))); + () -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getLastCapacity()) + )); bars.add("connections", entity -> new Bar(() -> Core.bundle.format("bar.powerlines", entity.power.links.size, maxNodes), diff --git a/gradle.properties b/gradle.properties index fa7fb4b746..9ff216de0d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,4 +11,4 @@ android.useAndroidX=true #used for slow jitpack builds; TODO see if this actually works http.socketTimeout=80000 http.connectionTimeout=80000 -archash=d9eb4aa5b85f51c87f2e5e78cea4043e65bd29f0 +archash=96dbecb52d98b54550bda3d6bb33c69d24884c08