mirror of
https://github.com/Melledy/Nebula.git
synced 2026-09-20 01:29:54 +02:00
Implement achievements properly
This commit is contained in:
@@ -10,6 +10,7 @@ import org.reflections.Reflections;
|
||||
import emu.nebula.util.JsonUtils;
|
||||
import emu.nebula.util.Utils;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.game.achievement.AchievementHelper;
|
||||
|
||||
public class ResourceLoader {
|
||||
private static boolean loaded = false;
|
||||
@@ -22,6 +23,9 @@ public class ResourceLoader {
|
||||
// Load
|
||||
loadResources();
|
||||
|
||||
// Add hardcoded achievements params
|
||||
AchievementHelper.fixParams();
|
||||
|
||||
// Done
|
||||
loaded = true;
|
||||
Nebula.getLogger().info("Resource loading complete");
|
||||
|
||||
@@ -2,7 +2,8 @@ package emu.nebula.data.resources;
|
||||
|
||||
import emu.nebula.data.BaseDef;
|
||||
import emu.nebula.data.ResourceType;
|
||||
|
||||
import emu.nebula.game.achievement.AchievementHelper;
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@@ -18,9 +19,32 @@ public class AchievementDef extends BaseDef {
|
||||
private int Tid1;
|
||||
private int Qty1;
|
||||
|
||||
// Custom params
|
||||
private transient int param1 = -1;
|
||||
private transient int param2 = -1;
|
||||
|
||||
@Override
|
||||
public int getId() {
|
||||
return Id;
|
||||
}
|
||||
|
||||
public void setParams(int param1, int param2) {
|
||||
this.param1 = param1;
|
||||
this.param2 = param2;
|
||||
}
|
||||
|
||||
public boolean hasParam1() {
|
||||
return this.param1 >= 0;
|
||||
}
|
||||
|
||||
public boolean hasParam2() {
|
||||
return this.param2 >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
// Add to cached achievement list
|
||||
var list = AchievementHelper.getCache().computeIfAbsent(this.CompleteCond, i -> new ObjectArrayList<>());
|
||||
list.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import lombok.Getter;
|
||||
@ResourceType(name = "StarTower.json")
|
||||
public class StarTowerDef extends BaseDef {
|
||||
private int Id;
|
||||
private int GroupId;
|
||||
private int Difficulty;
|
||||
private int[] FloorNum;
|
||||
|
||||
private transient int maxFloors;
|
||||
|
||||
Reference in New Issue
Block a user