Implement mutual exclusives

This commit is contained in:
2025-12-04 20:46:39 +01:00
parent 9ff5d9f828
commit d0755c893f
5 changed files with 37 additions and 5 deletions
@@ -17,6 +17,11 @@ public class SkillLogic {
for (ResourceLocation neighborId : node.getLinks()) {
if (data.isUnlocked(neighborId)) return true;
}
for (ResourceLocation excl : node.getExclusiveWith()) {
if (data.isUnlocked(excl)) {
return false;
}
}
return false;
}
public static boolean meetsAscendPrerequisites(Player player, SkillNode node) {
@@ -18,6 +18,7 @@ public class SkillNode {
private final List<ResourceLocation> tags;
private final ResourceLocation icons;
private final Map<String, Integer> prereqAttributes;
private final List<ResourceLocation> exclusiveWith;
public SkillNode(ResourceLocation id,
Component title,
@@ -27,7 +28,8 @@ public class SkillNode {
List<ResourceLocation> links,
List<ResourceLocation> tags,
ResourceLocation icons,
Map<String, Integer> prereqAttributes) {
Map<String, Integer> prereqAttributes,
List<ResourceLocation> exclusiveWith){
this.id = id;
this.title = title;
@@ -39,6 +41,7 @@ public class SkillNode {
this.tags = List.copyOf(tags);
this.icons = icons;
this.prereqAttributes = Map.copyOf(prereqAttributes);
this.exclusiveWith = List.copyOf(exclusiveWith);
}
public ResourceLocation getId() {
@@ -81,6 +84,10 @@ public class SkillNode {
return prereqAttributes;
}
public List<ResourceLocation> getExclusiveWith() {
return exclusiveWith;
}
public boolean isRoot() {
return links.isEmpty();
}
@@ -61,6 +61,11 @@ public class SkillNodeLoader extends SimpleJsonResourceReloadListener {
prereqAttributes.put(entry.getKey(), entry.getValue().getAsInt());
}
}
List<ResourceLocation> exclusiveWith = new ArrayList<>();
if (obj.has("exclusive_with")) {
obj.getAsJsonArray("exclusive_with").forEach(e ->
exclusiveWith.add(new ResourceLocation(e.getAsString())));
}
SkillNode node = new SkillNode(
nodeId,
Component.literal(title),
@@ -70,8 +75,10 @@ public class SkillNodeLoader extends SimpleJsonResourceReloadListener {
links,
tags,
icons,
prereqAttributes
prereqAttributes,
exclusiveWith
);
SkillNodeRegistry.put(node);
});
SkillEngine.LOGGER.info("Loaded {} skill nodes", SkillNodeRegistry.all().size());