mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-19 12:17:40 +07:00
Turn notification
This commit is contained in:
@ -32,6 +32,7 @@ public class EventType{
|
|||||||
update
|
update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class TurnEvent{}
|
||||||
public static class WinEvent{}
|
public static class WinEvent{}
|
||||||
public static class LoseEvent{}
|
public static class LoseEvent{}
|
||||||
public static class LaunchEvent{}
|
public static class LaunchEvent{}
|
||||||
@ -67,6 +68,7 @@ public class EventType{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class CommandIssueEvent{
|
public static class CommandIssueEvent{
|
||||||
public final Tilec tile;
|
public final Tilec tile;
|
||||||
public final UnitCommand command;
|
public final UnitCommand command;
|
||||||
|
@ -38,7 +38,17 @@ public class Stats{
|
|||||||
|
|
||||||
/** Updates export statistics. */
|
/** Updates export statistics. */
|
||||||
public void handleItemExport(ItemStack stack){
|
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){
|
public float getExport(Item item){
|
||||||
|
@ -6,6 +6,7 @@ import arc.struct.ObjectFloatMap.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.io.*;
|
import mindustry.io.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|
||||||
@ -76,7 +77,7 @@ public class Universe{
|
|||||||
for(Sector sector : planet.sectors){
|
for(Sector sector : planet.sectors){
|
||||||
|
|
||||||
//ignore the current sector if the player is in it right now
|
//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;
|
SaveMeta meta = sector.save.meta;
|
||||||
|
|
||||||
for(Entry<Item> entry : meta.exportRates){
|
for(Entry<Item> entry : meta.exportRates){
|
||||||
@ -103,12 +104,13 @@ public class Universe{
|
|||||||
turn ++;
|
turn ++;
|
||||||
turnCounter = 0;
|
turnCounter = 0;
|
||||||
|
|
||||||
//TODO EVENTS
|
//TODO EVENTS + a notification
|
||||||
|
|
||||||
//increment turns passed for sectors with waves
|
//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!
|
//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(Planet planet : content.planets()){
|
||||||
for(Sector sector : planet.sectors){
|
for(Sector sector : planet.sectors){
|
||||||
|
//attacks happen even for sectors without bases - stuff still gets destroyed
|
||||||
if(!sector.isBeingPlayed() && sector.hasSave() && sector.hasWaves()){
|
if(!sector.isBeingPlayed() && sector.hasSave() && sector.hasWaves()){
|
||||||
sector.setTurnsPassed(sector.getTurnsPassed() + 1);
|
sector.setTurnsPassed(sector.getTurnsPassed() + 1);
|
||||||
}
|
}
|
||||||
@ -120,6 +122,20 @@ public class Universe{
|
|||||||
for(int i = 0; i < exports.length; i++){
|
for(int i = 0; i < exports.length; i++){
|
||||||
data.addItem(content.item(i), exports[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){
|
public float secondsMod(float mod, float scale){
|
||||||
|
@ -364,7 +364,7 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
}).fillX().row();
|
}).fillX().row();
|
||||||
|
|
||||||
//production
|
//production
|
||||||
if(selected.hasSave() && selected.save.meta.hasProduction){
|
if(selected.hasBase() && selected.save.meta.hasProduction){
|
||||||
stable.add("Production:").row();
|
stable.add("Production:").row();
|
||||||
stable.table(t -> {
|
stable.table(t -> {
|
||||||
t.left();
|
t.left();
|
||||||
@ -381,7 +381,7 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//disaply how many turns this sector has been attacked
|
//disaply how many turns this sector has been attacked
|
||||||
if(selected.getTurnsPassed() > 0){
|
if(selected.getTurnsPassed() > 0 && selected.hasBase()){
|
||||||
stable.row();
|
stable.row();
|
||||||
|
|
||||||
stable.add("[scarlet]" + Iconc.warning + " " + selected.getTurnsPassed() + "x attacks");
|
stable.add("[scarlet]" + Iconc.warning + " " + selected.getTurnsPassed() + "x attacks");
|
||||||
|
@ -41,7 +41,13 @@ public class HudFragment extends Fragment{
|
|||||||
|
|
||||||
private long lastToast;
|
private long lastToast;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void build(Group parent){
|
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
|
//menu at top left
|
||||||
parent.fill(cont -> {
|
parent.fill(cont -> {
|
||||||
|
Reference in New Issue
Block a user