More achievement cleanup
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package mindustry.desktop.steam;
|
||||
|
||||
public enum SAchievement{
|
||||
completeTutorial,
|
||||
//completeTutorial,
|
||||
kill1kEnemies(SStat.unitsDestroyed, 1000),
|
||||
kill100kEnemies(SStat.unitsDestroyed, 1000 * 100),
|
||||
//TODO achievements for reaching 10k/min production or something
|
||||
launch10kItems(SStat.itemsLaunched, 1000 * 10),
|
||||
//TODO reduce amounts required here
|
||||
launch1milItems(SStat.itemsLaunched, 1000 * 1000),
|
||||
win10Attack(SStat.attacksWon, 10),
|
||||
win10PvP(SStat.pvpsWon, 10),
|
||||
@@ -43,8 +45,7 @@ public enum SAchievement{
|
||||
issueAttackCommand,
|
||||
active100Units(SStat.maxUnitActive, 100),
|
||||
build1000Units,
|
||||
//TODO
|
||||
buildAllUnits,
|
||||
buildAllUnits(SStat.unitsBuilt, 30),
|
||||
//TODO
|
||||
activeAllT5,
|
||||
dieExclusion,
|
||||
@@ -55,9 +56,13 @@ public enum SAchievement{
|
||||
launchItemPad,
|
||||
chainRouters,
|
||||
//TODO
|
||||
circleConveyor,
|
||||
//TODO
|
||||
becomeRouter,
|
||||
//TODO
|
||||
save20Schematics,
|
||||
//TODO
|
||||
destroyEnemyBase,
|
||||
survive10WavesNoBlocks,
|
||||
useFlameAmmo,
|
||||
coolTurret,
|
||||
|
||||
@@ -29,8 +29,8 @@ public enum SStat{
|
||||
}
|
||||
}
|
||||
|
||||
public void add(int amount){
|
||||
SVars.stats.stats.setStatI(name(), get() + amount);
|
||||
public void set(int amount){
|
||||
SVars.stats.stats.setStatI(name(), amount);
|
||||
SVars.stats.onUpdate();
|
||||
|
||||
for(SAchievement a : SAchievement.all){
|
||||
@@ -38,6 +38,10 @@ public enum SStat{
|
||||
}
|
||||
}
|
||||
|
||||
public void add(int amount){
|
||||
set(get() + 1);
|
||||
}
|
||||
|
||||
public void add(){
|
||||
add(1);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package mindustry.desktop.steam;
|
||||
|
||||
import arc.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import com.codedisaster.steamworks.*;
|
||||
import mindustry.*;
|
||||
@@ -8,6 +9,8 @@ import mindustry.content.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.game.EventType.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.desktop.steam.SAchievement.*;
|
||||
@@ -20,6 +23,8 @@ public class SStats implements SteamUserStatsCallback{
|
||||
//private ObjectSet<String> mechs = new ObjectSet<>();
|
||||
private int statSavePeriod = 4; //in minutes
|
||||
|
||||
private ObjectSet<String> blocksBuilt = new ObjectSet<>(), unitsBuilt = new ObjectSet<>();
|
||||
|
||||
public SStats(){
|
||||
stats.requestCurrentStats();
|
||||
|
||||
@@ -51,7 +56,7 @@ public class SStats implements SteamUserStatsCallback{
|
||||
|
||||
void checkUpdate(){
|
||||
if(campaign()){
|
||||
SStat.maxUnitActive.max(Groups.unit.count(t -> t.team() == player.team()));
|
||||
SStat.maxUnitActive.max(Groups.unit.count(t -> t.team == player.team()));
|
||||
|
||||
//TODO
|
||||
//if(Groups.unit.count(u -> u.type() == UnitTypes.phantom && u.team() == player.team()) >= 10){
|
||||
@@ -73,6 +78,11 @@ public class SStats implements SteamUserStatsCallback{
|
||||
}
|
||||
|
||||
private void registerEvents(){
|
||||
Events.on(ClientLoadEvent.class, e -> {
|
||||
unitsBuilt = Core.settings.getJson("units-built" , ObjectSet.class, String.class, ObjectSet::new);
|
||||
blocksBuilt = Core.settings.getJson("blocks-built" , ObjectSet.class, String.class, ObjectSet::new);
|
||||
});
|
||||
|
||||
Events.on(UnitDestroyEvent.class, e -> {
|
||||
if(ncustom()){
|
||||
if(e.unit.team != Vars.player.team()){
|
||||
@@ -105,33 +115,47 @@ public class SStats implements SteamUserStatsCallback{
|
||||
chainRouters.complete();
|
||||
}
|
||||
|
||||
//TODO implement
|
||||
if(e.tile.block() == Blocks.groundFactory){
|
||||
buildGroundFactory.complete();
|
||||
}
|
||||
|
||||
//TODO fix, cleaner impl
|
||||
if(e.tile.block() == Blocks.meltdown || e.tile.block() == Blocks.spectre || e.tile.block() == Blocks.foreshadow){
|
||||
if(e.tile.block() == Blocks.meltdown){
|
||||
Core.settings.put("meltdownp", true);
|
||||
if(blocksBuilt.add(e.tile.block().name)){
|
||||
if(blocksBuilt.contains("meltdown") && blocksBuilt.contains("spectre") && blocksBuilt.contains("foreshadow")){
|
||||
buildMeltdownSpectreForeshadow.complete();
|
||||
}
|
||||
|
||||
if(e.tile.block() == Blocks.spectre){
|
||||
Core.settings.put("spectrep", true);
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
if(e.tile.block() == Blocks.foreshadow){
|
||||
Core.settings.put("spectrep", true);
|
||||
}
|
||||
if(e.tile.block() instanceof Conveyor){
|
||||
check: {
|
||||
Tile current = e.tile;
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(current.build == null) break check;
|
||||
Tile next = current.nearby(current.build.rotation);
|
||||
if(next != null && next.block() instanceof Conveyor){
|
||||
current = next;
|
||||
}else{
|
||||
break check;
|
||||
}
|
||||
}
|
||||
|
||||
if(Core.settings.getBool("meltdownp", false) && Core.settings.getBool("spectrep", false)){
|
||||
//TODO
|
||||
//buildMeltdownSpectre.complete();
|
||||
if(current == e.tile){
|
||||
circleConveyor.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(UnitCreateEvent.class, e -> {
|
||||
if(campaign()){
|
||||
if(unitsBuilt.add(e.unit.type.name)){
|
||||
SStat.unitsBuilt.set(content.units().count(u -> unitsBuilt.contains(u.name) && !u.isHidden()));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(BlockDestroyEvent.class, e -> {
|
||||
if(campaign() && e.tile.team() != player.team()){
|
||||
SStat.blocksDestroyed.add();
|
||||
@@ -151,7 +175,11 @@ public class SStats implements SteamUserStatsCallback{
|
||||
|
||||
Events.run(Trigger.exclusionDeath, dieExclusion::complete);
|
||||
|
||||
Events.run(Trigger.drown, drown::complete);
|
||||
Events.on(UnitDrownEvent.class, e -> {
|
||||
if(campaign() && e.unit.isPlayer()){
|
||||
drown.complete();
|
||||
}
|
||||
});
|
||||
|
||||
trigger(Trigger.impactPower, powerupImpactReactor);
|
||||
|
||||
@@ -173,7 +201,11 @@ public class SStats implements SteamUserStatsCallback{
|
||||
|
||||
trigger(Trigger.phaseDeflectHit, killEnemyPhaseWall);
|
||||
|
||||
trigger(Trigger.itemLaunch, launchItemPad);
|
||||
Events.on(LaunchItemEvent.class, e -> {
|
||||
if(campaign()){
|
||||
launchItemPad.complete();
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(UnitCreateEvent.class, e -> {
|
||||
if(campaign() && e.unit.team() == player.team()){
|
||||
@@ -214,13 +246,17 @@ public class SStats implements SteamUserStatsCallback{
|
||||
}
|
||||
});
|
||||
|
||||
Events.on(ResearchEvent.class, e -> {
|
||||
if(e.content == Blocks.router) researchRouter.complete();
|
||||
Runnable checkUnlocks = () -> {
|
||||
if(Blocks.router.unlocked()) researchRouter.complete();
|
||||
|
||||
if(!TechTree.all.contains(t -> t.content.locked())){
|
||||
researchAll.complete();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//check unlocked stuff on load as well
|
||||
Events.on(ResearchEvent.class, e -> checkUnlocks.run());
|
||||
Events.on(ClientLoadEvent.class, e -> checkUnlocks.run());
|
||||
|
||||
Events.on(WinEvent.class, e -> {
|
||||
if(state.hasSector()){
|
||||
@@ -238,6 +274,8 @@ public class SStats implements SteamUserStatsCallback{
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
//TODO dead achievement
|
||||
/*
|
||||
Events.on(MechChangeEvent.class, e -> {
|
||||
@@ -249,6 +287,11 @@ public class SStats implements SteamUserStatsCallback{
|
||||
});*/
|
||||
}
|
||||
|
||||
private void save(){
|
||||
Core.settings.putJson("units-built" , String.class, unitsBuilt);
|
||||
Core.settings.putJson("blocks-built" , String.class, blocksBuilt);
|
||||
}
|
||||
|
||||
private void trigger(Trigger trigger, SAchievement ach){
|
||||
Events.run(trigger, () -> {
|
||||
if(campaign()){
|
||||
|
||||
Reference in New Issue
Block a user