Merge branch 'master' of https://github.com/Anuken/Mindustry into 7.0-features

This commit is contained in:
Anuken
2021-08-19 23:52:06 -04:00
32 changed files with 166 additions and 121 deletions

View File

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

View File

@@ -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<Item> 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;
}