mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-13 19:39:04 +07:00
Turn notification
This commit is contained in:
parent
bdbc8ab6d2
commit
2b46659daf
@ -32,6 +32,7 @@ public class EventType{
|
||||
update
|
||||
}
|
||||
|
||||
public static class TurnEvent{}
|
||||
public static class WinEvent{}
|
||||
public static class LoseEvent{}
|
||||
public static class LaunchEvent{}
|
||||
@ -67,6 +68,7 @@ public class EventType{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class CommandIssueEvent{
|
||||
public final Tilec tile;
|
||||
public final UnitCommand command;
|
||||
|
@ -38,7 +38,17 @@ public class Stats{
|
||||
|
||||
/** Updates export statistics. */
|
||||
public void handleItemExport(ItemStack stack){
|
||||
export.getOr(stack.item, ExportStat::new).counter += stack.amount;
|
||||
handleItemExport(stack.item, stack.amount);
|
||||
}
|
||||
|
||||
/** Updates export statistics. */
|
||||
public void handleItemExport(Item item, int amount){
|
||||
export.getOr(item, ExportStat::new).counter += amount;
|
||||
}
|
||||
|
||||
/** Subtracts from export statistics. */
|
||||
public void handleItemImport(Item item, int amount){
|
||||
export.getOr(item, ExportStat::new).counter -= amount;
|
||||
}
|
||||
|
||||
public float getExport(Item item){
|
||||
|
@ -6,6 +6,7 @@ import arc.struct.ObjectFloatMap.*;
|
||||
import arc.util.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.io.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
@ -76,7 +77,7 @@ public class Universe{
|
||||
for(Sector sector : planet.sectors){
|
||||
|
||||
//ignore the current sector if the player is in it right now
|
||||
if(sector.hasSave() && !sector.isBeingPlayed()){
|
||||
if(sector.hasBase() && !sector.isBeingPlayed()){
|
||||
SaveMeta meta = sector.save.meta;
|
||||
|
||||
for(Entry<Item> entry : meta.exportRates){
|
||||
@ -103,12 +104,13 @@ public class Universe{
|
||||
turn ++;
|
||||
turnCounter = 0;
|
||||
|
||||
//TODO EVENTS
|
||||
//TODO EVENTS + a notification
|
||||
|
||||
//increment turns passed for sectors with waves
|
||||
//TODO a turn passing may break the core; detect this, send an event and mark the sector as having no base!
|
||||
for(Planet planet : content.planets()){
|
||||
for(Sector sector : planet.sectors){
|
||||
//attacks happen even for sectors without bases - stuff still gets destroyed
|
||||
if(!sector.isBeingPlayed() && sector.hasSave() && sector.hasWaves()){
|
||||
sector.setTurnsPassed(sector.getTurnsPassed() + 1);
|
||||
}
|
||||
@ -120,6 +122,20 @@ public class Universe{
|
||||
for(int i = 0; i < exports.length; i++){
|
||||
data.addItem(content.item(i), exports[i]);
|
||||
}
|
||||
|
||||
Events.fire(new TurnEvent());
|
||||
}
|
||||
|
||||
public int getTurn(){
|
||||
return turn;
|
||||
}
|
||||
|
||||
public int getSectorsAttacked(){
|
||||
int count = 0;
|
||||
for(Planet planet : content.planets()){
|
||||
count += planet.sectors.count(s -> !s.isBeingPlayed() && s.hasSave() && s.hasWaves());
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public float secondsMod(float mod, float scale){
|
||||
|
@ -364,7 +364,7 @@ public class PlanetDialog extends FloatingDialog{
|
||||
}).fillX().row();
|
||||
|
||||
//production
|
||||
if(selected.hasSave() && selected.save.meta.hasProduction){
|
||||
if(selected.hasBase() && selected.save.meta.hasProduction){
|
||||
stable.add("Production:").row();
|
||||
stable.table(t -> {
|
||||
t.left();
|
||||
@ -381,7 +381,7 @@ public class PlanetDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
//disaply how many turns this sector has been attacked
|
||||
if(selected.getTurnsPassed() > 0){
|
||||
if(selected.getTurnsPassed() > 0 && selected.hasBase()){
|
||||
stable.row();
|
||||
|
||||
stable.add("[scarlet]" + Iconc.warning + " " + selected.getTurnsPassed() + "x attacks");
|
||||
|
@ -41,7 +41,13 @@ public class HudFragment extends Fragment{
|
||||
|
||||
private long lastToast;
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
Events.on(TurnEvent.class, e -> {
|
||||
//TODO localize, clean up, etc
|
||||
int attacked = universe.getSectorsAttacked();
|
||||
showToast("New turn: [accent]" + universe.getTurn() + "[]" + (attacked > 0 ? "\n[scarlet]" + Iconc.warning + " " + attacked + " sectors attacked!": ""));
|
||||
});
|
||||
|
||||
//menu at top left
|
||||
parent.fill(cont -> {
|
||||
|
Loading…
Reference in New Issue
Block a user